Skip to content

Commit

Permalink
Merge pull request #953 from CruGlobal/MPDX-7930-fix-mailing-addresse…
Browse files Browse the repository at this point in the history
…s-style-modals

Mpdx 7930 fix mailing addresses style modals
  • Loading branch information
dr-bizz authored Jun 13, 2024
2 parents ffec90e + f453b30 commit a9d552f
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 434 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ interface EditContactAddressModalProps {
accountListId: string;
address: ContactMailingFragment['addresses']['nodes'][0];
contactId: string;
handleClose: () => void;
handleClose: (deletedAddress: boolean) => void;
}

export const EditContactAddressModal: React.FC<
Expand Down Expand Up @@ -115,7 +115,7 @@ export const EditContactAddressModal: React.FC<
enqueueSnackbar(t('Address updated successfully'), {
variant: 'success',
});
handleClose();
handleClose(false);
};

const deleteContactAddress = async (): Promise<void> => {
Expand Down Expand Up @@ -158,10 +158,11 @@ export const EditContactAddressModal: React.FC<
},
});
}
handleClose();
handleClose(true);
};

const editingDisabled = address.source === 'Siebel';
const editingDisabled =
address.source === 'Siebel' || address.source === 'DataServer';
const { data: emailData } = useDonationServicesEmailQuery({
variables: {
accountListId,
Expand All @@ -171,7 +172,11 @@ export const EditContactAddressModal: React.FC<
});

return (
<Modal isOpen={true} title={t('Edit Address')} handleClose={handleClose}>
<Modal
isOpen={true}
title={t('Edit Address')}
handleClose={() => handleClose(false)}
>
<Formik
initialValues={{
id: address.id,
Expand Down Expand Up @@ -213,29 +218,43 @@ export const EditContactAddressModal: React.FC<
<ContactEditContainer>
{editingDisabled && (
<ContactInputWrapper>
<Alert severity="info">
<AlertTitle sx={{ fontWeight: 'bold' }}>
{t('This address is provided by Donation Services')}
</AlertTitle>
<p>
{t(
'The address that syncs with Donation Services cannot be edited here. Please email Donation Services with the updated address, or you can create a new address and select it as your primary mailing address.',
{address.source === 'Siebel' && (
<Alert severity="info">
<AlertTitle sx={{ fontWeight: 'bold' }}>
{t('This address is provided by Donation Services')}
</AlertTitle>
<p>
{t(
'The address that syncs with Donation Services cannot be edited here. Please email Donation Services with the updated address, or you can create a new address and select it as your primary mailing address.',
)}
</p>
{emailData && (
<p>
<Link
href={`mailto:[email protected]?subject=Donor+address+change&body=${encodeURIComponent(
generateEmailBody(emailData, address),
)}`}
underline="hover"
sx={{ fontWeight: 'bold' }}
>
{t('Email Donation Services here')}
</Link>
</p>
)}
</p>
{emailData && (
</Alert>
)}
{address.source === 'DataServer' && (
<Alert severity="info">
<AlertTitle sx={{ fontWeight: 'bold' }}>
{t('This address is provided by your organization.')}
</AlertTitle>
<p>
<Link
href={`mailto:[email protected]?subject=Donor+address+change&body=${encodeURIComponent(
generateEmailBody(emailData, address),
)}`}
underline="hover"
sx={{ fontWeight: 'bold' }}
>
{t('Email Donation Services here')}
</Link>
{t(
'The address that syncs with your organization’s donations cannot be edited here. Please email your donation department with the updated address, or you can create a new address and select it as your primary mailing address.',
)}
</p>
)}
</Alert>
</Alert>
)}
</ContactInputWrapper>
)}
<ContactInputWrapper>
Expand Down Expand Up @@ -391,8 +410,13 @@ export const EditContactAddressModal: React.FC<
</ContactEditContainer>
</DialogContent>
<DialogActions>
{address && <DeleteButton onClick={deleteContactAddress} />}
<CancelButton onClick={handleClose} disabled={isSubmitting} />
{address && !editingDisabled && (
<DeleteButton onClick={deleteContactAddress} />
)}
<CancelButton
onClick={() => handleClose(false)}
disabled={isSubmitting}
/>
<SubmitButton disabled={!isValid || isSubmitting}>
{(updating || deleting || settingPrimaryAddress) && (
<LoadingIndicator color="primary" size={20} />
Expand Down
Loading

0 comments on commit a9d552f

Please sign in to comment.