import getBreweryPostById from '@/services/BreweryPost/getBreweryPostById'; import BreweryPostQueryResult from '@/services/BreweryPost/types/BreweryPostQueryResult'; import { GetServerSideProps, NextPage } from 'next'; import { z } from 'zod'; import Head from 'next/head'; import Image from 'next/image'; import 'react-responsive-carousel/lib/styles/carousel.min.css'; // requires a loader import { Carousel } from 'react-responsive-carousel'; import useMediaQuery from '@/hooks/useMediaQuery'; import { Tab } from '@headlessui/react'; import BreweryInfoHeader from '@/components/BreweryById/BreweryInfoHeader'; import BreweryPostMap from '@/components/BreweryById/BreweryPostMap'; import BreweryBeersSection from '@/components/BreweryById/BreweryBeerSection.tsx'; import BreweryCommentsSection from '@/components/BreweryById/BreweryCommentsSection'; interface BreweryPageProps { breweryPost: z.infer; } const BreweryByIdPage: NextPage = ({ breweryPost }) => { const [longitude, latitude] = breweryPost.location.coordinates; const isDesktop = useMediaQuery('(min-width: 1024px)'); return ( <> {breweryPost.name} <> {breweryPost.breweryImages.length ? breweryPost.breweryImages.map((image, index) => (
{image.alt}
)) : Array.from({ length: 1 }).map((_, i) => (
))}
{isDesktop ? (
) : ( <> Comments Beers )}
); }; export const getServerSideProps: GetServerSideProps = 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;