refactor(convertDateToAPI): parsedDate new Date

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-05-07 09:36:31 +07:00
parent 780a815a24
commit 9eaa28711d

View file

@ -1252,7 +1252,15 @@ export const useCounterMixin = defineStore("mixin", () => {
// กรณีมีเฉพาะ date
function convertDateToAPI(date: Date | null) {
return date ? format(date, "yyyy-MM-dd") : null;
if (!date) return null;
const parsedDate = new Date(date);
if (parsedDate) {
return format(parsedDate, "yyyy-MM-dd");
} else {
return null;
}
}
// กรณี datetime