Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fixes : On Creating advertisement page get reloaded #1118

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add tests for these lines.

name: '',
link: '',
type: 'BANNER',
startDate: new Date(),
endDate: new Date(),
orgId: currentOrg,
});
handleClose();
}
} catch (error) {
console.log('error occured', error);
Expand Down
Loading