Skip to content

Commit

Permalink
Bug Fixes : On Creating advertisement page get reloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
aialok committed Dec 3, 2023
1 parent dec5042 commit 2810a65
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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] + '';
Expand Down Expand Up @@ -59,9 +62,15 @@ function advertisementRegister({

if (data) {
toast.success('Advertisement created successfully');
setTimeout(() => {
window.location.reload();
}, 2000);
setFormState({

Check warning on line 65 in src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx#L65

Added line #L65 was not covered by tests
name: '',
link: '',
type: 'BANNER',
startDate: new Date(),
endDate: new Date(),
orgId: currentOrg,
});
handleClose();

Check warning on line 73 in src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx#L73

Added line #L73 was not covered by tests
}
} catch (error) {
console.log('error occured', error);
Expand Down

0 comments on commit 2810a65

Please sign in to comment.