Tomi-1997 commented on code in PR #63885:
URL: https://github.com/apache/airflow/pull/63885#discussion_r2980900656
##########
airflow-core/src/airflow/ui/src/components/DateTimeInput.tsx:
##########
@@ -19,43 +19,55 @@
import { Input, type InputProps } from "@chakra-ui/react";
import dayjs from "dayjs";
import tz from "dayjs/plugin/timezone";
-import { forwardRef } from "react";
+import { forwardRef, type ChangeEvent, useState } from "react";
+import { useDebouncedCallback } from "use-debounce";
import { useTimezone } from "src/context/timezone";
import { DEFAULT_DATETIME_FORMAT } from "src/utils/datetimeUtils";
dayjs.extend(tz);
+const debounceDelay = 500;
+
type Props = {
readonly value: string;
} & InputProps;
export const DateTimeInput = forwardRef<HTMLInputElement, Props>(({ onChange,
value, ...rest }, ref) => {
const { selectedTimezone } = useTimezone();
+ const [displayDate, setDisplayDate] = useState(value);
+
+ const onDateChange = (event: ChangeEvent<HTMLInputElement>) => {
+ const valid = dayjs(event.target.value).isValid();
+ // UI Timezone -> Utc -> yyyy-mm-ddThh:mmZ
+ const utc = valid ? dayjs.tz(event.target.value,
selectedTimezone).toISOString() : "";
+ const local =
+ Boolean(utc) && valid ?
dayjs(utc).tz(selectedTimezone).format(DEFAULT_DATETIME_FORMAT) : "";
Review Comment:
agreed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]