refactor: migrate authentication and signup flow to use external API and improve type safety
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m58s

This commit is contained in:
2025-01-24 11:42:38 +05:00
parent 8ffabb1fcb
commit 0fd269df31
9 changed files with 96 additions and 73 deletions

31
lib/backend-types.ts Normal file
View File

@ -0,0 +1,31 @@
export interface Links {
next_page: string | null;
previous_page: string | null;
}
export interface Meta {
total: number;
per_page: number;
current_page: number;
last_page: number;
}
export interface DataResponse<T> {
meta: Meta;
links: Links;
data: T[];
}
export interface Atoll {
id: number;
islands: Island[];
name: string;
createdAt: string;
updatedAt: string;
}
export interface Island {
id: number;
name: string;
createdAt: string;
updatedAt: string;
}

View File

@ -5,10 +5,10 @@ export const signUpFormSchema = z.object({
.string()
.min(2, { message: "ID Card is required" })
.regex(/^[A][0-9]{6}$/, "Please enter a valid ID Card number."),
atoll_id: z.string().min(2, { message: "Atoll is required." }),
atoll_id: z.string().min(1, { message: "Atoll is required." }),
island_id: z
.string({ required_error: "Island is required." })
.min(2, { message: "Island is required." }),
.min(1, { message: "Island is required." }),
address: z.string().min(2, { message: "address is required." }),
dob: z.coerce.date({ message: "Date of birth is required." }),
phone_number: z
@ -26,5 +26,8 @@ export const signUpFormSchema = z.object({
required_error: "You must accept the privacy policy",
})
.transform((val) => val === "on"),
accNo: z.string().min(2, { message: "Account number is required." }),
accNo: z
.string()
.min(2, { message: "Account number is required." })
.regex(/^(7\d{12}|9\d{16})$/, "Please enter a valid account number"),
});