date issue 5

This commit is contained in:
2025-05-19 08:16:31 +05:30
parent 490c6a22c1
commit 14282fbafe
2 changed files with 11 additions and 11 deletions

View File

@@ -258,11 +258,6 @@ export function AppointmentForm({
}
const formattedDate = format(data.date, "yyyy-MM-dd");
console.log(
"Updating with date:",
data.date,
format(data.date, "yyyy-MM-dd")
);
onSubmit({
...data,

View File

@@ -371,15 +371,20 @@ export default function AppointmentsPage() {
const handleAppointmentSubmit = (
appointmentData: InsertAppointment | UpdateAppointment
) => {
// Converts local date to exact UTC date with no offset issues
function getUTCDateOnly(date: Date) {
return new Date(
Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
);
}
const rawDate =
appointmentData.date instanceof Date
? appointmentData.date
: new Date(appointmentData.date);
const updatedData = {
...appointmentData,
date: format(
appointmentData.date instanceof Date
? appointmentData.date
: new Date(appointmentData.date),
"yyyy-MM-dd"
),
date: getUTCDateOnly(rawDate), // 👈 This ensures consistent date across all environments
};
// Check if we're editing an existing appointment with a valid ID