diff --git a/components/LogbuchForm.tsx b/components/LogbuchForm.tsx index b713c5e..2772d63 100644 --- a/components/LogbuchForm.tsx +++ b/components/LogbuchForm.tsx @@ -19,10 +19,24 @@ function toLocalDatetimeValue(isoOrDatetime: string): string { return isoOrDatetime.slice(0, 16); } +function snapTo15(value: string): string { + if (!value) return value; + const d = new Date(value); + if (isNaN(d.getTime())) return value; + const rem = d.getMinutes() % 15; + if (rem !== 0) { + d.setMinutes(d.getMinutes() + (15 - rem)); + d.setSeconds(0); + } + const pad = (n: number) => String(n).padStart(2, '0'); + return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`; +} + function nowLocalDatetime(): string { const now = new Date(); const pad = (n: number) => String(n).padStart(2, '0'); - return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}T${pad(now.getHours())}:${pad(now.getMinutes())}`; + const raw = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}T${pad(now.getHours())}:${pad(now.getMinutes())}`; + return snapTo15(raw); } const NO_OBJEKTE_ARTEN: ArtFuehrung[] = ['BEO-Sitzung', 'Technischer Dienst']; @@ -160,7 +174,7 @@ export default function LogbuchForm({ kuppel, currentUserBeo, editEntry, onSaved const labelCls = 'block text-sm font-medium text-gray-700 mb-0.5'; return ( -
+ {/* Art der Führung — volle Breite */}
@@ -179,8 +193,9 @@ export default function LogbuchForm({ kuppel, currentUserBeo, editEntry, onSaved setBeginn(e.target.value)} + onChange={(e) => setBeginn(snapTo15(e.target.value))} required + step={900} className="w-full px-2 py-2 border-2 border-gray-400 rounded-lg bg-white text-sm focus:border-blue-500 focus:outline-none" />
@@ -189,8 +204,9 @@ export default function LogbuchForm({ kuppel, currentUserBeo, editEntry, onSaved setEnde(e.target.value)} + onChange={(e) => setEnde(snapTo15(e.target.value))} required + step={900} className="w-full px-2 py-2 border-2 border-gray-400 rounded-lg bg-white text-sm focus:border-blue-500 focus:outline-none" /> @@ -270,8 +286,8 @@ export default function LogbuchForm({ kuppel, currentUserBeo, editEntry, onSaved )} - {/* Buttons — volle Breite auf Mobile */} -
+ {/* Buttons — zentriert */} +