1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-23 15:14:23 +00:00
festa/components/editable/EditableDateTimeLocal.tsx

27 lines
953 B
TypeScript
Raw Normal View History

2022-06-08 17:14:00 +00:00
import { HTMLProps } from "react";
2022-06-10 03:21:02 +00:00
import { toDatetimeLocal } from "../../utils/dateFields";
2022-06-09 21:55:49 +00:00
import { FestaMoment } from "../extensions/FestaMoment";
2022-06-10 15:18:36 +00:00
import { BaseEditable } from "./BaseEditable";
2022-06-08 17:14:00 +00:00
2022-06-10 03:21:02 +00:00
export type EditableDateTimeLocalProps = Omit<HTMLProps<HTMLInputElement>, "value" | "max" | "min"> & { value: Date | null, max?: Date, min?: Date }
export function EditableDateTimeLocal(props: EditableDateTimeLocalProps) {
2022-06-08 17:14:00 +00:00
return (
2022-06-10 15:18:36 +00:00
<BaseEditable
2022-06-08 17:14:00 +00:00
editing={
2022-06-10 03:21:02 +00:00
<input
type="datetime-local"
{...props}
value={props.value ? toDatetimeLocal(props.value) : undefined}
min={props.min ? toDatetimeLocal(props.min) : undefined}
max={props.max ? toDatetimeLocal(props.max) : undefined}
/>
2022-06-08 17:14:00 +00:00
}
preview={
2022-06-09 21:55:49 +00:00
<FestaMoment date={props.value} />
2022-06-08 17:14:00 +00:00
}
/>
)
}