date issue 7

This commit is contained in:
2025-05-19 08:49:04 +05:30
parent b5132581c0
commit 67dcc94d8e
4 changed files with 18 additions and 2 deletions

View File

@@ -257,7 +257,8 @@ export function AppointmentForm({
: `Appointment with ${selectedStaff?.name}`; : `Appointment with ${selectedStaff?.name}`;
} }
const formattedDate = format(data.date, "yyyy-MM-dd"); const formattedDate = data.date.toLocaleDateString("en-CA");
onSubmit({ onSubmit({
...data, ...data,

View File

@@ -383,12 +383,16 @@ export default function AppointmentsPage() {
appointmentData.date instanceof Date appointmentData.date instanceof Date
? appointmentData.date ? appointmentData.date
: new Date(appointmentData.date); // this is unsafe if it's "yyyy-MM-dd" : new Date(appointmentData.date); // this is unsafe if it's "yyyy-MM-dd"
console.log("Appoiment date.date ",appointmentData.date);
console.log("Raw date", rawDate);
const updatedData = { const updatedData = {
...appointmentData, ...appointmentData,
date: toUTCDateString(rawDate), // 👈 This ensures consistent date across all environments date: toUTCDateString(rawDate), // 👈 This ensures consistent date across all environments
}; };
console.log("update data: ", toUTCDateString(rawDate));
// Check if we're editing an existing appointment with a valid ID // Check if we're editing an existing appointment with a valid ID
if ( if (
editingAppointment && editingAppointment &&

10
package-lock.json generated
View File

@@ -12,6 +12,7 @@
"packages/*" "packages/*"
], ],
"dependencies": { "dependencies": {
"date-fns-tz": "^3.2.0",
"dotenv": "^16.5.0", "dotenv": "^16.5.0",
"dotenv-cli": "^8.0.0", "dotenv-cli": "^8.0.0",
"shx": "^0.4.0" "shx": "^0.4.0"
@@ -6360,6 +6361,15 @@
"url": "https://github.com/sponsors/kossnocorp" "url": "https://github.com/sponsors/kossnocorp"
} }
}, },
"node_modules/date-fns-tz": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/date-fns-tz/-/date-fns-tz-3.2.0.tgz",
"integrity": "sha512-sg8HqoTEulcbbbVXeg84u5UnlsQa8GS5QXMqjjYIhS4abEVVKIUwe0/l/UhrZdKaL/W5eWZNlbTeEIiOXTcsBQ==",
"license": "MIT",
"peerDependencies": {
"date-fns": "^3.0.0 || ^4.0.0"
}
},
"node_modules/debug": { "node_modules/debug": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",

View File

@@ -30,6 +30,7 @@
"packages/*" "packages/*"
], ],
"dependencies": { "dependencies": {
"date-fns-tz": "^3.2.0",
"dotenv": "^16.5.0", "dotenv": "^16.5.0",
"dotenv-cli": "^8.0.0", "dotenv-cli": "^8.0.0",
"shx": "^0.4.0" "shx": "^0.4.0"