Your favorite shift management application!
feat(ui): pick the date when adding a shift manually (#228)
panteLd37a5d178b92
diff --git a/components/shift-form-fields.tsx b/components/shift-form-fields.tsxindex cccaab3..cffeef0 100644--- a/components/shift-form-fields.tsx+++ b/components/shift-form-fields.tsx@@ -68,19 +68,16 @@ export function ShiftFormFields({return (<div className="flex flex-col gap-3 lg:gap-4">- {/* Creating uses the day shown in the header; editing may move the shift */}- {isEditing && (- <Field label={t("shift.date")} htmlFor="date">- <Input- id="date"- type="date"- value={formData.date}- onChange={(e) => onFormDataChange({ ...formData, date: e.target.value })}- disabled={readOnly}- className={cn(inputClass, "font-mono")}- />- </Field>- )}+ <Field label={t("shift.date")} htmlFor="date">+ <Input+ id="date"+ type="date"+ value={formData.date}+ onChange={(e) => onFormDataChange({ ...formData, date: e.target.value })}+ disabled={readOnly}+ className={cn(inputClass, "font-mono")}+ />+ </Field><div className="flex flex-col gap-2.5 lg:gap-3"><div className="flex gap-2.5">diff --git a/components/shift-sheet.tsx b/components/shift-sheet.tsxindex e8683db..c592daf 100644--- a/components/shift-sheet.tsx+++ b/components/shift-sheet.tsx@@ -143,7 +143,9 @@ export function ShiftSheet({}// For new shifts, check if user has entered any data+ const defaultDate = formatDateToLocal(selectedDate ?? new Date());return (+ formData.date !== defaultDate ||formData.title.trim() !== "" ||formData.notes?.trim() !== "" ||saveAsPreset ||@@ -203,7 +205,8 @@ export function ShiftSheet({(definition) => !validateFieldValue(definition, formData.customFields?.[definition.key]).ok);- const dateLabel = /^\d{4}-\d{2}-\d{2}$/.test(formData.date)+ const hasValidDate = /^\d{4}-\d{2}-\d{2}$/.test(formData.date);+ const dateLabel = hasValidDate? formatLongDate(parseLocalDate(formData.date), locale, { year: true }): undefined;@@ -219,6 +222,7 @@ export function ShiftSheet({isSaving={isSaving}saveDisabled={!formData.title.trim() ||+ !hasValidDate ||(shift && !hasChanges()) ||(!formData.isAllDay && !!validateTimeRanges(toTimeRanges(formData))) ||missingRequiredCustomField