From d8a8dad37fe572c743a8190656dac78ca8984954 Mon Sep 17 00:00:00 2001 From: Aaron William Po Date: Mon, 27 Mar 2023 19:02:38 -0400 Subject: [PATCH] Refactor beer by id page Extracted services to separate files. --- components/BeerById/BeerCommentForm.tsx | 4 +--- components/BeerById/BeerPostCommentsSection.tsx | 5 ++--- components/ui/Navbar.tsx | 6 +++--- services/BeerComment/getBeerCommentCount.ts | 11 +++++++++++ services/BeerPostLike/getBeerPostLikeCount.ts | 11 +++++++++++ 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 services/BeerComment/getBeerCommentCount.ts create mode 100644 services/BeerPostLike/getBeerPostLikeCount.ts diff --git a/components/BeerById/BeerCommentForm.tsx b/components/BeerById/BeerCommentForm.tsx index f85972d..3187ed5 100644 --- a/components/BeerById/BeerCommentForm.tsx +++ b/components/BeerById/BeerCommentForm.tsx @@ -1,10 +1,9 @@ import sendCreateBeerCommentRequest from '@/requests/sendCreateBeerCommentRequest'; -import { BeerCommentQueryResultArrayT } from '@/services/BeerComment/schema/BeerCommentQueryResult'; import BeerCommentValidationSchema from '@/services/BeerComment/schema/CreateBeerCommentValidationSchema'; import { BeerPostQueryResult } from '@/services/BeerPost/schema/BeerPostQueryResult'; import { zodResolver } from '@hookform/resolvers/zod'; import { useRouter } from 'next/router'; -import { Dispatch, SetStateAction, FunctionComponent, useState, useEffect } from 'react'; +import { FunctionComponent, useState, useEffect } from 'react'; import { Rating } from 'react-daisyui'; import { useForm, SubmitHandler } from 'react-hook-form'; import { z } from 'zod'; @@ -18,7 +17,6 @@ import FormTextArea from '../ui/forms/FormTextArea'; interface BeerCommentFormProps { beerPost: BeerPostQueryResult; - setComments: Dispatch>; } const BeerCommentForm: FunctionComponent = ({ beerPost }) => { diff --git a/components/BeerById/BeerPostCommentsSection.tsx b/components/BeerById/BeerPostCommentsSection.tsx index 6a61623..a0824ba 100644 --- a/components/BeerById/BeerPostCommentsSection.tsx +++ b/components/BeerById/BeerPostCommentsSection.tsx @@ -9,14 +9,13 @@ import CommentCard from './CommentCard'; interface BeerPostCommentsSectionProps { beerPost: BeerPostQueryResult; - setComments: React.Dispatch>; comments: BeerCommentQueryResultArrayT; commentsPageCount: number; } const BeerPostCommentsSection: FC = ({ beerPost, - setComments, + comments, commentsPageCount, }) => { @@ -30,7 +29,7 @@ const BeerPostCommentsSection: FC = ({
{user ? ( - + ) : (
Log in to leave a comment. diff --git a/components/ui/Navbar.tsx b/components/ui/Navbar.tsx index 4803717..a329b6b 100644 --- a/components/ui/Navbar.tsx +++ b/components/ui/Navbar.tsx @@ -44,7 +44,7 @@ const Navbar = () => { return (
-
-