From 3bdb0027f3f373f4b3cdaae854447615b397ce6f Mon Sep 17 00:00:00 2001 From: "reza.g" Date: Sun, 6 Sep 2026 19:03:10 +0330 Subject: [PATCH] =?UTF-8?q?fix(quotes):=20quote=20date=20(=D8=AA=D8=A7?= =?UTF-8?q?=D8=B1=DB=8C=D8=AE=20=D9=BE=DB=8C=D8=B4=D9=86=D9=87=D8=A7=D8=AF?= =?UTF-8?q?)=20defaults=20to=20current=20time,=20not=20midnight?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wizard Step 5 initializes the quote date with the client's current local time instead of 00:00, and the Jalali datepicker's hour/minute controls default to the current clock whenever no explicit time is configured (clicking «امروز» already used the current time). Date-only consumers are unaffected (times are stripped at the API layer). --- frontend/src/components/JalaliDatePicker.tsx | 11 +++++++++-- frontend/src/pages/Wizard/WizardPage.tsx | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/JalaliDatePicker.tsx b/frontend/src/components/JalaliDatePicker.tsx index 0c28d9a..97d66d1 100644 --- a/frontend/src/components/JalaliDatePicker.tsx +++ b/frontend/src/components/JalaliDatePicker.tsx @@ -39,10 +39,17 @@ function buildIso(jy: number, jm: number, jd: number, h: number, m: number): str return new Date(gy, gm - 1, gd, h, m).toISOString(); } +// وقتی هنوز زمان مشخصی ست نشده، ساعت/دقیقه‌ی فعلی سیستم پیش‌فرض است +// (نه ۰۰:۰۰) — دکمه‌ی «امروز» و انتخاب روز، همین زمان را نگه می‌دارند. +function nowTime(): { h: number; m: number } { + const d = new Date(); + return { h: d.getHours(), m: d.getMinutes() }; +} + function timeOf(iso: string | null): { h: number; m: number } { - if (!iso) return { h: 0, m: 0 }; + if (!iso) return nowTime(); const d = new Date(iso); - if (Number.isNaN(d.getTime())) return { h: 0, m: 0 }; + if (Number.isNaN(d.getTime())) return nowTime(); return { h: d.getHours(), m: d.getMinutes() }; } diff --git a/frontend/src/pages/Wizard/WizardPage.tsx b/frontend/src/pages/Wizard/WizardPage.tsx index 0611261..f48c80e 100644 --- a/frontend/src/pages/Wizard/WizardPage.tsx +++ b/frontend/src/pages/Wizard/WizardPage.tsx @@ -73,8 +73,8 @@ export function WizardPage() { const [assignment, setAssignment] = useState>({}); const [quoteDate, setQuoteDate] = useState(() => { - const d = new Date(); - return new Date(d.getFullYear(), d.getMonth(), d.getDate()).toISOString(); + // تاریخ پیشنهاد: همین الان (ساعت و دقیقه‌ی فعلی) — نه نیمه‌شب + return new Date().toISOString(); }); const [expiryDate, setExpiryDate] = useState(null); const [notes, setNotes] = useState("");