changed native date to shadcn

This commit is contained in:
rgrgogu
2026-07-15 23:23:19 +08:00
parent 9ebe706ef9
commit 5c391e7abd
+6 -5
View File
@@ -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'),
})