Skip to content

Commit 7d3b353

Browse files
committed
fix: Form submission bugs
1 parent 8493905 commit 7d3b353

File tree

9 files changed

+55
-10
lines changed

9 files changed

+55
-10
lines changed

admission-web/src/components/common/components/Loader.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
import { cn } from '@/lib/utils/cn';
12
import { Loader2 } from 'lucide-react';
23

34
const sizeMapper = {
5+
tiny: 25,
46
small: 75,
57
medium: 100,
68
large: 160,
79
};
810

911
export function Loader({
1012
size = 'medium',
13+
className,
1114
}: {
12-
size?: 'small' | 'medium' | 'large';
15+
size?: 'tiny' | 'small' | 'medium' | 'large';
16+
className?: string;
1317
}) {
1418
return (
1519
<Loader2
16-
className='mb-7 animate-spin text-violet-700'
20+
className={cn('mb-7 animate-spin text-violet-700', className)}
1721
size={sizeMapper[size]}
1822
/>
1923
);

admission-web/src/components/pages/auth/sign-in/components/login-form.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useRouter } from 'next/navigation';
1717
import { isAxiosError } from 'axios';
1818
import { useCommonToast } from '@/components/ui/toast/use-common-toast';
1919
import { TSignIn, SignInSchema } from '@/lib/schemas/auth.schemas';
20+
import { Loader } from '@/components/common/components/Loader';
2021

