Initial commit
This commit is contained in:
20
src/screens/auth/registeration/lib/form.ts
Normal file
20
src/screens/auth/registeration/lib/form.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// form.ts
|
||||
import { z } from 'zod';
|
||||
|
||||
export const FirstStepSchema = z.object({
|
||||
firstName: z.string().min(3, "Eng kamida 3ta belgi bo'lishi kerak"),
|
||||
lastName: z.string().min(3, "Eng kamida 3ta belgi bo'lishi kerak"),
|
||||
phoneNumber: z.string().min(12, 'Xato raqam kiritildi'),
|
||||
branchId: z.number().min(1, 'Filialni tanlang'),
|
||||
recommend: z.string().min(1, 'Majburiy maydon'),
|
||||
});
|
||||
|
||||
export const SecondStepSchema = z.object({
|
||||
passportSeriya: z.string().length(2, '2 ta harf kerak'),
|
||||
birthDate: z.string().min(8, 'Majburiy maydon'),
|
||||
passportNumber: z.string().length(7, '7 ta raqam kerak'),
|
||||
jshshir: z.string().length(14, '14 ta raqam kerak'),
|
||||
});
|
||||
|
||||
export type FirstStepFormType = z.infer<typeof FirstStepSchema>;
|
||||
export type SecondStepFormType = z.infer<typeof SecondStepSchema>;
|
||||
42
src/screens/auth/registeration/lib/modalStore.ts
Normal file
42
src/screens/auth/registeration/lib/modalStore.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface ModalState {
|
||||
isVisible: boolean;
|
||||
title: string;
|
||||
message: string;
|
||||
type: 'success' | 'error' | 'info';
|
||||
onConfirm: () => void;
|
||||
onCancel?: () => void;
|
||||
openModal: (
|
||||
title: string,
|
||||
message: string,
|
||||
type?: 'success' | 'error' | 'info',
|
||||
onConfirm?: () => void,
|
||||
onCancel?: () => void
|
||||
) => void;
|
||||
closeModal: () => void;
|
||||
}
|
||||
|
||||
export const useModalStore = create<ModalState>((set) => ({
|
||||
isVisible: false,
|
||||
title: '',
|
||||
message: '',
|
||||
type: 'info',
|
||||
onConfirm: () => { },
|
||||
onCancel: undefined,
|
||||
|
||||
openModal: (title, message, type = 'info', onConfirm, onCancel) =>
|
||||
set({
|
||||
isVisible: true,
|
||||
title,
|
||||
message,
|
||||
type,
|
||||
onConfirm: () => {
|
||||
if (onConfirm) onConfirm();
|
||||
set({ isVisible: false });
|
||||
},
|
||||
onCancel: onCancel || undefined,
|
||||
}),
|
||||
|
||||
closeModal: () => set({ isVisible: false }),
|
||||
}));
|
||||
28
src/screens/auth/registeration/lib/userstore.ts
Normal file
28
src/screens/auth/registeration/lib/userstore.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface UserState {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
phoneNumber: string;
|
||||
setUser: (user: Partial<UserState>) => void;
|
||||
clearUser: () => void;
|
||||
}
|
||||
|
||||
export const useUserStore = create<UserState>(set => ({
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
phoneNumber: '',
|
||||
|
||||
setUser: user =>
|
||||
set(state => ({
|
||||
...state,
|
||||
...user,
|
||||
})),
|
||||
|
||||
clearUser: () =>
|
||||
set({
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
phoneNumber: '',
|
||||
}),
|
||||
}));
|
||||
Reference in New Issue
Block a user