aboutsummaryrefslogtreecommitdiff
path: root/packages/exchange-backoffice-ui/src/handlers/InputDate.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/exchange-backoffice-ui/src/handlers/InputDate.tsx')
-rw-r--r--packages/exchange-backoffice-ui/src/handlers/InputDate.tsx12
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/exchange-backoffice-ui/src/handlers/InputDate.tsx b/packages/exchange-backoffice-ui/src/handlers/InputDate.tsx
index 00dd59996..e834b6cdb 100644
--- a/packages/exchange-backoffice-ui/src/handlers/InputDate.tsx
+++ b/packages/exchange-backoffice-ui/src/handlers/InputDate.tsx
@@ -4,24 +4,26 @@ import { CalendarIcon } from "@heroicons/react/24/outline";
import { VNode, h } from "preact";
import { format, parse } from "date-fns";
-export function InputDate(
- props: { pattern?: string } & UIFormProps<AbsoluteTime>,
+export function InputDate<T extends object, K extends keyof T>(
+ props: { pattern?: string } & UIFormProps<T, K>,
): VNode {
const pattern = props.pattern ?? "dd/MM/yyyy";
return (
- <InputLine<AbsoluteTime>
+ <InputLine<T, K>
type="text"
after={{
type: "icon",
icon: <CalendarIcon class="h-6 w-6" />,
}}
converter={{
- fromStringUI: (v) => {
+ //@ts-ignore
+ fromStringUI: (v): AbsoluteTime => {
if (!v) return { t_ms: "never" };
const t_ms = parse(v, pattern, Date.now()).getTime();
return { t_ms };
},
- toStringUI: (v) => {
+ //@ts-ignore
+ toStringUI: (v: AbsoluteTime) => {
return !v || !v.t_ms
? ""
: v.t_ms === "never"