2122
export const LoginForm = () => {
2223
const { toastError } = useCommonToast();
@@ -68,7 +69,11 @@ export const LoginForm = () => {
6869
className='w-full'
6970
disabled={form.formState.isSubmitting}
7071
>
71-
Увійти
72+
{form.formState.isSubmitting ? (
73+
<Loader size='tiny' className='mb-0 text-violet-950' />
74+
) : (
75+
'Увійти'
76+
)}
7277
</Button>
7378
</form>
7479
</Form>

admission-web/src/components/pages/auth/sign-up/components/register-form.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
1717
import { useRouter } from 'next/navigation';
1818
import { isAxiosError } from 'axios';
1919
import { TSignUp, SignUpSchema } from '@/lib/schemas/auth.schemas';
20+
import { Loader } from '@/components/common/components/Loader';
2021

2122
export const RegisterForm = () => {
2223
const { push } = useRouter();
@@ -123,7 +124,11 @@ export const RegisterForm = () => {
123124
className='w-full'
124125
disabled={form.formState.isSubmitting}
125126
>
126-
Зареєструватись
127+
{form.formState.isSubmitting ? (
128+
<Loader size='tiny' className='mb-0 text-violet-950' />
129+
) : (
130+
'Зареєструватись'
131+
)}
127132
</Button>
128133
</form>
129134
</Form>

admission-web/src/components/pages/entrant/documents/components/DocumentsForm.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { EducationalDegree } from '$/utils/src/enums/EducationalDegreeEnum';
3838
import { StudyForm } from '$/utils/src/enums/StudyFormEnum';
3939
import { Specialty } from '$/utils/src/enums/SpecialtyEnum';
4040
import { PaymentType } from '$/utils/src/enums/PaymentTypeEnum';
41+
import { Loader } from '@/components/common/components/Loader';
42+
import { useQueryClient } from '@tanstack/react-query';
4143

4244
export const DocumentsForm = () => {
4345
const { toastError, toastSuccess } = useCommonToast();
@@ -60,6 +62,7 @@ export const DocumentsForm = () => {
6062
const studyForm = form.watch('studyForm');
6163

6264
const { push } = useRouter();
65+
const queryClient = useQueryClient();
6366

6467
const { user } = useAuth();
6568

@@ -85,6 +88,9 @@ export const DocumentsForm = () => {
8588
] as string)
8689
: null,
8790
});
91+
await queryClient.refetchQueries({
92+
queryKey: ['personal-data', user!.id],
93+
});
8894
push('/');
8995
toastSuccess(
9096
'Договір успішно створений!',
@@ -412,8 +418,16 @@ export const DocumentsForm = () => {
412418
{specialty === Specialty.F6 && degree !== EducationalDegree.MASTER && (
413419
<PriorityForm educationalPrograms={ISTeduPrograms} form={form} />
414420
)}
415-
<Button type='submit' className='w-full md:w-[185px]'>
416-
Надіслати договір
421+
<Button
422+
type='submit'
423+
className='w-full md:w-[185px]'
424+
disabled={form.formState.isSubmitting}
425+
>
426+
{form.formState.isSubmitting ? (
427+
<Loader size='tiny' className='mb-0 text-violet-950' />
428+
) : (
429+
'Надіслати договір'
430+
)}
417431
</Button>
418432
</form>
419433
</Form>

admission-web/src/components/pages/entrant/documents/components/PriorityForm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ const PriorityForm: FC<PriorityFormProps> = ({
6464
>
6565
<FormControl>
6666
<SelectTrigger className='w-[320px] md:w-[350px]'>
67-
<SelectValue placeholder='Вибери зі списку' />
67+
<div className='line-clamp-1 break-words text-start'>
68+
<SelectValue placeholder='Вибери зі списку' />
69+
</div>
6870
</SelectTrigger>
6971
</FormControl>
7072
<SelectContent className='w-[320px] md:w-auto'>

admission-web/src/components/pages/entrant/main/components/StudentPayerBlock.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export function StudentPayerBlock({ payerData }: { payerData: PersonalData }) {
1313
<div className='mt-3 flex flex-col gap-3 text-sm font-light'>
1414
<h6>Номер телефону: {payerData.phoneNumber}</h6>
1515
<h6>Електронна пошта: {payerData.email}</h6>
16-
<h6>Номер паспорту: {payerData.passportNumber}</h6>
16+
<h6>
17+
Номер паспорту: {payerData?.passportSeries}{' '}
18+
{payerData.passportNumber}
19+
</h6>
1720
<h6>Дата видачі: {payerData.passportDate}</h6>
1821
<h6>Орган видачі: {payerData.passportInstitute}</h6>
1922
<h6>РНОКПП: {payerData.idCode}</h6>

admission-web/src/components/pages/entrant/main/components/StudentPersonalDataBlock.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export function StudentPersonalDataBlock({ userId }: { userId: string }) {
3636
<div className='mt-3 flex flex-col gap-3 text-sm font-light'>
3737
<h6>Номер телефону: {userData.entrantData.phoneNumber}</h6>
3838
<h6>Електронна пошта: {userData.entrantData.email}</h6>
39-
<h6>Номер паспорту: {userData.entrantData.passportNumber}</h6>
39+
<h6>
40+
Номер паспорту: {userData.entrantData.passportSeries}{' '}
41+
{userData.entrantData.passportNumber}
42+
</h6>
4043
<h6>Дата видачі: {userData.entrantData.passportDate}</h6>
4144
<h6>Ким видано: {userData.entrantData.passportInstitute}</h6>
4245
<h6>РНОКПП: {userData.entrantData.idCode}</h6>

admission-web/src/components/pages/entrant/main/components/StudentRepresentativeBlock.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export function StudentRepresentativeBlock({
1717
<div className='mt-3 flex flex-col gap-3 text-sm font-light'>
1818
<h6>Номер телефону: {representativeData.phoneNumber}</h6>
1919
<h6>Електронна пошта: {representativeData.email}</h6>
20-
<h6>Номер паспорту: {representativeData.passportNumber}</h6>
20+
<h6>
21+
Номер паспорту: {representativeData.passportSeries}{' '}
22+
{representativeData.passportNumber}
23+
</h6>
2124
<h6>Дата видачі: {representativeData.passportDate}</h6>
2225
<h6>Орган видачі: {representativeData.passportInstitute}</h6>
2326
<h6>РНОКПП: {representativeData.idCode}</h6>

admission-web/src/components/pages/entrant/personal-data/components/SubmitPage.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { usePersonalDataContext } from '@/lib/contexts/PersonalDataContext';
1111
import { FundingSourceLabels } from '@/lib/constants/fundingSourceLabels';
1212
import { FundingSource } from '$/utils/src/enums/FundingSourceEnum';
1313
import { useToast } from '@/components/ui/toast/use-toast';
14+
import { useQueryClient } from '@tanstack/react-query';
1415

1516
const SubmitPage: FC = () => {
1617
const { toast } = useToast();
@@ -29,6 +30,7 @@ const SubmitPage: FC = () => {
2930
const [adminCode, setAdminCode] = useState('');
3031
const { user } = useAuth();
3132
const { push } = useRouter();
33+
const queryClient = useQueryClient();
3234

3335
const onSubmit = async () => {
3436
if (isSubmittingInCorpus) {
@@ -44,6 +46,9 @@ const SubmitPage: FC = () => {
4446
},
4547
user!.id
4648
);
49+
await queryClient.refetchQueries({
50+
queryKey: ['personal-data', user!.id],
51+
});
4752
toast({
4853
title: 'Особисті дані оновлено!',
4954
variant: 'success',
@@ -58,6 +63,7 @@ const SubmitPage: FC = () => {
5863
});
5964
}
6065
};
66+
6167
return (
6268
<div className='flex flex-col gap-8'>
6369
{showPopup && (

0 commit comments

Comments
 (0)