date issue 5
This commit is contained in:
@@ -258,11 +258,6 @@ export function AppointmentForm({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const formattedDate = format(data.date, "yyyy-MM-dd");
|
const formattedDate = format(data.date, "yyyy-MM-dd");
|
||||||
console.log(
|
|
||||||
"Updating with date:",
|
|
||||||
data.date,
|
|
||||||
format(data.date, "yyyy-MM-dd")
|
|
||||||
);
|
|
||||||
|
|
||||||
onSubmit({
|
onSubmit({
|
||||||
...data,
|
...data,
|
||||||
|
|||||||
@@ -371,15 +371,20 @@ export default function AppointmentsPage() {
|
|||||||
const handleAppointmentSubmit = (
|
const handleAppointmentSubmit = (
|
||||||
appointmentData: InsertAppointment | UpdateAppointment
|
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 = {
|
const updatedData = {
|
||||||
...appointmentData,
|
...appointmentData,
|
||||||
date: format(
|
date: getUTCDateOnly(rawDate), // 👈 This ensures consistent date across all environments
|
||||||
appointmentData.date instanceof Date
|
|
||||||
? appointmentData.date
|
|
||||||
: new Date(appointmentData.date),
|
|
||||||
"yyyy-MM-dd"
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if we're editing an existing appointment with a valid ID
|
// Check if we're editing an existing appointment with a valid ID
|
||||||
|
|||||||
Reference in New Issue
Block a user