From 5c391e7abdcc583ea9b06b72ce4e8fa8a2d3816b Mon Sep 17 00:00:00 2001 From: rgrgogu Date: Wed, 15 Jul 2026 23:23:19 +0800 Subject: [PATCH] changed native date to shadcn --- src/modules/auth/components/RegisterForm.jsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/auth/components/RegisterForm.jsx b/src/modules/auth/components/RegisterForm.jsx index c6c6cbb..d152512 100644 --- a/src/modules/auth/components/RegisterForm.jsx +++ b/src/modules/auth/components/RegisterForm.jsx @@ -41,9 +41,10 @@ import { } from '@/components/ui/alert-dialog' import { Eye, EyeOff, LoaderCircle, Users, Check, CalendarIcon } from 'lucide-react' -// Birthday must put the user between 13 and 120 years old (mirrors personalSchema below) +// Birthday must put the user's birth year between 3 and 120 years ago (mirrors personalSchema below). +// Bounds are whole calendar years (Jan 1 / Dec 31) so every month/day is selectable within a boundary year. const MIN_BIRTHDATE = new Date(new Date().getFullYear() - 120, 0, 1) -const MAX_BIRTHDATE = new Date(new Date().getFullYear() - 13, new Date().getMonth(), new Date().getDate()) +const MAX_BIRTHDATE = new Date(new Date().getFullYear() - 3, 11, 31) // ─── Step schemas ───────────────────────────────────────────────────────────── const personalSchema = z.object({ @@ -56,9 +57,9 @@ const personalSchema = z.object({ .min(1, 'Birthday is required') .refine((v) => !isNaN(Date.parse(v)), { message: 'Invalid date' }) .refine((v) => { - const age = (Date.now() - new Date(v)) / (1000 * 60 * 60 * 24 * 365.25) - return age >= 13 && age <= 120 - }, { message: 'Must be at least 13 years old' }), + const yearsAgo = new Date().getFullYear() - new Date(v).getFullYear() + return yearsAgo >= 3 && yearsAgo <= 120 + }, { message: 'Must be at least 3 years old' }), occupation: z.string().min(1, 'Occupation is required').max(100), phone: z.string().min(1, 'Phone number is required').regex(/^\+?[0-9\s\-()]{7,20}$/, 'Invalid phone number'), })