Skip to content

Commit 0312f1a

Browse files
authored
fix(contributor-spotlight): show PageNotFound on error (#9759)
Previously we just showed an empty page.
1 parent a0813d0 commit 0312f1a

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

Diff for: client/src/contributor-spotlight/index.tsx

+32-28
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { Quote } from "../ui/molecules/quote";
99

1010
import "./index.scss";
1111
import { useLocale } from "../hooks";
12+
import { PageNotFound } from "../page-not-found";
13+
import { Loading } from "../ui/atoms/loading";
1214

1315
type ContributorDetails = {
1416
sections: [string];
@@ -31,7 +33,7 @@ export function ContributorSpotlight(props: HydrationData<ContributorDetails>) {
3133

3234
const fallbackData = props.hyData ? props : undefined;
3335

34-
const { data: { hyData } = {} } = useSWR<any>(
36+
const { error, data: { hyData } = {} } = useSWR<any>(
3537
contributorJSONUrl,
3638
async (url) => {
3739
const response = await fetch(url);
@@ -55,37 +57,39 @@ export function ContributorSpotlight(props: HydrationData<ContributorDetails>) {
5557
document.title = pageTitle;
5658
}, [hyData]);
5759

60+
if (error) {
61+
return <PageNotFound />;
62+
} else if (!hyData) {
63+
return <Loading />;
64+
}
65+
5866
return (
5967
<>
6068
<main className="contributor-spotlight-content-container">
61-
{hyData && (
62-
<>
63-
<h1 className="_ify">Contributor profile</h1>
64-
<section className="profile-header">
65-
<img
66-
className="profile-image"
67-
src={`${baseURL}/${hyData.profileImg}`}
68-
alt={hyData.profileImgAlt}
69-
width="200"
70-
height="200"
71-
/>
72-
<a
73-
className="username"
74-
href={`https://github.com/${hyData.usernames.github}`}
75-
>
76-
@{hyData.usernames.github}
77-
</a>
78-
</section>
79-
<section
80-
dangerouslySetInnerHTML={{ __html: hyData.sections[0] }}
81-
></section>
82-
<Quote name={hyData.contributorName}>{hyData.quote}</Quote>
69+
<h1 className="_ify">Contributor profile</h1>
70+
<section className="profile-header">
71+
<img
72+
className="profile-image"
73+
src={`${baseURL}/${hyData.profileImg}`}
74+
alt={hyData.profileImgAlt}
75+
width="200"
76+
height="200"
77+
/>
78+
<a
79+
className="username"
80+
href={`https://github.com/${hyData.usernames.github}`}
81+
>
82+
@{hyData.usernames.github}
83+
</a>
84+
</section>
85+
<section
86+
dangerouslySetInnerHTML={{ __html: hyData.sections[0] }}
87+
></section>
88+
<Quote name={hyData.contributorName}>{hyData.quote}</Quote>
8389

84-
{hyData.sections.slice(1).map((section) => {
85-
return <section dangerouslySetInnerHTML={{ __html: section }} />;
86-
})}
87-
</>
88-
)}
90+
{hyData.sections.slice(1).map((section) => {
91+
return <section dangerouslySetInnerHTML={{ __html: section }} />;
92+
})}
8993
</main>
9094
<GetInvolved />
9195
</>

0 commit comments

Comments
 (0)