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

Mpdx 7930 fix mailing addresses style modals #953

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
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 @@ -68,7 +68,7 @@
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 @@
enqueueSnackbar(t('Address updated successfully'), {
variant: 'success',
});
handleClose();
handleClose(false);
};

const deleteContactAddress = async (): Promise<void> => {
Expand Down Expand Up @@ -158,10 +158,11 @@
},
});
}
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 @@
});

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

Check warning on line 247 in src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditContactAddressModal/EditContactAddressModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditContactAddressModal/EditContactAddressModal.tsx#L247

Added line #L247 was not covered by tests
<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 @@
</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
Loading