From 2810a6503035648e189e3de317afdc29f3018c24 Mon Sep 17 00:00:00 2001 From: aialok Date: Sun, 3 Dec 2023 23:45:40 +0530 Subject: [PATCH] Bug Fixes : On Creating advertisement page get reloaded --- .../AdvertisementRegister.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx index e205d50598..f12dd31d3b 100644 --- a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx +++ b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx @@ -6,6 +6,7 @@ import { useMutation } from '@apollo/client'; import { ADD_ADVERTISEMENT_MUTATION } from 'GraphQl/Mutations/mutations'; import { useTranslation } from 'react-i18next'; import { toast } from 'react-toastify'; +import { ADVERTISEMENTS_GET } from 'GraphQl/Queries/Queries'; import dayjs from 'dayjs'; interface InterfaceAddOnRegisterProps { @@ -31,7 +32,9 @@ function advertisementRegister({ const handleClose = (): void => setShow(false); const handleShow = (): void => setShow(true); - const [create] = useMutation(ADD_ADVERTISEMENT_MUTATION); + const [create] = useMutation(ADD_ADVERTISEMENT_MUTATION, { + refetchQueries: [ADVERTISEMENTS_GET], + }); //getting orgId from URL const currentOrg = window.location.href.split('/id=')[1] + ''; @@ -59,9 +62,15 @@ function advertisementRegister({ if (data) { toast.success('Advertisement created successfully'); - setTimeout(() => { - window.location.reload(); - }, 2000); + setFormState({ + name: '', + link: '', + type: 'BANNER', + startDate: new Date(), + endDate: new Date(), + orgId: currentOrg, + }); + handleClose(); } } catch (error) { console.log('error occured', error);