mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Add dbml, minor tweaks to beer style page
This commit is contained in:
33
src/pages/beers/styles/[id]/index.tsx
Normal file
33
src/pages/beers/styles/[id]/index.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import getBeerStyleById from '@/services/BeerStyles/getBeerStyleById';
|
||||
import BeerStyleQueryResult from '@/services/BeerStyles/schema/BeerStyleQueryResult';
|
||||
import { GetServerSideProps, NextPage } from 'next';
|
||||
import { z } from 'zod';
|
||||
|
||||
interface BeerStylePageProps {
|
||||
beerStyle: z.infer<typeof BeerStyleQueryResult>;
|
||||
}
|
||||
|
||||
const BeerStylePage: NextPage<BeerStylePageProps> = ({ beerStyle }) => {
|
||||
return (
|
||||
<div>
|
||||
<h1>{beerStyle.name}</h1>
|
||||
<p>{beerStyle.description}</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default BeerStylePage;
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<BeerStylePageProps> = async (
|
||||
context,
|
||||
) => {
|
||||
const beerStyle = await getBeerStyleById(context.params!.id! as string);
|
||||
|
||||
if (!beerStyle) {
|
||||
return {
|
||||
notFound: true,
|
||||
};
|
||||
}
|
||||
|
||||
return { props: { beerStyle: JSON.parse(JSON.stringify(beerStyle)) } };
|
||||
};
|
||||
Reference in New Issue
Block a user