mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Refactor: update beer style, brewery post services
This commit is contained in:
@@ -8,7 +8,7 @@ import { BeerStyle } from '@prisma/client';
|
||||
import { NextPage } from 'next';
|
||||
import { BiBeer } from 'react-icons/bi';
|
||||
import { z } from 'zod';
|
||||
import getBreweryPostById from '@/services/posts/brewery-post/getBreweryPostById';
|
||||
import { getBreweryPostByIdService } from '@/services/posts/brewery-post';
|
||||
|
||||
interface CreateBeerPageProps {
|
||||
brewery: z.infer<typeof BreweryPostQueryResult>;
|
||||
@@ -32,7 +32,7 @@ export const getServerSideProps = withPageAuthRequired<CreateBeerPageProps>(
|
||||
async (context) => {
|
||||
const id = context.params?.id as string;
|
||||
|
||||
const breweryPost = await getBreweryPostById(id);
|
||||
const breweryPost = await getBreweryPostByIdService({ breweryPostId: id });
|
||||
const beerStyles = await DBClient.instance.beerStyle.findMany();
|
||||
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,8 @@ import FormPageLayout from '@/components/ui/forms/FormPageLayout';
|
||||
import FormSegment from '@/components/ui/forms/FormSegment';
|
||||
import FormTextArea from '@/components/ui/forms/FormTextArea';
|
||||
import FormTextInput from '@/components/ui/forms/FormTextInput';
|
||||
import getBreweryPostById from '@/services/posts/brewery-post/getBreweryPostById';
|
||||
import { getBreweryPostByIdService } from '@/services/posts/brewery-post';
|
||||
|
||||
import BreweryPostQueryResult from '@/services/posts/brewery-post/schema/BreweryPostQueryResult';
|
||||
import EditBreweryPostValidationSchema from '@/services/posts/brewery-post/schema/EditBreweryPostValidationSchema';
|
||||
import withPageAuthRequired from '@/util/withPageAuthRequired';
|
||||
@@ -143,7 +144,7 @@ export default EditBreweryPostPage;
|
||||
export const getServerSideProps = withPageAuthRequired<EditPageProps>(
|
||||
async (context, session) => {
|
||||
const breweryPostId = context.params?.id as string;
|
||||
const breweryPost = await getBreweryPostById(breweryPostId);
|
||||
const breweryPost = await getBreweryPostByIdService({ breweryPostId });
|
||||
|
||||
const { id: userId } = session;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import getBreweryPostById from '@/services/posts/brewery-post/getBreweryPostById';
|
||||
import BreweryPostQueryResult from '@/services/posts/brewery-post/schema/BreweryPostQueryResult';
|
||||
import { GetServerSideProps, NextPage } from 'next';
|
||||
|
||||
@@ -13,6 +12,7 @@ import { Tab } from '@headlessui/react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { MAPBOX_ACCESS_TOKEN } from '@/config/env';
|
||||
import { CldImage } from 'next-cloudinary';
|
||||
import { getBreweryPostByIdService } from '@/services/posts/brewery-post';
|
||||
|
||||
const [BreweryInfoHeader, BreweryBeersSection, BreweryCommentsSection, BreweryPostMap] = [
|
||||
dynamic(() => import('@/components/BreweryById/BreweryInfoHeader')),
|
||||
@@ -114,7 +114,9 @@ const BreweryByIdPage: NextPage<BreweryPageProps> = ({ breweryPost, mapboxToken
|
||||
export const getServerSideProps: GetServerSideProps<BreweryPageProps> = async (
|
||||
context,
|
||||
) => {
|
||||
const breweryPost = await getBreweryPostById(context.params!.id! as string);
|
||||
const breweryPost = await getBreweryPostByIdService({
|
||||
breweryPostId: context.params?.id as string,
|
||||
});
|
||||
const mapboxToken = MAPBOX_ACCESS_TOKEN;
|
||||
|
||||
return !breweryPost
|
||||
|
||||
Reference in New Issue
Block a user