From 16839eb7d3ae504dac3cd77d6ef97c43ac1c5ff4 Mon Sep 17 00:00:00 2001 From: Palash Gupta Date: Tue, 28 Nov 2023 13:44:25 +0530 Subject: [PATCH] fix: updated the form value on mount (#4076) * fix: updated the form value on mount * fix: isLoading is replaced isFetching --- frontend/src/container/EditAlertChannels/index.tsx | 8 +++++++- frontend/src/pages/ChannelsEdit/index.tsx | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/container/EditAlertChannels/index.tsx b/frontend/src/container/EditAlertChannels/index.tsx index ca8bc96f7f..58401bb48e 100644 --- a/frontend/src/container/EditAlertChannels/index.tsx +++ b/frontend/src/container/EditAlertChannels/index.tsx @@ -22,7 +22,7 @@ import { import FormAlertChannels from 'container/FormAlertChannels'; import { useNotifications } from 'hooks/useNotifications'; import history from 'lib/history'; -import { useCallback, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useParams } from 'react-router-dom'; @@ -57,6 +57,12 @@ function EditAlertChannels({ setType(value as ChannelType); }, []); + useEffect(() => { + formInstance.setFieldsValue({ + ...initialValue, + }); + }, [formInstance, initialValue]); + const prepareSlackRequest = useCallback( () => ({ api_url: selectedConfig?.api_url || '', diff --git a/frontend/src/pages/ChannelsEdit/index.tsx b/frontend/src/pages/ChannelsEdit/index.tsx index 9a2c10b4f5..8a578c06e0 100644 --- a/frontend/src/pages/ChannelsEdit/index.tsx +++ b/frontend/src/pages/ChannelsEdit/index.tsx @@ -18,7 +18,7 @@ function ChannelsEdit(): JSX.Element { const { id } = useParams(); const { t } = useTranslation(); - const { isLoading, isError, data } = useQuery(['getChannel', id], { + const { isFetching, isError, data } = useQuery(['getChannel', id], { queryFn: () => get({ id, @@ -29,7 +29,7 @@ function ChannelsEdit(): JSX.Element { return {data?.error || t('something_went_wrong')}; } - if (isLoading || !data?.payload) { + if (isFetching || !data?.payload) { return ; }