|
|
@ -12,19 +12,19 @@ type QuestionDateProps = { |
|
|
disabled?: boolean; |
|
|
disabled?: boolean; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const MONTHS = [ |
|
|
|
|
|
{ value: "01", label: "01 - January" }, |
|
|
|
|
|
{ value: "02", label: "02 - February" }, |
|
|
|
|
|
{ value: "03", label: "03 - March" }, |
|
|
|
|
|
{ value: "04", label: "04 - April" }, |
|
|
|
|
|
{ value: "05", label: "05 - May" }, |
|
|
|
|
|
{ value: "06", label: "06 - June" }, |
|
|
|
|
|
{ value: "07", label: "07 - July" }, |
|
|
|
|
|
{ value: "08", label: "08 - August" }, |
|
|
|
|
|
{ value: "09", label: "09 - September" }, |
|
|
|
|
|
{ value: "10", label: "10 - October" }, |
|
|
|
|
|
{ value: "11", label: "11 - November" }, |
|
|
|
|
|
{ value: "12", label: "12 - December" }, |
|
|
|
|
|
|
|
|
const MONTH_VALUES = [ |
|
|
|
|
|
"01", |
|
|
|
|
|
"02", |
|
|
|
|
|
"03", |
|
|
|
|
|
"04", |
|
|
|
|
|
"05", |
|
|
|
|
|
"06", |
|
|
|
|
|
"07", |
|
|
|
|
|
"08", |
|
|
|
|
|
"09", |
|
|
|
|
|
"10", |
|
|
|
|
|
"11", |
|
|
|
|
|
"12", |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
const DAYS = Array.from({ length: 31 }, (_, i) => { |
|
|
const DAYS = Array.from({ length: 31 }, (_, i) => { |
|
|
@ -50,6 +50,16 @@ export function QuestionDate({ |
|
|
const value = getAnswerValue(question, questionIndex); |
|
|
const value = getAnswerValue(question, questionIndex); |
|
|
const dateValue = typeof value === "string" ? value : ""; |
|
|
const dateValue = typeof value === "string" ? value : ""; |
|
|
|
|
|
|
|
|
|
|
|
const months = useMemo(() => { |
|
|
|
|
|
return MONTH_VALUES.map((val, idx) => { |
|
|
|
|
|
const date = new Date(2000, idx, 15); |
|
|
|
|
|
const label = new Intl.DateTimeFormat(`${locale}-u-ca-gregory`, { |
|
|
|
|
|
month: "long", |
|
|
|
|
|
}).format(date); |
|
|
|
|
|
return { value: val, label }; |
|
|
|
|
|
}); |
|
|
|
|
|
}, [locale]); |
|
|
|
|
|
|
|
|
const [selectedYear, setSelectedYear] = useState(() => { |
|
|
const [selectedYear, setSelectedYear] = useState(() => { |
|
|
const parts = dateValue ? dateValue.split("-") : []; |
|
|
const parts = dateValue ? dateValue.split("-") : []; |
|
|
return parts[0] || ""; |
|
|
return parts[0] || ""; |
|
|
@ -170,7 +180,7 @@ export function QuestionDate({ |
|
|
className="h-[54px] w-full cursor-pointer rounded-[16px] border border-[#D0D5DD] bg-white px-3 text-[15px] font-medium text-[#181818] outline-none transition-all hover:border-[#98A2B3] focus:border-[#6F6F6F] focus:ring-1 focus:ring-[#6F6F6F]" |
|
|
className="h-[54px] w-full cursor-pointer rounded-[16px] border border-[#D0D5DD] bg-white px-3 text-[15px] font-medium text-[#181818] outline-none transition-all hover:border-[#98A2B3] focus:border-[#6F6F6F] focus:ring-1 focus:ring-[#6F6F6F]" |
|
|
> |
|
|
> |
|
|
<option value="">Month</option> |
|
|
<option value="">Month</option> |
|
|
{MONTHS.map((m) => ( |
|
|
|
|
|
|
|
|
{months.map((m) => ( |
|
|
<option key={m.value} value={m.value}> |
|
|
<option key={m.value} value={m.value}> |
|
|
{m.label} |
|
|
{m.label} |
|
|
</option> |
|
|
</option> |
|
|
|