Skip to content

Commit e915062

Browse files
committed
typescript fixes
1 parent 5efada9 commit e915062

14 files changed

Lines changed: 41 additions & 24 deletions

src/components/Contacts/ContactDetails/ContactDetails.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ export const ContactDetails: React.FC<Props> = ({
5252

5353
const [selectedTabIndex, setSelectedTabIndex] = React.useState(0);
5454

55-
const handleChange = (event: React.ChangeEvent, newIndex: number) => {
55+
const handleChange = (
56+
_event: React.ChangeEvent<Record<string, unknown>>,
57+
newIndex: number,
58+
) => {
5659
setSelectedTabIndex(newIndex);
5760
};
5861

src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactDetailsHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const ContactDetailsHeader: React.FC<Props> = ({
7373
const { t } = useTranslation();
7474

7575
return (
76-
<Box style={{ padding: 24 }}>
76+
<Box style={{ padding: 24, backgroundColor: 'transparent' }}>
7777
<HeaderBar>
7878
<ContactAvatar src={data?.contact?.avatar || ''} />
7979
<HeaderBarContactWrap>

src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactHeaderSection/ContactHeaderAddressSection.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ export const Default = (): ReactElement => {
2020
};
2121

2222
export const Loading = (): ReactElement => {
23-
return <ContactHeaderAddressSection loading={true} contact={null} />;
23+
return <ContactHeaderAddressSection loading={true} contact={undefined} />;
2424
};

src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactHeaderSection/ContactHeaderAddressSection.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ const contact = gqlMock<ContactDetailsHeaderFragment>(
1414
describe('ContactHeaderAddressSection', () => {
1515
it('should show loading state', async () => {
1616
const { queryByText } = render(
17-
<ContactHeaderAddressSection loading={true} contact={null} />,
17+
<ContactHeaderAddressSection loading={true} contact={undefined} />,
1818
);
1919

20-
expect(queryByText(contact.primaryAddress.street)).toBeNull();
20+
expect(queryByText(contact.primaryAddress?.street || '')).toBeNull();
2121
});
2222

2323
it('should render with contact details', async () => {
2424
const { queryByText } = render(
2525
<ContactHeaderAddressSection loading={false} contact={contact} />,
2626
);
2727

28-
expect(queryByText(contact.greeting)).toBeInTheDocument();
29-
expect(queryByText(contact.primaryAddress.street)).toBeInTheDocument();
28+
expect(queryByText(contact.greeting || '')).toBeInTheDocument();
29+
expect(
30+
queryByText(contact.primaryAddress?.street || ''),
31+
).toBeInTheDocument();
3032
});
3133
});

src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactHeaderSection/ContactHeaderAddressSection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ export const ContactHeaderAddressSection = ({
4040
<TextSkeleton variant="text" />
4141
</ContactHeaderSection>
4242
);
43-
} else if (contact) {
43+
} else if (contact && contact.primaryAddress) {
4444
const {
4545
greeting,
46-
primaryAddress: { street, city, state, postalCode } = {},
46+
primaryAddress: { street, city, state, postalCode },
4747
} = contact;
4848

4949
if (!!greeting && !!street && !!city && !!state && !!postalCode) {

src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactHeaderSection/ContactHeaderEmailSection.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ export const Default = (): ReactElement => {
2020
};
2121

2222
export const Loading = (): ReactElement => {
23-
return <ContactHeaderEmailSection loading={true} contact={null} />;
23+
return <ContactHeaderEmailSection loading={true} contact={undefined} />;
2424
};

src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactHeaderSection/ContactHeaderEmailSection.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ const contact = gqlMock<ContactDetailsHeaderFragment>(
1414
describe('ContactHeaderEmailSection', () => {
1515
it('should show loading state', async () => {
1616
const { queryByText } = render(
17-
<ContactHeaderEmailSection loading={true} contact={null} />,
17+
<ContactHeaderEmailSection loading={true} contact={undefined} />,
1818
);
1919

2020
expect(
21-
queryByText(contact.primaryPerson.primaryEmailAddress.email),
21+
queryByText(contact.primaryPerson?.primaryEmailAddress?.email || ''),
2222
).toBeNull();
2323
});
2424

@@ -28,7 +28,7 @@ describe('ContactHeaderEmailSection', () => {
2828
);
2929

3030
expect(
31-
queryByText(contact.primaryPerson.primaryEmailAddress.email),
31+
queryByText(contact.primaryPerson?.primaryEmailAddress?.email || ''),
3232
).toBeInTheDocument();
3333
});
3434
});

src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactHeaderSection/ContactHeaderEmailSection.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,15 @@ export const ContactHeaderEmailSection = ({
3535
<TextSkeleton variant="text" />
3636
</ContactHeaderSection>
3737
);
38-
} else if (contact) {
38+
} else if (
39+
contact &&
40+
contact.primaryPerson &&
41+
contact.primaryPerson.primaryEmailAddress
42+
) {
3943
const {
40-
primaryPerson: { primaryEmailAddress: { email } = {} } = {},
44+
primaryPerson: {
45+
primaryEmailAddress: { email },
46+
},
4147
} = contact;
4248

4349
if (!!email) {

src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactHeaderSection/ContactHeaderPhoneSection.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ export const Default = (): ReactElement => {
2020
};
2121

2222
export const Loading = (): ReactElement => {
23-
return <ContactHeaderPhoneSection loading={true} contact={null} />;
23+
return <ContactHeaderPhoneSection loading={true} contact={undefined} />;
2424
};

src/components/Contacts/ContactDetails/ContactDetailsHeader/ContactHeaderSection/ContactHeaderPhoneSection.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ const contact = gqlMock<ContactDetailsHeaderFragment>(
1414
describe('ContactHeaderPhoneSection', () => {
1515
it('should show loading state', async () => {
1616
const { queryByText } = render(
17-
<ContactHeaderPhoneSection loading={true} contact={null} />,
17+
<ContactHeaderPhoneSection loading={true} contact={undefined} />,
1818
);
1919

2020
expect(
21-
queryByText(contact.primaryPerson.primaryPhoneNumber.number),
21+
queryByText(contact.primaryPerson?.primaryPhoneNumber?.number || ''),
2222
).toBeNull();
2323
});
2424

@@ -28,7 +28,7 @@ describe('ContactHeaderPhoneSection', () => {
2828
);
2929

3030
expect(
31-
queryByText(contact.primaryPerson.primaryPhoneNumber.number),
31+
queryByText(contact.primaryPerson?.primaryPhoneNumber?.number || ''),
3232
).toBeInTheDocument();
3333
});
3434
});

0 commit comments

Comments
 (0)