Update: beer post form now connected to a specific brewery.

This commit eliminates the brewery selector in the create beer post form, and reroutes the form page to /breweries/[id]/beers/create.

This commit also introduces the use of turbopack for `next dev`.
This commit is contained in:
Aaron William Po
2023-05-12 20:20:52 -04:00
parent 5c9970a045
commit 99c57d88c7
8 changed files with 76 additions and 97 deletions

View File

@@ -1,43 +0,0 @@
import CreateBeerPostForm from '@/components/CreateBeerPostForm';
import FormPageLayout from '@/components/ui/forms/FormPageLayout';
import withPageAuthRequired from '@/util/withPageAuthRequired';
import DBClient from '@/prisma/DBClient';
import getAllBreweryPosts from '@/services/BreweryPost/getAllBreweryPosts';
import BreweryPostQueryResult from '@/services/BreweryPost/types/BreweryPostQueryResult';
import { BeerType } from '@prisma/client';
import { NextPage } from 'next';
import { BiBeer } from 'react-icons/bi';
import { z } from 'zod';
interface CreateBeerPageProps {
breweries: z.infer<typeof BreweryPostQueryResult>[];
types: BeerType[];
}
const CreateBeerPost: NextPage<CreateBeerPageProps> = ({ breweries, types }) => {
return (
<FormPageLayout
headingText="Create a new beer"
headingIcon={BiBeer}
backLink="/beers"
backLinkText="Back to beers"
>
<CreateBeerPostForm breweries={breweries} types={types} />
</FormPageLayout>
);
};
export const getServerSideProps = withPageAuthRequired<CreateBeerPageProps>(async () => {
const breweryPosts = await getAllBreweryPosts();
const beerTypes = await DBClient.instance.beerType.findMany();
return {
props: {
breweries: JSON.parse(JSON.stringify(breweryPosts)),
types: JSON.parse(JSON.stringify(beerTypes)),
},
};
});
export default CreateBeerPost;

View File

@@ -47,16 +47,6 @@ const BeerPage: NextPage = () => {
<h1 className="text-4xl font-bold lg:text-6xl">The Biergarten App</h1>
<h2 className="text-2xl font-bold lg:text-4xl">Beers</h2>
</div>
{!!user && (
<div
className="tooltip tooltip-left h-full"
data-tip="Create a new beer post"
>
<Link href="/beers/create" className="btn-ghost btn-sm btn">
<FaPlus />
</Link>
</div>
)}
</header>
<div className="grid gap-6 xl:grid-cols-2">
{!!beerPosts.length && !isLoading && (