From 8d9b6630a576b7e8331eb5431cd90d02733b4917 Mon Sep 17 00:00:00 2001 From: zyachel Date: Sun, 21 May 2023 14:44:54 +0530 Subject: [PATCH] fix(name): fix a couple of crashes in name and title route --- src/components/name/Basic.tsx | 2 +- src/components/name/Credits.tsx | 76 ++++++------------- src/components/name/DidYouKnow.tsx | 76 +++++++++---------- src/components/name/Info.tsx | 48 +++++------- src/interfaces/misc/rawName.ts | 18 ++--- src/interfaces/misc/rawTitle.ts | 2 +- .../components/name/credits.module.scss | 6 -- .../components/name/did-you-know.module.scss | 2 +- src/utils/cleaners/name.ts | 4 +- src/utils/cleaners/title.ts | 2 +- 10 files changed, 95 insertions(+), 141 deletions(-) diff --git a/src/components/name/Basic.tsx b/src/components/name/Basic.tsx index b5ae294..81411f6 100644 --- a/src/components/name/Basic.tsx +++ b/src/components/name/Basic.tsx @@ -10,7 +10,7 @@ type Props = { const Basic = ({ data, className }: Props) => { return ( - +
{data.ranking && (

diff --git a/src/components/name/Credits.tsx b/src/components/name/Credits.tsx index ea93e49..9b20c81 100644 --- a/src/components/name/Credits.tsx +++ b/src/components/name/Credits.tsx @@ -13,59 +13,29 @@ const Credits = ({ className, data }: Props) => { return (

Credits

-
-

Released

- {data.released.map( - (item, i) => - !!item.total && ( -
- - {item.category.text} ({item.total}) - -
    - {item.titles.map(title => ( - - ))} -
-
- ) - )} -
-
-

Unreleased

- {data.unreleased.map( - (item, i) => - !!item.total && ( -
- - {item.category.text} ({item.total}) - -
    - {item.titles.map(title => ( - -

    {title.productionStatus}

    -
    - ))} -
-
- ) - )} -
+ {data.released.map( + (item, i) => + !!item.total && ( +
+ + {item.category.text} ({item.total}) + +
    + {item.titles.map(title => ( + + ))} +
+
+ ) + )}
); }; diff --git a/src/components/name/DidYouKnow.tsx b/src/components/name/DidYouKnow.tsx index 1578cd0..bf65c60 100644 --- a/src/components/name/DidYouKnow.tsx +++ b/src/components/name/DidYouKnow.tsx @@ -7,46 +7,44 @@ type Props = { }; const DidYouKnow = ({ data }: Props) => ( -
+

Did you know

-
- {!!data.trivia?.total && ( -
-

Trivia

-
-
- )} - {!!data.quotes?.total && ( -
-

Quotes

-
-
- )} - {!!data.trademark?.total && ( -
-

Trademark

-
-
- )} - {!!data.nicknames.length && ( -
-

Nicknames

-

{data.nicknames.join(', ')}

-
- )} - {!!data.salary?.total && ( -
-

Salary

-

- {data.salary.value} in - - {data.salary.title.text} - - ({data.salary.title.year}) -

-
- )} -
+ {!!data.trivia?.total && ( +
+

Trivia

+
+
+ )} + {!!data.quotes?.total && ( +
+

Quotes

+
+
+ )} + {!!data.trademark?.total && ( +
+

Trademark

+
+
+ )} + {!!data.nicknames.length && ( +
+

Nicknames

+

{data.nicknames.join(', ')}

+
+ )} + {!!data.salary?.total && ( +
+

Salary

+

+ {data.salary.value} in + + {data.salary.title.text} + + ({data.salary.title.year}) +

+
+ )}
); diff --git a/src/components/name/Info.tsx b/src/components/name/Info.tsx index 8b9b02e..bfc526c 100644 --- a/src/components/name/Info.tsx +++ b/src/components/name/Info.tsx @@ -82,13 +82,15 @@ const PersonalDetails = ({ info, accolades }: Props) => {

Died: {info.death.date} - - {' '} - in{' '} - - {info.death.location} - - + {info.death.location && ( + + {' '} + in{' '} + + {info.death.location} + + + )}

)} {info.death.cause && ( @@ -102,11 +104,9 @@ const PersonalDetails = ({ info, accolades }: Props) => { Spouses: {info.spouses.map((spouse, i) => ( - <> - {!!i && ', '} - {renderPersonNameWithLink(spouse)} {spouse.range} ( - {spouse.attributes.join(', ')}) - + {!!i && ', '} + {renderPersonNameWithLink(spouse)} {spouse.range} + {spouse.attributes && ' (' + spouse.attributes.join(', ') + ')'} ))}

@@ -116,10 +116,8 @@ const PersonalDetails = ({ info, accolades }: Props) => { Children: {info.children.map((child, i) => ( - <> - {!!i && ', '} - {renderPersonNameWithLink(child)} - + {!!i && ', '} + {renderPersonNameWithLink(child)} ))}

@@ -129,10 +127,8 @@ const PersonalDetails = ({ info, accolades }: Props) => { Parents: {info.parents.map((parent, i) => ( - <> - {!!i && ', '} - {renderPersonNameWithLink(parent)} - + {!!i && ', '} + {renderPersonNameWithLink(parent)} ))}

@@ -142,10 +138,8 @@ const PersonalDetails = ({ info, accolades }: Props) => { Relatives: {info.relatives.map((relative, i) => ( - <> - {!!i && ', '} - {renderPersonNameWithLink(relative)} ({relative.relation}) - + {!!i && ', '} + {renderPersonNameWithLink(relative)} ({relative.relation}) ))}

@@ -155,10 +149,8 @@ const PersonalDetails = ({ info, accolades }: Props) => { Other Works: {info.otherWorks.map((work, i) => ( - <> - {!!i && ', '} - - + {!!i && ', '} + ))}

diff --git a/src/interfaces/misc/rawName.ts b/src/interfaces/misc/rawName.ts index c3c5c36..36e0197 100644 --- a/src/interfaces/misc/rawName.ts +++ b/src/interfaces/misc/rawName.ts @@ -34,7 +34,7 @@ export default interface Name { total: number; };*/ - primaryImage: { + primaryImage?: { id: string; url: string; height: number; @@ -687,13 +687,13 @@ export default interface Name { }>; }; }; - titleGenres: { - genres: Array<{ - genre: { - text: string; - }; - }>; - }; + titleGenres: { + genres: Array<{ + genre: { + text: string; + }; + }>; + }; productionStatus: { currentProductionStage: { id: string; @@ -882,7 +882,7 @@ export default interface Name { plainText: string; }; }; - attributes: Array<{ + attributes?: Array<{ id: string; text: string; }>; diff --git a/src/interfaces/misc/rawTitle.ts b/src/interfaces/misc/rawTitle.ts index b28d7b9..2aafec4 100644 --- a/src/interfaces/misc/rawTitle.ts +++ b/src/interfaces/misc/rawTitle.ts @@ -125,7 +125,7 @@ export default interface RawTitle { runtime: { value: number; }; - description: { + description?: { value: string; language: string; }; diff --git a/src/styles/modules/components/name/credits.module.scss b/src/styles/modules/components/name/credits.module.scss index 395b3c2..be761d6 100644 --- a/src/styles/modules/components/name/credits.module.scss +++ b/src/styles/modules/components/name/credits.module.scss @@ -4,12 +4,6 @@ display: grid; gap: var(--comp-whitespace); - & > section { - overflow-x: auto; - display: grid; - gap: var(--spacer-1); - } - details { overflow-x: auto; } diff --git a/src/styles/modules/components/name/did-you-know.module.scss b/src/styles/modules/components/name/did-you-know.module.scss index 28ae062..4672d36 100644 --- a/src/styles/modules/components/name/did-you-know.module.scss +++ b/src/styles/modules/components/name/did-you-know.module.scss @@ -1,4 +1,4 @@ -.bio { +.container { display: grid; gap: var(--comp-whitespace); } diff --git a/src/utils/cleaners/name.ts b/src/utils/cleaners/name.ts index 55110cc..b88c9ab 100644 --- a/src/utils/cleaners/name.ts +++ b/src/utils/cleaners/name.ts @@ -139,7 +139,7 @@ const cleanName = (rawData: RawName) => { })), }, released: getCredits(misc.releasedPrimaryCredits), - unreleased: getCredits<'unreleased'>(misc.unreleasedPrimaryCredits), + // unreleased: getCredits<'unreleased'>(misc.unreleasedPrimaryCredits), }, personalDetails: { officialSites: misc.personalDetailsExternalLinks.edges.map(item => ({ @@ -162,7 +162,7 @@ const cleanName = (rawData: RawName) => { name: spouse.spouse.asMarkdown.plainText, id: spouse.spouse.name?.id ?? null, range: spouse.timeRange.displayableProperty.value.plaidHtml, - attributes: spouse.attributes.map(attr => attr.text), + attributes: spouse.attributes?.map(attr => attr.text) ?? null, })) ?? null, children: misc.children.edges.map(child => ({ name: child.node.relationName.displayableProperty.value.plainText, diff --git a/src/utils/cleaners/title.ts b/src/utils/cleaners/title.ts index ebf74d2..b20869e 100644 --- a/src/utils/cleaners/title.ts +++ b/src/utils/cleaners/title.ts @@ -81,7 +81,7 @@ const cleanTitle = (rawData: RawTitle) => { isMature: main.primaryVideos.edges[0].node.isMature, thumbnail: main.primaryVideos.edges[0].node.thumbnail.url, runtime: main.primaryVideos.edges[0].node.runtime.value, - caption: main.primaryVideos.edges[0].node.description.value, + caption: main.primaryVideos.edges[0].node.description?.value ?? null, urls: main.primaryVideos.edges[0].node.playbackURLs.map(url => ({ resolution: url.displayName.value, mimeType: url.mimeType,