mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
feat(date): migrate remaining date inputs to DateField
Swap the four DateInput callsites (filter bar, export range, schedule history, onboarding baseline) to DateField so the user's date-order preference paints every date input. Adapt the onChange from a native event to the direct ISO value DateField emits, and add an optional autoComplete prop so the onboarding date-of-birth field keeps its bday autofill hint.
This commit is contained in:
1 parent
8471384d01
commit
0816b3b0c0
5 files changed
+24
-20
No files matched your search
@@ -59,7 +59,7 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { DateInput } from "@/components/ui/date-input";
|
||||
import { DateField } from "@/components/ui/date-field";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { TimesOfDayChips } from "@/components/medications/scheduling/times-of-day-chips";
|
||||
import { apiDelete, apiGet, apiPatch, apiPost } from "@/lib/api/api-fetch";
|
||||
@@ -545,22 +545,22 @@ function EraDialog({
|
||||
<Label htmlFor="zeitplan-history-from">
|
||||
{t("medications.detail.zeitplan.history.fromLabel")}
|
||||
</Label>
|
||||
<DateInput
|
||||
<DateField
|
||||
id="zeitplan-history-from"
|
||||
value={fromDate}
|
||||
onChange={(e) => setFromDate(e.target.value)}
|
||||
data-slot="zeitplan-history-from"
|
||||
onChange={setFromDate}
|
||||
data-testid="zeitplan-history-from"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="zeitplan-history-until">
|
||||
{t("medications.detail.zeitplan.history.untilLabel")}
|
||||
</Label>
|
||||
<DateInput
|
||||
<DateField
|
||||
id="zeitplan-history-until"
|
||||
value={untilDate}
|
||||
onChange={(e) => setUntilDate(e.target.value)}
|
||||
data-slot="zeitplan-history-until"
|
||||
onChange={setUntilDate}
|
||||
data-testid="zeitplan-history-until"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { toast } from "sonner";
|
||||
import { Loader2 } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DateInput } from "@/components/ui/date-input";
|
||||
import { DateField } from "@/components/ui/date-field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
@@ -242,10 +242,10 @@ export function BaselineForm() {
|
||||
<Label htmlFor="ob-baseline-dob">
|
||||
{t("onboarding.baseline.dateOfBirthLabel")}
|
||||
</Label>
|
||||
<DateInput
|
||||
<DateField
|
||||
id="ob-baseline-dob"
|
||||
value={form.dateOfBirth}
|
||||
onChange={(e) => patch("dateOfBirth", e.target.value)}
|
||||
onChange={(value) => patch("dateOfBirth", value)}
|
||||
max={new Date().toISOString().slice(0, 10)}
|
||||
autoComplete="bday"
|
||||
/>
|
||||
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
} from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DateInput } from "@/components/ui/date-input";
|
||||
import { DateField } from "@/components/ui/date-field";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { SettingsCard } from "@/components/settings/settings-card";
|
||||
@@ -181,10 +181,10 @@ function DateRangeFields({
|
||||
<Label htmlFor={`${idPrefix}-since`} className="text-xs">
|
||||
{t("settings.sections.export.filters.since")}
|
||||
</Label>
|
||||
<DateInput
|
||||
<DateField
|
||||
id={`${idPrefix}-since`}
|
||||
value={since}
|
||||
onChange={(e) => setSince(e.target.value)}
|
||||
onChange={setSince}
|
||||
max={until || undefined}
|
||||
/>
|
||||
</div>
|
||||
@@ -192,10 +192,10 @@ function DateRangeFields({
|
||||
<Label htmlFor={`${idPrefix}-until`} className="text-xs">
|
||||
{t("settings.sections.export.filters.until")}
|
||||
</Label>
|
||||
<DateInput
|
||||
<DateField
|
||||
id={`${idPrefix}-until`}
|
||||
value={until}
|
||||
onChange={(e) => setUntil(e.target.value)}
|
||||
onChange={setUntil}
|
||||
min={since || undefined}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -50,6 +50,8 @@ export interface DateFieldProps {
|
||||
onBlur?: () => void;
|
||||
disabled?: boolean;
|
||||
required?: boolean;
|
||||
/** Autofill hint forwarded to the native date input (e.g. "bday"). */
|
||||
autoComplete?: string;
|
||||
/** ISO `yyyy-MM-dd`. */
|
||||
min?: string;
|
||||
/** ISO `yyyy-MM-dd`. */
|
||||
@@ -73,6 +75,7 @@ export const DateField = React.forwardRef<HTMLInputElement, DateFieldProps>(
|
||||
onBlur,
|
||||
disabled,
|
||||
required,
|
||||
autoComplete,
|
||||
min,
|
||||
max,
|
||||
placeholder,
|
||||
@@ -174,6 +177,7 @@ export const DateField = React.forwardRef<HTMLInputElement, DateFieldProps>(
|
||||
defaultValue={value === undefined ? defaultValue : undefined}
|
||||
disabled={disabled}
|
||||
required={required}
|
||||
autoComplete={autoComplete}
|
||||
min={min}
|
||||
max={max}
|
||||
onChange={handleNativeChange}
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as React from "react";
|
||||
import { ListFilter, X } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DateInput } from "@/components/ui/date-input";
|
||||
import { DateField } from "@/components/ui/date-field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
@@ -266,12 +266,12 @@ export function FilterBarDateRange({
|
||||
>
|
||||
{t("dataList.dateFrom")}
|
||||
</Label>
|
||||
<DateInput
|
||||
<DateField
|
||||
id={`${idPrefix}-from`}
|
||||
className="w-44"
|
||||
value={from}
|
||||
max={to || undefined}
|
||||
onChange={(e) => onFromChange(e.target.value)}
|
||||
onChange={onFromChange}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
@@ -281,12 +281,12 @@ export function FilterBarDateRange({
|
||||
>
|
||||
{t("dataList.dateTo")}
|
||||
</Label>
|
||||
<DateInput
|
||||
<DateField
|
||||
id={`${idPrefix}-to`}
|
||||
className="w-44"
|
||||
value={to}
|
||||
min={from || undefined}
|
||||
onChange={(e) => onToChange(e.target.value)}
|
||||
onChange={onToChange}
|
||||
/>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
|
||||
Reference in new issue
Block a user