Skip to content

Commit

Permalink
'disc not found' fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cdleveille committed Jun 1, 2024
1 parent e682fbe commit f12b959
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/app/@modal/default.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { DiscNotFound } from "@components";

export default function Default() {
return (
<div className="disc-detail-container">
<div className="disc-detail-not-found">
<p>Disc not found!</p>
</div>
</div>
);
return <DiscNotFound />;
}
8 changes: 5 additions & 3 deletions src/components/DiscDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ export const DiscDetail = ({ name_slug }: DiscDetailProps) => {
{fade}
</div>
</div>
<div className="disc-detail-img-container">
<Image src={pic} alt={name} width={400} height={340} className="disc-detail-img" />
</div>
{pic && (
<div className="disc-detail-img-container">
<Image src={pic} alt={name} width={400} height={340} className="disc-detail-img" />
</div>
)}
</div>
</div>
);
Expand Down
19 changes: 19 additions & 0 deletions src/components/DiscNotFound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";

import { useParams } from "next/navigation";
import { useContext } from "react";

import { DiscContext } from "@components";

export const DiscNotFound = () => {
const { name_slug } = useParams();
const { discs } = useContext(DiscContext);
if (!name_slug || discs.find(disc => disc.name_slug === name_slug)) return null;
return (
<div className="disc-detail-container">
<div className="disc-detail-not-found">
<div>Disc not found!</div>
</div>
</div>
);
};
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from "./DiscCount";
export * from "./DiscDetail";
export * from "./DiscGrid";
export * from "./DiscModal";
export * from "./DiscNotFound";
export * from "./Filters";
export * from "./Header";
export * from "./Home";
Expand Down

0 comments on commit f12b959

Please sign in to comment.