date issue 4
This commit is contained in:
@@ -257,20 +257,19 @@ export function AppointmentForm({
|
|||||||
: `Appointment with ${selectedStaff?.name}`;
|
: `Appointment with ${selectedStaff?.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 👇 Use current date if none provided
|
const formattedDate = format(data.date, "yyyy-MM-dd");
|
||||||
const appointmentDate = data.date ? new Date(data.date) : new Date();
|
console.log(
|
||||||
|
"Updating with date:",
|
||||||
if (isNaN(appointmentDate.getTime())) {
|
data.date,
|
||||||
console.error("Invalid date:", data.date);
|
format(data.date, "yyyy-MM-dd")
|
||||||
return;
|
);
|
||||||
}
|
|
||||||
|
|
||||||
onSubmit({
|
onSubmit({
|
||||||
...data,
|
...data,
|
||||||
title,
|
title,
|
||||||
notes,
|
notes,
|
||||||
patientId,
|
patientId,
|
||||||
date: format(appointmentDate, "yyyy-MM-dd"),
|
date: formattedDate,
|
||||||
startTime: data.startTime,
|
startTime: data.startTime,
|
||||||
endTime: data.endTime,
|
endTime: data.endTime,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -371,10 +371,15 @@ export default function AppointmentsPage() {
|
|||||||
const handleAppointmentSubmit = (
|
const handleAppointmentSubmit = (
|
||||||
appointmentData: InsertAppointment | UpdateAppointment
|
appointmentData: InsertAppointment | UpdateAppointment
|
||||||
) => {
|
) => {
|
||||||
// Make sure the date is for the selected date
|
|
||||||
const updatedData = {
|
const updatedData = {
|
||||||
...appointmentData,
|
...appointmentData,
|
||||||
date: format(selectedDate, "yyyy-MM-dd"),
|
date: format(
|
||||||
|
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