Improve the inventory page 3

This commit is contained in:
Urtzi Alfaro
2025-09-18 08:06:32 +02:00
parent dcb3ce441b
commit ae77a0e1c5
31 changed files with 2376 additions and 1774 deletions

View File

@@ -564,7 +564,7 @@ export const formatDateInTimezone = (
): string => {
try {
const dateObj = typeof date === 'string' ? parseISO(date) : date;
if (!isValid(dateObj)) {
return '';
}
@@ -580,4 +580,23 @@ export const formatDateInTimezone = (
} catch {
return formatDate(date, formatStr);
}
};
// Convert HTML date input (YYYY-MM-DD) to end-of-day datetime for API
export const formatExpirationDateForAPI = (dateString: string): string | undefined => {
try {
if (!dateString) return undefined;
// Parse the date string (YYYY-MM-DD format from HTML date input)
const dateObj = parseISO(dateString);
if (!isValid(dateObj)) {
return undefined;
}
// Set to end of day for expiration dates and return ISO string
return getEndOfDay(dateObj).toISOString();
} catch {
return undefined;
}
};