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 1 commit
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 { 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 @@

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 @@

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
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();

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
Loading