Skip to content

Commit

Permalink
feat(buildteams): ✨ Disable applications
Browse files Browse the repository at this point in the history
  • Loading branch information
Nudelsuppe42 committed Jan 3, 2024
1 parent 26d2226 commit c1b5953
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
38 changes: 28 additions & 10 deletions src/pages/teams/[team]/apply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { IconAlertCircle, IconCheck } from '@tabler/icons-react';
import { signIn, useSession } from 'next-auth/react';
import useSWR, { mutate } from 'swr';

import { useForm } from '@mantine/form';
import { showNotification } from '@mantine/notifications';
import { ApplicationQuestions } from '../../../utils/application/ApplicationQuestions';
import { IconChevronLeft } from '@tabler/icons-react';
import { NextPage } from 'next';
import Page from '../../../components/Page';
import fetcher from '../../../utils/Fetcher';
import sanitize from 'sanitize-html';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { showNotification } from '@mantine/notifications';
import { useForm } from '@mantine/form';
import { useRouter } from 'next/router';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import sanitize from 'sanitize-html';
import Page from '../../../components/Page';
import { useUser } from '../../../hooks/useUser';
import fetcher from '../../../utils/Fetcher';
import { ApplicationQuestions } from '../../../utils/application/ApplicationQuestions';

const Apply: NextPage = ({ data, buildteam }: any) => {
const router = useRouter();
Expand Down Expand Up @@ -101,7 +101,7 @@ const Apply: NextPage = ({ data, buildteam }: any) => {
/>
{!pastApplications || typeof pastApplications == 'string' ? (
<>
<Skeleton height={50} my={'md'} />
<Skeleton height={300} my={'md'} />
<Button leftSection={<IconChevronLeft />} mt="md" onClick={() => router.back()}>
{t('common:button.back')}
</Button>
Expand Down Expand Up @@ -133,14 +133,25 @@ const Apply: NextPage = ({ data, buildteam }: any) => {
color="blue"
mb="md"
styles={{ label: { minWidth: 100 } }}
disabled={loading}
disabled={loading || !buildteam?.allowApplications}
data={[
{ label: t('builder', { ns: 'common' }), value: '0' },
{ label: t('trial', { ns: 'common' }), value: '1' },
]}
/>
</>
)}
{!buildteam?.allowApplications && (
<Alert
mb="md"
icon={<IconAlertCircle size="1rem" />}
title={'Disabled Applications'}
color="red"
>
This BuildTeam has disabled applications. Please message the BuildTeam if you
think this is an error.
</Alert>
)}
{data
?.filter((d: any) => d.trial == trial && d.sort >= 0)
.sort((a: any, b: any) => a.sort - b.sort)
Expand All @@ -153,11 +164,18 @@ const Apply: NextPage = ({ data, buildteam }: any) => {
style={{ marginTop: i > 0 && theme.spacing.md, maxWidth: '55%' }}
onChange={(v: any) => form.setFieldValue(d.id, v)}
error={form.errors[d.id]}
disabled={loading}
disabled={loading || !buildteam?.allowApplications}
/>
);
})}
<Button type="submit" variant="filled" color="blue" mt="md" loading={loading}>
<Button
type="submit"
variant="filled"
color="blue"
mt="md"
loading={loading}
disabled={!buildteam?.allowApplications}
>
{t('common:button.apply')}
</Button>
<Button
Expand Down
9 changes: 8 additions & 1 deletion src/pages/teams/[team]/manage/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ const Settings = ({ data: tempData }: any) => {
mb="xl"
/>
<h3>Applications and Claims</h3>
<Switch
label="Allow Applications"
description="Allow users to apply to this team."
defaultChecked={data.allowApplications}
disabled={!allowSettings}
mb="md"
onChange={(e) => handleUpdate('allowApplications', e.target.checked)}
/>
<Switch
label="Trial Applications"
description="If new Users should be able to apply as Trial to the Build Team and then build their builder application builds on the Build Team´s server."
Expand All @@ -314,7 +322,6 @@ const Settings = ({ data: tempData }: any) => {
onChange={(e) => handleUpdate('instantAccept', e.target.checked)}
/>
<TextInput
required
label="API Webhook"
description="A Endpoint at your custom api that the BTE API can hit when an application is rejected or accepted."
defaultValue={data.webhook}
Expand Down

0 comments on commit c1b5953

Please sign in to comment.