jscheffl commented on code in PR #45790:
URL: https://github.com/apache/airflow/pull/45790#discussion_r1929593707


##########
airflow/ui/src/components/FlexibleForm/FieldDateTime.tsx:
##########
@@ -19,13 +19,29 @@
 import { Input, type InputProps } from "@chakra-ui/react";
 
 import type { FlexibleFormElementProps } from ".";
+import { paramPlaceholder, useParamStore } from "../TriggerDag/useParamStore";
 
-export const FieldDateTime = ({ name, param, ...rest }: 
FlexibleFormElementProps & InputProps) => (
-  <Input
-    defaultValue={typeof param.value === "string" ? param.value : undefined}
-    id={`element_${name}`}
-    name={`element_${name}`}
-    size="sm"
-    type={rest.type}
-  />
-);
+export const FieldDateTime = ({ name, ...rest }: FlexibleFormElementProps & 
InputProps) => {
+  const { paramsDict, setParamsDict } = useParamStore();
+  const param = paramsDict[name] ?? paramPlaceholder;
+  const handleChange = (value: string) => {
+    if (paramsDict[name]) {
+      // "undefined" values are removed from params, so we set it to null to 
avoid falling back to DAG defaults.
+      // eslint-disable-next-line unicorn/no-null
+      paramsDict[name].value = value === "" ? null : value.slice(0, 16);

Review Comment:
   We need to suffix a bit of text if it is a datetime field to make it ISO 
date parable in JSON
   ```suggestion
         if (rest.type === "datetime-local") {
           // "undefined" values are removed from params, so we set it to null 
to avoid falling back to DAG defaults.
           // eslint-disable-next-line unicorn/no-null
           paramsDict[name].value = value === "" ? null : `${value}:00+00:00`; 
// Need to suffix to make it UTC like
         } else {
           // "undefined" values are removed from params, so we set it to null 
to avoid falling back to DAG defaults.
           // eslint-disable-next-line unicorn/no-null
           paramsDict[name].value = value === "" ? null : value;
         }
   ```



-- 
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]

Reply via email to