mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Restructure codebase to use src directory
This commit is contained in:
29
src/pages/breweries/[id].tsx
Normal file
29
src/pages/breweries/[id].tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import Layout from '@/components/ui/Layout';
|
||||
|
||||
import getBreweryPostById from '@/services/BreweryPost/getBreweryPostById';
|
||||
import BreweryPostQueryResult from '@/services/BreweryPost/types/BreweryPostQueryResult';
|
||||
import { GetServerSideProps, NextPage } from 'next';
|
||||
import { z } from 'zod';
|
||||
|
||||
interface BreweryPageProps {
|
||||
breweryPost: z.infer<typeof BreweryPostQueryResult>;
|
||||
}
|
||||
|
||||
const BreweryByIdPage: NextPage<BreweryPageProps> = ({ breweryPost }) => {
|
||||
return (
|
||||
<Layout>
|
||||
<h1 className="text-3xl font-bold underline">{breweryPost.name}</h1>
|
||||
</Layout>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<BreweryPageProps> = async (
|
||||
context,
|
||||
) => {
|
||||
const breweryPost = await getBreweryPostById(context.params!.id! as string);
|
||||
return !breweryPost
|
||||
? { notFound: true }
|
||||
: { props: { breweryPost: JSON.parse(JSON.stringify(breweryPost)) } };
|
||||
};
|
||||
|
||||
export default BreweryByIdPage;
|
||||
Reference in New Issue
Block a user