generated from muhtadeetaron/nextjs-template
fix(api): fix api endpoint logic #1
This commit is contained in:
@ -22,13 +22,17 @@ export default function RegisterPage() {
|
||||
const { setToken } = useAuth();
|
||||
const router = useRouter();
|
||||
const [form, setForm] = useState<RegisterForm>({
|
||||
name: "",
|
||||
institution: "",
|
||||
sscRoll: "",
|
||||
hscRoll: "",
|
||||
full_name: "",
|
||||
username: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
password: "",
|
||||
phone_number: "",
|
||||
ssc_roll: 0,
|
||||
ssc_board: "",
|
||||
hsc_roll: 0,
|
||||
hsc_board: "",
|
||||
college: "",
|
||||
preparation_unit: "",
|
||||
});
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
@ -44,8 +48,8 @@ export default function RegisterPage() {
|
||||
};
|
||||
|
||||
const validateForm = () => {
|
||||
const { sscRoll, hscRoll, password } = form;
|
||||
if (sscRoll === hscRoll) {
|
||||
const { ssc_roll, hsc_roll, password } = form;
|
||||
if (ssc_roll === hsc_roll) {
|
||||
return "SSC Roll and HSC Roll must be unique.";
|
||||
}
|
||||
const passwordRegex =
|
||||
@ -93,11 +97,11 @@ export default function RegisterPage() {
|
||||
return (
|
||||
<BackgroundWrapper>
|
||||
<div className="min-h-screen flex flex-col items-center justify-center px-4 py-10">
|
||||
<div className="w-full max-w-md space-y-6">
|
||||
<div className="w-full space-y-6">
|
||||
<div className="w-full aspect-[368/89] mx-auto">
|
||||
<Image
|
||||
src="/images/logo/logo.png"
|
||||
alt="Logo"
|
||||
alt="logo"
|
||||
width={368}
|
||||
height={89}
|
||||
className="w-full h-auto"
|
||||
@ -106,48 +110,34 @@ export default function RegisterPage() {
|
||||
|
||||
<div className="space-y-10">
|
||||
<div className="space-y-6">
|
||||
<h1 className="text-2xl font-semibold">Personal Info</h1>
|
||||
<FormField
|
||||
title="Full name"
|
||||
value={form.name}
|
||||
handleChangeText={(value) => setForm({ ...form, name: value })}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
title="Institution"
|
||||
value={form.institution}
|
||||
value={form.full_name}
|
||||
handleChangeText={(value) =>
|
||||
setForm({ ...form, institution: value })
|
||||
setForm({ ...form, full_name: value })
|
||||
}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
title="SSC Roll No."
|
||||
value={form.sscRoll}
|
||||
title="User name"
|
||||
value={form.username}
|
||||
handleChangeText={(value) =>
|
||||
setForm({ ...form, sscRoll: value })
|
||||
setForm({ ...form, username: value })
|
||||
}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
title="HSC Roll No."
|
||||
value={form.hscRoll}
|
||||
title="Phone Number"
|
||||
value={form.phone_number}
|
||||
handleChangeText={(value) =>
|
||||
setForm({ ...form, hscRoll: value })
|
||||
setForm({ ...form, phone_number: value })
|
||||
}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
title="Email Address"
|
||||
value={form.email}
|
||||
handleChangeText={(value) => setForm({ ...form, email: value })}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
title="Phone Number"
|
||||
value={form.phone}
|
||||
handleChangeText={(value) => setForm({ ...form, phone: value })}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
title="Password"
|
||||
value={form.password}
|
||||
@ -156,6 +146,58 @@ export default function RegisterPage() {
|
||||
}
|
||||
placeholder={undefined}
|
||||
/>
|
||||
<h1 className="text-2xl font-semibold">Educational Background</h1>
|
||||
|
||||
<FormField
|
||||
title="College"
|
||||
value={form.college}
|
||||
handleChangeText={(value) =>
|
||||
setForm({ ...form, college: value })
|
||||
}
|
||||
/>
|
||||
<FormField
|
||||
title="Preparation Unit"
|
||||
value={form.preparation_unit}
|
||||
handleChangeText={(value) =>
|
||||
setForm({ ...form, preparation_unit: value })
|
||||
}
|
||||
/>
|
||||
<div className="w-full flex gap-4">
|
||||
<FormField
|
||||
title="SSC Board"
|
||||
value={form.ssc_board}
|
||||
handleChangeText={(value) =>
|
||||
setForm({ ...form, ssc_board: value })
|
||||
}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
title="SSC Roll No."
|
||||
value={form.ssc_roll}
|
||||
handleChangeText={(value: string) =>
|
||||
setForm({ ...form, ssc_roll: Number(value) })
|
||||
}
|
||||
className="max-w-26"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="w-full flex gap-4">
|
||||
<FormField
|
||||
title="HSC Board"
|
||||
value={form.hsc_board}
|
||||
handleChangeText={(value) =>
|
||||
setForm({ ...form, hsc_board: value })
|
||||
}
|
||||
/>
|
||||
<FormField
|
||||
title="HSC Roll No."
|
||||
value={form.hsc_roll}
|
||||
handleChangeText={(value: string) =>
|
||||
setForm({ ...form, hsc_roll: Number(value) })
|
||||
}
|
||||
className="max-w-26"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && <DestructibleAlert text={error} />}
|
||||
|
||||
Reference in New Issue
Block a user