Skip to content

Commit

Permalink
Merge pull request #187 from storybookjs/charles/sb-1525-500-error-in…
Browse files Browse the repository at this point in the history
…-addon-tags

Improve error state on addon tags
  • Loading branch information
cdedreuille authored Jul 15, 2024
2 parents d3e8835 + 2267d66 commit c1ccca0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apps/addon-catalog/app/(home)/tag/[...name]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Link from 'next/link';

export default function NotFound() {
return (
<div>
<h2 className="mb-8 text-2xl font-bold">Not Found</h2>
<p className="mb-8">We could not found any information for this tag.</p>
<Link href="/" className="text-blue-500">
Return to the list of addons
</Link>
</div>
);
}
43 changes: 43 additions & 0 deletions apps/addon-catalog/app/(home)/tag/[...name]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Preview } from '../../../../components/preview';
import { fetchTagDetailsData } from '../../../../lib/fetch-tag-details-data';
import { notFound } from 'next/navigation';

interface TagDetailsProps {
params: {
name: string;
};
}

// export async function generateStaticParams() {
// const categories = (await fetchTagsData({ isCategory: true })) || [];
// const tags = (await fetchTagsData()) || [];
// return [...categories, ...tags].map((name) => ({
// params: { name },
// }));
// }

export default async function TagDetails({
params: { name },
}: TagDetailsProps) {
const data = (await fetchTagDetailsData(name)) || {};

if ('error' in data) return notFound();

return (
<>
<h3 className="mb-8 text-2xl font-bold">
{data.displayName} integrations
</h3>
<div className="flex flex-col gap-6">
{data.topIntegrations?.addons?.map((addon) => (
<Preview
key={addon.name}
element={addon}
orientation="horizontal"
type="addon"
/>
))}
</div>
</>
);
}

0 comments on commit c1ccca0

Please sign in to comment.