Skip to content

Commit

Permalink
Fixed the Toast message and changed the routing for DeleteOrg page.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitSharma512 committed Dec 2, 2023
1 parent da35be1 commit 2a1b05f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/DeleteOrg/DeleteOrg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { DELETE_ORGANIZATION_MUTATION } from 'GraphQl/Mutations/mutations';
import { REMOVE_SAMPLE_ORGANIZATION_MUTATION } from 'GraphQl/Mutations/mutations';
import { IS_SAMPLE_ORGANIZATION_QUERY } from 'GraphQl/Queries/Queries';
import styles from './DeleteOrg.module.css';
import { useHistory } from 'react-router-dom';

function deleteOrg(): JSX.Element {
const { t } = useTranslation('translation', {
Expand All @@ -29,24 +30,26 @@ function deleteOrg(): JSX.Element {
},
});

const history = useHistory();

const deleteOrg = async (): Promise<void> => {
if (data && data.isSampleOrganization) {
removeSampleOrganization()
.then(() => {
toast.success('Successfully deleted sample Organization');
})
.catch((error) => {
toast.error(error.message);
});
window.location.replace('/orglist');
try {
await removeSampleOrganization();
toast.success('Successfully deleted sample Organization');
history.push('/orglist');

Check warning on line 40 in src/components/DeleteOrg/DeleteOrg.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DeleteOrg/DeleteOrg.tsx#L37-L40

Added lines #L37 - L40 were not covered by tests
} catch (error: any) {
toast.error(error.message);

Check warning on line 42 in src/components/DeleteOrg/DeleteOrg.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DeleteOrg/DeleteOrg.tsx#L42

Added line #L42 was not covered by tests
}
} else {
try {
await del({
variables: {
id: currentUrl,
},
});
window.location.replace('/orglist');
toast.success('Successfully deleted Organization');
history.push('/orglist');

Check warning on line 52 in src/components/DeleteOrg/DeleteOrg.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/DeleteOrg/DeleteOrg.tsx#L51-L52

Added lines #L51 - L52 were not covered by tests
} catch (error: any) {
errorHandler(t, error);
}
Expand Down

0 comments on commit 2a1b05f

Please sign in to comment.