diff --git a/src/components/Forms/Formik/FormikDurationPicker.tsx b/src/components/Forms/Formik/FormikDurationPicker.tsx index 702b3757c..88390c2c8 100644 --- a/src/components/Forms/Formik/FormikDurationPicker.tsx +++ b/src/components/Forms/Formik/FormikDurationPicker.tsx @@ -61,7 +61,6 @@ export default function FormikDurationPicker({ value={value} placeholder={placeholder} onChange={(value) => { - console.log(value, "value"); if (value.type === "absolute") { setFieldValue(from, value.from); setFieldValue(to, value.to); diff --git a/src/components/Notifications/SilenceNotificationForm/NotificationSilenceForm.tsx b/src/components/Notifications/SilenceNotificationForm/NotificationSilenceForm.tsx index a8fca2f30..bdd31fcaf 100644 --- a/src/components/Notifications/SilenceNotificationForm/NotificationSilenceForm.tsx +++ b/src/components/Notifications/SilenceNotificationForm/NotificationSilenceForm.tsx @@ -13,6 +13,7 @@ import FormikTextArea from "@flanksource-ui/components/Forms/Formik/FormikTextAr import FormikNotificationResourceField from "@flanksource-ui/components/Notifications/SilenceNotificationForm/FormikNotificationField"; import { toastError } from "@flanksource-ui/components/Toast/toast"; import { Button } from "@flanksource-ui/ui/Buttons/Button"; +import { parseDateMath } from "@flanksource-ui/ui/Dates/TimeRangePicker/parseDateMath"; import { useMutation } from "@tanstack/react-query"; import { AxiosError } from "axios"; import { Form, Formik } from "formik"; @@ -93,8 +94,21 @@ export default function NotificationSilenceForm({ > initialValues={initialValues} onSubmit={(v) => { + // Before submitting, we need to parse the date math expressions, if + // any are present in the from and until fields. + const { from, until } = v; + const fromTime = from?.includes("now") + ? parseDateMath(from, false) + : from; + + const untilTime = until?.includes("now") + ? parseDateMath(until, false) + : until; + return mutate({ - ...v + ...v, + from: fromTime, + until: untilTime } as SilenceNotificationRequest); }} > diff --git a/src/components/Notifications/SilenceNotificationsList.tsx b/src/components/Notifications/SilenceNotificationsList.tsx index 35a64836c..369b7a995 100644 --- a/src/components/Notifications/SilenceNotificationsList.tsx +++ b/src/components/Notifications/SilenceNotificationsList.tsx @@ -235,7 +235,7 @@ export default function SilenceNotificationsList({ const selectedNotificationSilenceId = searchParams.get("id") ?? undefined; - const { data: selectedNotificationSilence } = useQuery({ + const { data: selectedNotificationSilence, refetch } = useQuery({ queryKey: ["notification_silences", selectedNotificationSilenceId], enabled: !!selectedNotificationSilenceId, queryFn: async () => @@ -264,9 +264,11 @@ export default function SilenceNotificationsList({ searchParams.delete("id"); setSearchParams(searchParams); refresh(); + refetch(); }} onClose={() => { searchParams.delete("id"); + refetch(); setSearchParams(searchParams); }} data={selectedNotificationSilence}