fix(quotes): quote date (تاریخ پیشنهاد) defaults to current time, not midnight
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).
This commit is contained in:
@@ -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();
|
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 } {
|
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);
|
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() };
|
return { h: d.getHours(), m: d.getMinutes() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ export function WizardPage() {
|
|||||||
const [assignment, setAssignment] = useState<Record<string, string[]>>({});
|
const [assignment, setAssignment] = useState<Record<string, string[]>>({});
|
||||||
|
|
||||||
const [quoteDate, setQuoteDate] = useState<string | null>(() => {
|
const [quoteDate, setQuoteDate] = useState<string | null>(() => {
|
||||||
const d = new Date();
|
// تاریخ پیشنهاد: همین الان (ساعت و دقیقهی فعلی) — نه نیمهشب
|
||||||
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).toISOString();
|
return new Date().toISOString();
|
||||||
});
|
});
|
||||||
const [expiryDate, setExpiryDate] = useState<string | null>(null);
|
const [expiryDate, setExpiryDate] = useState<string | null>(null);
|
||||||
const [notes, setNotes] = useState("");
|
const [notes, setNotes] = useState("");
|
||||||
|
|||||||
Reference in New Issue
Block a user