Skip to content

Commit

Permalink
Merge pull request #978 from CruGlobal/MPDX-7535-fix-newsletter-confirm
Browse files Browse the repository at this point in the history
MPDX-7535 - Fix Send Newsletter: Confirm button
  • Loading branch information
wrandall22 authored Jul 31, 2024
2 parents 3475d73 + a5a2492 commit 1b734b6
Show file tree
Hide file tree
Showing 10 changed files with 435 additions and 145 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const customJestConfig = {
'!**/*.mock.*',
'!**/*.stories.*',
'!**/*.test.*',
'!**/*Mock.ts',
],
testEnvironment: 'jest-environment-jsdom',
snapshotFormat: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TestRouter from '__tests__/util/TestRouter';
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
import { CreateContactAddressMutation } from 'src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/AddAddressModal/CreateContactAddress.generated';
import theme from 'src/theme';
import FixSendNewsletter from './FixMailingAddresses';
import FixMailingAddresses from './FixMailingAddresses';
import {
mockInvalidAddressesResponse,
mpdxSourcedAddress,
Expand Down Expand Up @@ -54,7 +54,7 @@ const Components = ({
mocks={mocks}
cache={cache}
>
<FixSendNewsletter
<FixMailingAddresses
accountListId={accountListId}
setContactFocus={setContactFocus}
/>
Expand All @@ -64,7 +64,7 @@ const Components = ({
</SnackbarProvider>
);

describe('FixSendNewsletter', () => {
describe('FixMailingAddresses', () => {
beforeEach(() => {
setContactFocus.mockClear();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ enum ModalEnum {

const sourceOptions = [appName, 'DataServer'];

const FixSendNewsletter: React.FC<Props> = ({
const FixMailingAddresses: React.FC<Props> = ({
accountListId,
setContactFocus,
}: Props) => {
Expand Down Expand Up @@ -475,4 +475,4 @@ const FixSendNewsletter: React.FC<Props> = ({
);
};

export default FixSendNewsletter;
export default FixMailingAddresses;
4 changes: 2 additions & 2 deletions src/components/Tool/FixSendNewsletter/Contact.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Contact from './Contact';
import {
ContactPrimaryAddressFragment,
ContactPrimaryPersonFragment,
} from './GetInvalidNewsletter.generated';
} from './InvalidNewsletter.generated';

const TestComponent = ({
primaryPerson,
Expand All @@ -21,7 +21,7 @@ const TestComponent = ({
primaryPerson={primaryPerson}
status=""
primaryAddress={primaryAddress}
updateFunction={jest.fn()}
handleSingleConfirm={jest.fn()}
setContactFocus={jest.fn()}
/>
</ThemeProvider>
Expand Down
14 changes: 8 additions & 6 deletions src/components/Tool/FixSendNewsletter/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { StyledInput } from '../StyledInput';
import {
ContactPrimaryAddressFragment,
ContactPrimaryPersonFragment,
} from './GetInvalidNewsletter.generated';
} from './InvalidNewsletter.generated';

const useStyles = makeStyles()(() => ({
left: {
Expand Down Expand Up @@ -85,7 +85,11 @@ interface Props {
status?: string;
primaryAddress?: ContactPrimaryAddressFragment;
source?: string;
updateFunction: (id: string, sendNewsletter: string) => Promise<void>;
handleSingleConfirm: (
id: string,
name: string,
sendNewsletter: string,
) => Promise<void>;
setContactFocus: SetContactFocus;
}

Expand All @@ -95,7 +99,7 @@ const Contact = ({
primaryPerson,
status,
primaryAddress,
updateFunction,
handleSingleConfirm,
setContactFocus,
}: Props): ReactElement => {
const { t } = useTranslation();
Expand All @@ -121,8 +125,6 @@ const Contact = ({
setNewsletter(newNewsletterValue);
}, [primaryAddress]);

//TODO: Add button functionality

const handleChange = (
event:
| React.ChangeEvent<HTMLSelectElement>
Expand Down Expand Up @@ -252,7 +254,7 @@ const Contact = ({
<Box className={classes.buttonTop}>
<Button
variant="contained"
onClick={() => updateFunction(id, newsletter)}
onClick={() => handleSingleConfirm(id, name, newsletter)}
>
<Icon
path={mdiCheckboxMarkedCircle}
Expand Down
82 changes: 0 additions & 82 deletions src/components/Tool/FixSendNewsletter/FindSendNewsletter.test.tsx

This file was deleted.

Loading

0 comments on commit 1b734b6

Please sign in to comment.