mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Add beer post, brewery post GET service and page
Add prettier, eslint config
This commit is contained in:
26
pages/breweries/[id].tsx
Normal file
26
pages/breweries/[id].tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { GetServerSideProps, NextPage } from 'next';
|
||||
import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult';
|
||||
import getBreweryPostById from '@/services/BreweryPost/getBreweryPostById';
|
||||
|
||||
interface BreweryPageProps {
|
||||
breweryPost: BeerPostQueryResult;
|
||||
}
|
||||
|
||||
const BreweryByIdPage: NextPage<BreweryPageProps> = ({ breweryPost }) => {
|
||||
return (
|
||||
<>
|
||||
<h1 className="text-3xl font-bold underline">{breweryPost.name}</h1>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
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