Files
the-biergarten-app/pages/breweries/[id].tsx
Aaron William Po 5cf2087cd1 Refactored api services into sep files. Client fix
Fixed hydration errors in beers/[id] by implementing timeDistanceState
2023-01-31 23:16:43 -05:00

27 lines
800 B
TypeScript

import BeerPostQueryResult from '@/services/BeerPost/schema/BeerPostQueryResult';
import getBreweryPostById from '@/services/BreweryPost/getBreweryPostById';
import { GetServerSideProps, NextPage } from 'next';
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;