Refactored api services into sep files. Client fix

Fixed hydration errors in beers/[id] by implementing timeDistanceState
This commit is contained in:
Aaron William Po
2023-01-31 22:38:13 -05:00
parent 0b96c8f1f5
commit 5cf2087cd1
29 changed files with 380 additions and 430 deletions

View File

@@ -0,0 +1,29 @@
import DBClient from '@/prisma/DBClient';
import { z } from 'zod';
import BeerPostValidationSchema from './schema/CreateBeerPostValidationSchema';
const createNewBeerPost = async ({
name,
description,
abv,
ibu,
typeId,
breweryId,
}: z.infer<typeof BeerPostValidationSchema>) => {
const user = await DBClient.instance.user.findFirstOrThrow();
const newBeerPost = await DBClient.instance.beerPost.create({
data: {
name,
description,
abv,
ibu,
type: { connect: { id: typeId } },
postedBy: { connect: { id: user.id } },
brewery: { connect: { id: breweryId } },
},
});
return newBeerPost;
};
export default createNewBeerPost;