From 38045a3c5010ae2597bb6ab4755eef09ba1cc458 Mon Sep 17 00:00:00 2001 From: pedro-bento Date: Mon, 5 Oct 2026 18:23:21 +0100 Subject: [PATCH] feat(dashboard): native schedule date picker Replace the dd/mm/yyyy free-text field with a native date input (min=today, dark chrome) and parse YYYY-MM-DD; time input, payload and publish logic unchanged. --- dashboard/src/components/ResultCard.jsx | 36 +++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/dashboard/src/components/ResultCard.jsx b/dashboard/src/components/ResultCard.jsx index dd5eddb..854ae83 100644 --- a/dashboard/src/components/ResultCard.jsx +++ b/dashboard/src/components/ResultCard.jsx @@ -26,17 +26,26 @@ const PlatformIcon = ({ identifier, size = 16 }) => { return ; }; -// DD/MM/YYYY + HH:MM parsed into a local Date, with explicit range checks so -// 31/02/2026 is rejected instead of silently rolling over to March. +// Today as YYYY-MM-DD in the user's own timezone, for the date input's `min`. +// Built from local parts (not toISOString, which would shift the day across the +// UTC boundary for users west of Greenwich). +function todayInputValue() { + const n = new Date(); + return `${n.getFullYear()}-${String(n.getMonth() + 1).padStart(2, '0')}-${String(n.getDate()).padStart(2, '0')}`; +} + +// YYYY-MM-DD (a native date picker's value) + HH:MM parsed into a local Date, +// with explicit range checks so 2026-02-31 is rejected instead of silently +// rolling over to March. function parseSchedule(dateStr, timeStr) { const d = String(dateStr || '').trim(); const t = String(timeStr || '').trim(); - if (!d || !t) return { error: 'Enter both a date (dd/mm/yyyy) and a time.' }; - const dm = d.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/); - if (!dm) return { error: 'Date must be in dd/mm/yyyy format.' }; - const day = Number(dm[1]); + if (!d || !t) return { error: 'Pick a date and a time.' }; + const dm = d.match(/^(\d{4})-(\d{2})-(\d{2})$/); + if (!dm) return { error: 'Date must be in yyyy-mm-dd format.' }; + const year = Number(dm[1]); const month = Number(dm[2]); - const year = Number(dm[3]); + const day = Number(dm[3]); if (month < 1 || month > 12) return { error: 'Month must be between 01 and 12.' }; if (day < 1 || day > 31) return { error: 'Day must be between 01 and 31.' }; const tm = t.match(/^(\d{1,2}):(\d{2})$/); @@ -1048,7 +1057,7 @@ export default function ResultCard({ clip, index, jobId, postizKey, postizUrl, g /> - {/* Scheduling — dd/mm/yyyy + HH:MM */} + {/* Scheduling — native date picker + HH:MM */}
)}