Can create movements from UI

This commit is contained in:
2025-04-21 15:29:00 +02:00
parent 18bed77c7b
commit 09e44da46e
8 changed files with 189 additions and 15 deletions

View File

@ -0,0 +1,28 @@
import { DatePicker } from "@mui/x-date-pickers";
import { dateToTime, timeToDate } from "../../utils/DateUtils";
export function DateInput(p: {
editable?: boolean;
autoFocus?: boolean;
label?: string;
style?: React.CSSProperties;
value: number | undefined;
onValueChange: (v: number | undefined) => void;
}): React.ReactElement {
return (
<DatePicker
autoFocus={p.autoFocus}
readOnly={p.editable === false}
label={p.label}
slotProps={{ textField: { variant: "standard", style: p.style } }}
value={timeToDate(p.value)}
onChange={(v) => {
try {
p.onValueChange(dateToTime(v ?? undefined));
} catch (e) {
console.warn("Failed to parse date!", e);
}
}}
/>
);
}