fix(date-input): render pg full-ISO dates in the configured format

LocalizedDateInput.toDisplay only matched a bare yyyy-MM-dd, but Postgres
serializes DATE columns as a full ISO datetime, so the field printed the
raw "2026-…T…Z" string (SQLite returned a bare date, hiding it). Match the
leading yyyy-MM-dd of any ISO value and slice the hidden native picker's
value to 10 chars. Fixes ISO-form dates on customer/event/passive-create.
This commit is contained in:
Luca
2026-06-03 11:23:58 +02:00
parent a03146edc9
commit f3a6c8940a
3 changed files with 13 additions and 4 deletions
@@ -53,11 +53,16 @@ export const LocalizedDateInput: React.FC<LocalizedDateInputProps> = ({
})(); })();
const placeholder = normalisedFormat.toLowerCase(); const placeholder = normalisedFormat.toLowerCase();
// ISO → display // ISO → display. NOTE: no `$` anchor — Postgres serialises DATE columns
// as a full ISO datetime ("2026-04-06T00:00:00.000Z"), so we match the
// leading yyyy-MM-dd and ignore any trailing time. (SQLite returns the
// bare date string, which also matches.) Coerced to String in case a
// Date object slips through. Without this the field rendered the raw
// ISO timestamp on pg — see feedback_pg_date_columns_serialize.
const toDisplay = (iso: string): string => { const toDisplay = (iso: string): string => {
if (!iso) return ''; if (!iso) return '';
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso); const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso));
if (!m) return iso; if (!m) return String(iso);
const [, y, mo, d] = m; const [, y, mo, d] = m;
switch (normalisedFormat) { switch (normalisedFormat) {
case 'MM/DD/YYYY': return `${mo}/${d}/${y}`; case 'MM/DD/YYYY': return `${mo}/${d}/${y}`;
@@ -148,7 +153,9 @@ export const LocalizedDateInput: React.FC<LocalizedDateInputProps> = ({
<input <input
ref={nativeRef} ref={nativeRef}
type="date" type="date"
value={value || ''} // Bare yyyy-MM-dd — a native date input rejects a full ISO
// datetime (pg serialisation), which would blank the picker.
value={value ? String(value).slice(0, 10) : ''}
min={min} min={min}
max={max} max={max}
disabled={disabled} disabled={disabled}
+1
View File
@@ -818,6 +818,7 @@
"noTemplate": "Keine Vorlage", "noTemplate": "Keine Vorlage",
"useThemeOnly": "Nur Design-Vorlage verwenden", "useThemeOnly": "Nur Design-Vorlage verwenden",
"customTemplate": "Benutzerdefinierte Vorlage", "customTemplate": "Benutzerdefinierte Vorlage",
"createInvoice": "Rechnung erstellen",
"title": "Veranstaltungen", "title": "Veranstaltungen",
"create": "Veranstaltung erstellen", "create": "Veranstaltung erstellen",
"createEvent": "Veranstaltung erstellen", "createEvent": "Veranstaltung erstellen",
+1
View File
@@ -607,6 +607,7 @@
"noTemplate": "No Template", "noTemplate": "No Template",
"useThemeOnly": "Use theme preset only", "useThemeOnly": "Use theme preset only",
"customTemplate": "Custom Template", "customTemplate": "Custom Template",
"createInvoice": "Create invoice",
"rename": { "rename": {
"button": "Rename", "button": "Rename",
"title": "Rename Event", "title": "Rename Event",