Skip to content

Commit

Permalink
fixup! 4. Contact Row - Add/Edit/Delete pledge
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz committed Aug 28, 2024
1 parent c210efd commit 26cdd9d
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useContext } from 'react';
import {
Box,
CircularProgress,
Expand Down Expand Up @@ -36,18 +36,15 @@ export const DeletePledgeModal: React.FC<DeletePledgeModalProps> = ({
}) => {
const { t } = useTranslation();
const { enqueueSnackbar } = useSnackbar();
const [deleteAccountListPledge] = useDeleteAccountListPledgeMutation();
const [mutating, setMutating] = React.useState(false);
const { contactsQueryResult } = React.useContext(
AppealsContext,
) as AppealsType;
const [deleteAccountListPledge, { loading }] =
useDeleteAccountListPledgeMutation();
const { contactsQueryResult } = useContext(AppealsContext) as AppealsType;

const handleConfirm = async () => {
setMutating(true);
await deleteAccountListPledge({
variables: {
input: {
id: pledge.id ?? '',
id: pledge.id,
},
},
update: () => {
Expand All @@ -65,7 +62,6 @@ export const DeletePledgeModal: React.FC<DeletePledgeModalProps> = ({
});
},
});
setMutating(false);
};

return (
Expand All @@ -75,7 +71,7 @@ export const DeletePledgeModal: React.FC<DeletePledgeModalProps> = ({
handleClose={handleClose}
>
<DialogContent dividers>
{mutating ? (
{loading ? (
<Box style={{ textAlign: 'center' }}>
<LoadingIndicator color="primary" size={50} />
</Box>
Expand All @@ -86,10 +82,10 @@ export const DeletePledgeModal: React.FC<DeletePledgeModalProps> = ({
)}
</DialogContent>
<DialogActions>
<CancelButton onClick={handleClose} disabled={mutating}>
<CancelButton onClick={handleClose} disabled={loading}>
{t('No')}
</CancelButton>
<SubmitButton type="button" onClick={handleConfirm} disabled={mutating}>
<SubmitButton type="button" onClick={handleConfirm} disabled={loading}>
{t('Yes')}
</SubmitButton>
</DialogActions>
Expand Down

0 comments on commit 26cdd9d

Please sign in to comment.