mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 18:52:06 +00:00
30 lines
910 B
TypeScript
30 lines
910 B
TypeScript
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;
|