Skip to content

Commit

Permalink
REmoving MPDX name and padding/margin
Browse files Browse the repository at this point in the history
Allow for TNT (DataServer) data to be edited in MPDX as it's imported once and not updated in third party software.

Only MPDX, TNT and manually address are now editable

Fixing failing test due to new changes with what source can be edited
  • Loading branch information
dr-bizz committed Jun 17, 2024
1 parent 6041662 commit 7893bf6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const mockContact: ContactMailingFragment = {
historic: true,
street: '123 Cool Street',
primaryMailingAddress: false,
source: 'MPDX',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const LoadingIndicator = styled(CircularProgress)(({ theme }) => ({
margin: theme.spacing(0, 1, 0, 0),
}));

export const editableSources = ['MPDX', 'manual', 'TntImport'];

interface EditContactAddressModalProps {
accountListId: string;
address: ContactMailingFragment['addresses']['nodes'][0];
Expand Down Expand Up @@ -169,8 +171,7 @@ export const EditContactAddressModal: React.FC<
handleClose();
};

const editingDisabled =
address.source === 'Siebel' || address.source === 'DataServer';
const editingDisabled = editableSources.indexOf(address.source) === -1;
const { data: emailData } = useDonationServicesEmailQuery({
variables: {
accountListId,
Expand Down
14 changes: 11 additions & 3 deletions src/components/Tool/FixMailingAddresses/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import clsx from 'clsx';
import { DateTime } from 'luxon';
import { useTranslation } from 'react-i18next';
import { makeStyles } from 'tss-react/mui';
import { editableSources } from 'src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditContactAddressModal/EditContactAddressModal';
import {
AddButton,
AddIcon,
Expand Down Expand Up @@ -105,6 +106,7 @@ interface Props {
name: string;
status: string;
addresses: ContactAddressFragment[];
appName: string;
openEditAddressModal: (address: ContactAddressFragment, id: string) => void;
openNewAddressModal: (address: ContactAddressFragment, id: string) => void;
}
Expand All @@ -114,6 +116,7 @@ const Contact: React.FC<Props> = ({
name,
status,
addresses,
appName,
openEditAddressModal,
openNewAddressModal,
}) => {
Expand Down Expand Up @@ -219,7 +222,11 @@ const Contact: React.FC<Props> = ({
</Box>

<ContactIconContainer aria-label={t('Edit Icon')}>
{address.source === 'MPDX' ? <EditIcon /> : <LockIcon />}
{editableSources.indexOf(address.source) > -1 ? (
<EditIcon />
) : (
<LockIcon />
)}
</ContactIconContainer>
</Box>
</Grid>
Expand All @@ -233,7 +240,9 @@ const Contact: React.FC<Props> = ({
<strong>{t('Source')}: </strong>
</Typography>
</Hidden>
<Typography display="inline">MPDX</Typography>
<Typography display="inline">
{t('{{appName}}', { appName })}
</Typography>
</Box>
</Box>
</Grid>
Expand All @@ -243,7 +252,6 @@ const Contact: React.FC<Props> = ({
justifyContent="flex-start"
className={clsx(
classes.responsiveBorder,
classes.paddingX,
classes.hoverHighlight,
)}
>
Expand Down
19 changes: 12 additions & 7 deletions src/components/Tool/FixMailingAddresses/FixMailingAddresses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ const useStyles = makeStyles()(() => ({
},
}));

const appName = process.env.APP_NAME || 'MPDX';

export const emptyAddress: ContactAddressFragment = {
id: 'new',
source: 'MPDX',
source: appName,
street: '',
region: '',
location: '',
Expand All @@ -114,7 +116,7 @@ enum ModalEnum {
Edit = 'Edit',
}

const sourceOptions = ['MPDX', 'DataServer'];
const sourceOptions = [appName, 'DataServer'];

const FixSendNewsletter: React.FC<Props> = ({ accountListId }: Props) => {
const { classes } = useStyles();
Expand All @@ -123,7 +125,7 @@ const FixSendNewsletter: React.FC<Props> = ({ accountListId }: Props) => {
const [showNewAddressModal, setShowNewAddressModal] = useState(false);
const [selectedAddress, setSelectedAddress] = useState(emptyAddress);
const [selectedContactId, setSelectedContactId] = useState('');
const [defaultSource, setDefaultSource] = useState('MPDX');
const [defaultSource, setDefaultSource] = useState(appName);
const { data, loading } = useInvalidAddressesQuery({
variables: { accountListId },
});
Expand Down Expand Up @@ -218,10 +220,12 @@ const FixSendNewsletter: React.FC<Props> = ({ accountListId }: Props) => {
</Grid>

{loading && !data && (
<CircularProgress
data-testid="loading"
style={{ marginTop: theme.spacing(3) }}
/>
<Box className={classes.outer}>
<CircularProgress
data-testid="loading"
style={{ marginTop: theme.spacing(3) }}
/>
</Box>
)}

{!loading && data && (
Expand Down Expand Up @@ -286,6 +290,7 @@ const FixSendNewsletter: React.FC<Props> = ({ accountListId }: Props) => {
status={contact.status || ''}
key={contact.id}
addresses={contact.addresses.nodes}
appName={appName}
openEditAddressModal={(address, contactId) =>
handleModalOpen(ModalEnum.Edit, address, contactId)
}
Expand Down

0 comments on commit 7893bf6

Please sign in to comment.