Skip to content

Commit

Permalink
misc. bug fixing and error naming mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
Collin Pastika committed Jun 17, 2024
1 parent 6794ce4 commit 30c396c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ describe('FixEmailAddresses-Contact', () => {
name={testData.name}
key={testData.name}
personId={testData.id}
emails={testData.emails}
email={testData.emails.map((email) => ({
...email,
isValid: false,
personId: testData.id,
isPrimary: email.primary,
}))}
handleChange={handleChangeMock}
handleDelete={handleDeleteModalOpenMock}
handleAdd={handleAddMock}
Expand Down Expand Up @@ -74,7 +79,12 @@ describe('FixEmailAddresses-Contact', () => {
name={testData.name}
key={testData.name}
personId={testData.id}
emails={testData.emails}
email={testData.emails.map((email) => ({
...email,
isValid: false,
personId: testData.id,
isPrimary: email.primary,
}))}
handleChange={handleChangeMock}
handleDelete={handleDeleteModalOpenMock}
handleAdd={handleAddMock}
Expand Down
14 changes: 8 additions & 6 deletions src/components/Tool/FixEmailAddresses/FixEmailAddressPerson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { useLocale } from 'src/hooks/useLocale';
import { dateFormatShort } from 'src/lib/intlFormat';
import theme from '../../../theme';
import { ConfirmButtonIcon } from '../ConfirmButtonIcon';
import { EmailAddressData } from './FixEmailAddresses';

const PersonCard = styled(Box)(({ theme }) => ({
[theme.breakpoints.up('md')]: {
Expand Down Expand Up @@ -109,10 +108,11 @@ interface FixEmailAddressPersonProps {

interface EmailAddressData {
email: string;
isValid: boolean;
isPrimary: boolean;
updatedAt: string;
source: string;
personId: string; // Add the 'personId' property
isValid: boolean;
}

// const onSubmit = (values: EmailAddressData, validationSchema) => {
Expand All @@ -122,6 +122,7 @@ interface EmailAddressData {
const EmailValidationForm = ({
email: initialEmail = {
email: '',
isPrimary: false,
updatedAt: '',
source: '',
personId: '',
Expand All @@ -138,13 +139,14 @@ const EmailValidationForm = ({
<Formik
initialValues={{
email: initialEmail.email,
isPrimary: initialEmail.isPrimary,
updatedAt: '',
source: '',
personId: '',
isValid: false,
}}
validationSchema={validationSchema}
onSubmit={onSubmit}
// onSubmit={onSubmit}
>
{({ isValid }) => (
<Form>
Expand Down Expand Up @@ -177,7 +179,7 @@ const EmailValidationForm = ({

export const FixEmailAddressPerson: React.FC<FixEmailAddressPersonProps> = ({
name,
emails,
email,
personId,
handleChange,
handleDelete,
Expand Down Expand Up @@ -244,7 +246,7 @@ export const FixEmailAddressPerson: React.FC<FixEmailAddressPersonProps> = ({
</Box>
</ColumnHeaderWrapper>
</Hidden>
{emails.map((email, index) => (
{email.map((email, index) => (
<Fragment key={index}>
<RowWrapper item xs={12} sm={6}>
<Box
Expand All @@ -266,7 +268,7 @@ export const FixEmailAddressPerson: React.FC<FixEmailAddressPersonProps> = ({
</Typography>
</Box>
<Typography>
{email.primary ? (
{email.isPrimary ? (
<Box
data-testid={`starIcon-${personId}-${index}`}
>
Expand Down
9 changes: 8 additions & 1 deletion src/components/Tool/FixEmailAddresses/FixEmailAddresses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,14 @@ export const FixEmailAddresses: React.FC<FixEmailAddressesProps> = ({
name={`${person.firstName} ${person.lastName}`}
key={person.id}
personId={person.id}
emails={dataState[person.id]?.emailAddresses || []}
email={
dataState[person.id]?.emailAddresses.map((email) => ({
...email,
isValid: false,
personId: person.id,
isPrimary: email.primary,
})) || []
}
toDelete={dataState[person.id]?.toDelete}
handleChange={handleChange}
handleDelete={handleDeleteModalOpen}
Expand Down

0 comments on commit 30c396c

Please sign in to comment.