From 5cf2087cd138b858d1091205cc6ee56b0beadd44 Mon Sep 17 00:00:00 2001 From: Aaron William Po Date: Tue, 31 Jan 2023 22:38:13 -0500 Subject: [PATCH] Refactored api services into sep files. Client fix Fixed hydration errors in beers/[id] by implementing timeDistanceState --- components/BeerById/BeerCommentForm.tsx | 84 +++-- components/BeerById/BeerInfoHeader.tsx | 10 +- components/BeerById/BeerRecommendations.tsx | 6 +- components/BeerById/CommentCard.tsx | 37 +- components/BeerForm.tsx | 19 +- components/BeerIndex/BeerCard.tsx | 2 +- components/ui/Navbar.tsx | 4 +- package-lock.json | 332 ++++++------------ package.json | 11 +- pages/api/beers/[id]/comments.ts | 41 +-- pages/api/beers/create.ts | 42 +-- pages/beers/[id].tsx | 41 ++- pages/beers/index.tsx | 6 +- pages/breweries/[id].tsx | 4 +- requests/sendCreateBeerCommentRequest.ts | 25 +- requests/sendCreateBeerPostRequest.ts | 2 +- services/BeerComment/createNewBeerComment.ts | 28 ++ .../getAllBeerComments.ts | 6 +- .../schema/BeerCommentQueryResult.ts | 15 + .../CreateBeerCommentValidationSchema.ts | 0 services/BeerPost/createNewBeerPost.ts | 29 ++ services/BeerPost/getAllBeerPosts.ts | 2 +- services/BeerPost/getBeerPostById.ts | 2 +- services/BeerPost/getBeerRecommendations.ts | 22 +- .../{types => schema}/BeerPostQueryResult.ts | 0 .../BeerReccomendationQueryResult.ts | 0 .../schema}/CreateBeerPostValidationSchema.ts | 0 .../BeerPost/types/BeerCommentQueryResult.ts | 13 - tailwind.config.js | 27 +- 29 files changed, 380 insertions(+), 430 deletions(-) create mode 100644 services/BeerComment/createNewBeerComment.ts rename services/{BeerPost => BeerComment}/getAllBeerComments.ts (78%) create mode 100644 services/BeerComment/schema/BeerCommentQueryResult.ts rename {validation => services/BeerComment/schema}/CreateBeerCommentValidationSchema.ts (100%) create mode 100644 services/BeerPost/createNewBeerPost.ts rename services/BeerPost/{types => schema}/BeerPostQueryResult.ts (100%) rename services/BeerPost/{types => schema}/BeerReccomendationQueryResult.ts (100%) rename {validation => services/BeerPost/schema}/CreateBeerPostValidationSchema.ts (100%) delete mode 100644 services/BeerPost/types/BeerCommentQueryResult.ts diff --git a/components/BeerById/BeerCommentForm.tsx b/components/BeerById/BeerCommentForm.tsx index e6d7cc9..e9a27f6 100644 --- a/components/BeerById/BeerCommentForm.tsx +++ b/components/BeerById/BeerCommentForm.tsx @@ -1,36 +1,30 @@ -import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult'; -import { Dispatch, FunctionComponent, SetStateAction } from 'react'; -import { z } from 'zod'; -import FormLabel from '@/components/ui/forms/FormLabel'; -import FormError from '@/components/ui/forms/FormError'; -import FormTextArea from '@/components/ui/forms/FormTextArea'; -import { SubmitHandler, useForm } from 'react-hook-form'; -import { zodResolver } from '@hookform/resolvers/zod'; -import Button from '@/components/ui/forms/Button'; -import FormInfo from '@/components/ui/forms/FormInfo'; -// @ts-expect-error -import ReactStars from 'react-rating-stars-component'; -import FormSegment from '@/components/ui/forms/FormSegment'; -import BeerCommentQueryResult from '@/services/BeerPost/types/BeerCommentQueryResult'; -import BeerCommentValidationSchema from '@/validation/CreateBeerCommentValidationSchema'; 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 { Rating } from 'react-daisyui'; +import { useForm, SubmitHandler } from 'react-hook-form'; +import { z } from 'zod'; + +import Button from '../ui/forms/Button'; +import FormError from '../ui/forms/FormError'; +import FormInfo from '../ui/forms/FormInfo'; +import FormLabel from '../ui/forms/FormLabel'; +import FormSegment from '../ui/forms/FormSegment'; +import FormTextArea from '../ui/forms/FormTextArea'; interface BeerCommentFormProps { beerPost: BeerPostQueryResult; - setComments: Dispatch>; + setComments: Dispatch>; } -const BeerCommentForm: FunctionComponent = ({ - beerPost, - setComments, -}) => { - const { - register, - handleSubmit, - formState: { errors }, - reset, - setValue, - } = useForm>({ +const BeerCommentForm: FunctionComponent = ({ beerPost }) => { + const { register, handleSubmit, formState, reset, setValue } = useForm< + z.infer + >({ defaultValues: { beerPostId: beerPost.id, rating: 0, @@ -38,22 +32,31 @@ const BeerCommentForm: FunctionComponent = ({ resolver: zodResolver(BeerCommentValidationSchema), }); + const [rating, setRating] = useState(0); + useEffect(() => { + setRating(0); + reset({ beerPostId: beerPost.id, rating: 0, content: '' }); + }, [beerPost.id, reset]); + + const router = useRouter(); const onSubmit: SubmitHandler> = async ( data, ) => { setValue('rating', 0); + setRating(0); await sendCreateBeerCommentRequest(data); - setComments((prev) => prev); reset(); + router.replace(router.asPath, undefined, { scroll: false }); }; + const { errors } = formState; + return (
Leave a comment {errors.content?.message} - = ({ error={!!errors.content?.message} /> - Rating {errors.rating?.message} - setValue('rating', value)} - /> + { + setRating(value); + setValue('rating', value); + }} + > + + + + + + ); diff --git a/components/BeerById/BeerInfoHeader.tsx b/components/BeerById/BeerInfoHeader.tsx index 1ce7d4e..4b21cdf 100644 --- a/components/BeerById/BeerInfoHeader.tsx +++ b/components/BeerById/BeerInfoHeader.tsx @@ -1,13 +1,17 @@ -import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult'; import Link from 'next/link'; import formatDistanceStrict from 'date-fns/formatDistanceStrict'; import format from 'date-fns/format'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { FaRegThumbsUp, FaThumbsUp } from 'react-icons/fa'; +import BeerPostQueryResult from '@/services/BeerPost/schema/BeerPostQueryResult'; const BeerInfoHeader: React.FC<{ beerPost: BeerPostQueryResult }> = ({ beerPost }) => { const createdAtDate = new Date(beerPost.createdAt); - const timeDistance = formatDistanceStrict(createdAtDate, Date.now()); + const [timeDistance, setTimeDistance] = useState(''); + + useEffect(() => { + setTimeDistance(formatDistanceStrict(new Date(beerPost.createdAt), new Date())); + }, [beerPost.createdAt]); const [isLiked, setIsLiked] = useState(false); diff --git a/components/BeerById/BeerRecommendations.tsx b/components/BeerById/BeerRecommendations.tsx index 724b547..e3b1339 100644 --- a/components/BeerById/BeerRecommendations.tsx +++ b/components/BeerById/BeerRecommendations.tsx @@ -1,6 +1,6 @@ -import { FunctionComponent } from 'react'; +import BeerRecommendationQueryResult from '@/services/BeerPost/schema/BeerReccomendationQueryResult'; import Link from 'next/link'; -import BeerRecommendationQueryResult from '@/services/BeerPost/types/BeerReccomendationQueryResult'; +import { FunctionComponent } from 'react'; interface BeerRecommendationsProps { beerRecommendations: BeerRecommendationQueryResult[]; @@ -14,7 +14,7 @@ const BeerRecommendations: FunctionComponent = ({ {beerRecommendations.map((beerPost) => (
- +

{beerPost.name}

diff --git a/components/BeerById/CommentCard.tsx b/components/BeerById/CommentCard.tsx index f7eb3cd..5af3e49 100644 --- a/components/BeerById/CommentCard.tsx +++ b/components/BeerById/CommentCard.tsx @@ -1,26 +1,35 @@ -import BeerCommentQueryResult from '@/services/BeerPost/types/BeerCommentQueryResult'; -import formatDistanceStrict from 'date-fns/formatDistanceStrict'; -// @ts-expect-error -import ReactStars from 'react-rating-stars-component'; +import { BeerCommentQueryResultT } from '@/services/BeerComment/schema/BeerCommentQueryResult'; +import { formatDistanceStrict } from 'date-fns'; +import { useEffect, useState } from 'react'; +import { Rating } from 'react-daisyui'; const CommentCard: React.FC<{ - comment: BeerCommentQueryResult; + comment: BeerCommentQueryResultT; }> = ({ comment }) => { - const timeDistance = formatDistanceStrict(new Date(comment.createdAt), new Date()); + const [timeDistance, setTimeDistance] = useState(''); + + useEffect(() => { + setTimeDistance(formatDistanceStrict(new Date(comment.createdAt), new Date())); + }, [comment.createdAt]); + return ( -
+

{comment.postedBy.username}

posted {timeDistance} ago

- + + {Array.from({ length: 5 }).map((val, index) => ( + + ))} +

{comment.content}

diff --git a/components/BeerForm.tsx b/components/BeerForm.tsx index a61bd0f..fd57e3c 100644 --- a/components/BeerForm.tsx +++ b/components/BeerForm.tsx @@ -1,13 +1,12 @@ -import BreweryPostQueryResult from '@/services/BreweryPost/types/BreweryPostQueryResult'; -import { BeerType } from '@prisma/client'; - -import { FunctionComponent } from 'react'; -import { SubmitHandler, useForm } from 'react-hook-form'; -import { z } from 'zod'; -import { zodResolver } from '@hookform/resolvers/zod'; -import BeerPostValidationSchema from '@/validation/CreateBeerPostValidationSchema'; -import Router from 'next/router'; import sendCreateBeerPostRequest from '@/requests/sendCreateBeerPostRequest'; +import BeerPostValidationSchema from '@/services/BeerPost/schema/CreateBeerPostValidationSchema'; +import BreweryPostQueryResult from '@/services/BreweryPost/types/BreweryPostQueryResult'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { BeerType } from '@prisma/client'; +import router from 'next/router'; +import { FunctionComponent } from 'react'; +import { useForm, SubmitHandler } from 'react-hook-form'; +import { z } from 'zod'; import Button from './ui/forms/Button'; import FormError from './ui/forms/FormError'; import FormInfo from './ui/forms/FormInfo'; @@ -52,7 +51,7 @@ const BeerForm: FunctionComponent = ({ case 'create': { try { const response = await sendCreateBeerPostRequest(data); - Router.push(`/beers/${response.id}`); + router.push(`/beers/${response.id}`); break; } catch (e) { // eslint-disable-next-line no-console diff --git a/components/BeerIndex/BeerCard.tsx b/components/BeerIndex/BeerCard.tsx index 74c073e..9a68635 100644 --- a/components/BeerIndex/BeerCard.tsx +++ b/components/BeerIndex/BeerCard.tsx @@ -1,7 +1,7 @@ -import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult'; import Link from 'next/link'; import { FC } from 'react'; import Image from 'next/image'; +import BeerPostQueryResult from '@/services/BeerPost/schema/BeerPostQueryResult'; const BeerCard: FC<{ post: BeerPostQueryResult }> = ({ post }) => { return ( diff --git a/components/ui/Navbar.tsx b/components/ui/Navbar.tsx index 27ac0fb..51a82d3 100644 --- a/components/ui/Navbar.tsx +++ b/components/ui/Navbar.tsx @@ -24,10 +24,10 @@ const Navbar = () => { ]; return ( -
-
+
{comments.map((comment) => ( ))} @@ -90,8 +92,11 @@ export const getServerSideProps: GetServerSideProps = async (cont } const { type, brewery, id } = beerPost; - const beerComments = await getAllBeerComments({ id }, { pageSize: 3, pageNum: 1 }); - const beerRecommendations = await getBeerRecommendations({ type, brewery }); + const beerComments = await getAllBeerComments( + { id: beerPost.id }, + { pageSize: 9, pageNum: 1 }, + ); + const beerRecommendations = await getBeerRecommendations({ type, brewery, id }); const props = { beerPost: JSON.parse(JSON.stringify(beerPost)), diff --git a/pages/beers/index.tsx b/pages/beers/index.tsx index 2850fd6..6a05ee4 100644 --- a/pages/beers/index.tsx +++ b/pages/beers/index.tsx @@ -1,12 +1,12 @@ import { GetServerSideProps, NextPage } from 'next'; import getAllBeerPosts from '@/services/BeerPost/getAllBeerPosts'; -import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult'; import { useRouter } from 'next/router'; import DBClient from '@/prisma/DBClient'; import Layout from '@/components/ui/Layout'; -import Pagination from '../../components/BeerIndex/Pagination'; -import BeerCard from '../../components/BeerIndex/BeerCard'; +import Pagination from '@/components/BeerIndex/Pagination'; +import BeerCard from '@/components/BeerIndex/BeerCard'; +import BeerPostQueryResult from '@/services/BeerPost/schema/BeerPostQueryResult'; interface BeerPageProps { initialBeerPosts: BeerPostQueryResult[]; diff --git a/pages/breweries/[id].tsx b/pages/breweries/[id].tsx index 9585a84..33a519d 100644 --- a/pages/breweries/[id].tsx +++ b/pages/breweries/[id].tsx @@ -1,6 +1,6 @@ -import { GetServerSideProps, NextPage } from 'next'; -import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult'; +import BeerPostQueryResult from '@/services/BeerPost/schema/BeerPostQueryResult'; import getBreweryPostById from '@/services/BreweryPost/getBreweryPostById'; +import { GetServerSideProps, NextPage } from 'next'; interface BreweryPageProps { breweryPost: BeerPostQueryResult; diff --git a/requests/sendCreateBeerCommentRequest.ts b/requests/sendCreateBeerCommentRequest.ts index ca92c7f..d4692e6 100644 --- a/requests/sendCreateBeerCommentRequest.ts +++ b/requests/sendCreateBeerCommentRequest.ts @@ -1,5 +1,7 @@ +import { BeerCommentQueryResult } from '@/services/BeerComment/schema/BeerCommentQueryResult'; +import BeerCommentValidationSchema from '@/services/BeerComment/schema/CreateBeerCommentValidationSchema'; +import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema'; import { z } from 'zod'; -import BeerCommentValidationSchema from '../validation/CreateBeerCommentValidationSchema'; const sendCreateBeerCommentRequest = async ({ beerPostId, @@ -20,7 +22,26 @@ const sendCreateBeerCommentRequest = async ({ const data = await response.json(); - console.log(data); + if (!response.ok) { + throw new Error(data.message); + } + + const parsedResponse = APIResponseValidationSchema.safeParse(data); + + if (!parsedResponse.success) { + console.log(parsedResponse.error); + throw new Error('Invalid API response'); + } + + console.log(parsedResponse); + const parsedPayload = BeerCommentQueryResult.safeParse(parsedResponse.data.payload); + + if (!parsedPayload.success) { + console.log(parsedPayload.error); + throw new Error('Invalid API response payload'); + } + + return parsedPayload.data; }; export default sendCreateBeerCommentRequest; diff --git a/requests/sendCreateBeerPostRequest.ts b/requests/sendCreateBeerPostRequest.ts index 2398838..7e5c8e8 100644 --- a/requests/sendCreateBeerPostRequest.ts +++ b/requests/sendCreateBeerPostRequest.ts @@ -1,4 +1,4 @@ -import BeerPostValidationSchema from '@/validation/CreateBeerPostValidationSchema'; +import BeerPostValidationSchema from '@/services/BeerPost/schema/CreateBeerPostValidationSchema'; import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema'; import { z } from 'zod'; diff --git a/services/BeerComment/createNewBeerComment.ts b/services/BeerComment/createNewBeerComment.ts new file mode 100644 index 0000000..ec6b55e --- /dev/null +++ b/services/BeerComment/createNewBeerComment.ts @@ -0,0 +1,28 @@ +import DBClient from '@/prisma/DBClient'; +import { z } from 'zod'; +import BeerCommentValidationSchema from './schema/CreateBeerCommentValidationSchema'; + +const createNewBeerComment = async ({ + content, + rating, + beerPostId, +}: z.infer) => { + const user = await DBClient.instance.user.findFirstOrThrow(); + return DBClient.instance.beerComment.create({ + data: { + content, + rating, + beerPost: { connect: { id: beerPostId } }, + postedBy: { connect: { id: user.id } }, + }, + select: { + id: true, + content: true, + rating: true, + postedBy: { select: { id: true, username: true } }, + createdAt: true, + }, + }); +}; + +export default createNewBeerComment; diff --git a/services/BeerPost/getAllBeerComments.ts b/services/BeerComment/getAllBeerComments.ts similarity index 78% rename from services/BeerPost/getAllBeerComments.ts rename to services/BeerComment/getAllBeerComments.ts index f36476c..7410348 100644 --- a/services/BeerPost/getAllBeerComments.ts +++ b/services/BeerComment/getAllBeerComments.ts @@ -1,13 +1,13 @@ -import BeerCommentQueryResult from '@/services/BeerPost/types/BeerCommentQueryResult'; import DBClient from '@/prisma/DBClient'; -import BeerPostQueryResult from './types/BeerPostQueryResult'; +import BeerPostQueryResult from '../BeerPost/schema/BeerPostQueryResult'; +import { BeerCommentQueryResultArrayT } from './schema/BeerCommentQueryResult'; const getAllBeerComments = async ( { id }: Pick, { pageSize, pageNum = 0 }: { pageSize: number; pageNum?: number }, ) => { const skip = (pageNum - 1) * pageSize; - const beerComments: BeerCommentQueryResult[] = + const beerComments: BeerCommentQueryResultArrayT = await DBClient.instance.beerComment.findMany({ where: { beerPostId: id, diff --git a/services/BeerComment/schema/BeerCommentQueryResult.ts b/services/BeerComment/schema/BeerCommentQueryResult.ts new file mode 100644 index 0000000..b80894e --- /dev/null +++ b/services/BeerComment/schema/BeerCommentQueryResult.ts @@ -0,0 +1,15 @@ +import { z } from 'zod'; + +export const BeerCommentQueryResult = z.object({ + id: z.string().uuid(), + content: z.string().min(1).max(300), + rating: z.number().int().min(1).max(5), + createdAt: z.date().or(z.string().datetime()), + postedBy: z.object({ + id: z.string().uuid(), + username: z.string().min(1).max(50), + }), +}); +export const BeerCommentQueryResultArray = z.array(BeerCommentQueryResult); +export type BeerCommentQueryResultT = z.infer; +export type BeerCommentQueryResultArrayT = z.infer; diff --git a/validation/CreateBeerCommentValidationSchema.ts b/services/BeerComment/schema/CreateBeerCommentValidationSchema.ts similarity index 100% rename from validation/CreateBeerCommentValidationSchema.ts rename to services/BeerComment/schema/CreateBeerCommentValidationSchema.ts diff --git a/services/BeerPost/createNewBeerPost.ts b/services/BeerPost/createNewBeerPost.ts new file mode 100644 index 0000000..64f9a54 --- /dev/null +++ b/services/BeerPost/createNewBeerPost.ts @@ -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) => { + 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; diff --git a/services/BeerPost/getAllBeerPosts.ts b/services/BeerPost/getAllBeerPosts.ts index eb6661d..6e20cc6 100644 --- a/services/BeerPost/getAllBeerPosts.ts +++ b/services/BeerPost/getAllBeerPosts.ts @@ -1,5 +1,5 @@ import DBClient from '@/prisma/DBClient'; -import BeerPostQueryResult from './types/BeerPostQueryResult'; +import BeerPostQueryResult from './schema/BeerPostQueryResult'; const prisma = DBClient.instance; diff --git a/services/BeerPost/getBeerPostById.ts b/services/BeerPost/getBeerPostById.ts index 4b2f548..bc67ca3 100644 --- a/services/BeerPost/getBeerPostById.ts +++ b/services/BeerPost/getBeerPostById.ts @@ -1,5 +1,5 @@ import DBClient from '@/prisma/DBClient'; -import BeerPostQueryResult from './types/BeerPostQueryResult'; +import BeerPostQueryResult from './schema/BeerPostQueryResult'; const prisma = DBClient.instance; diff --git a/services/BeerPost/getBeerRecommendations.ts b/services/BeerPost/getBeerRecommendations.ts index 58cc144..4c7dae1 100644 --- a/services/BeerPost/getBeerRecommendations.ts +++ b/services/BeerPost/getBeerRecommendations.ts @@ -1,27 +1,17 @@ -import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult'; import DBClient from '@/prisma/DBClient'; +import BeerPostQueryResult from './schema/BeerPostQueryResult'; const getBeerRecommendations = async ( - beerPost: Pick, + beerPost: Pick, ) => { const beerRecommendations = await DBClient.instance.beerPost.findMany({ where: { - OR: [ - { - typeId: beerPost.type.id, - }, - { - breweryId: beerPost.brewery.id, - }, - ], + OR: [{ typeId: beerPost.type.id }, { breweryId: beerPost.brewery.id }], + NOT: { id: beerPost.id }, }, include: { - beerImages: { - select: { id: true, url: true, alt: true }, - }, - brewery: { - select: { id: true, name: true }, - }, + beerImages: { select: { id: true, url: true, alt: true } }, + brewery: { select: { id: true, name: true } }, }, }); diff --git a/services/BeerPost/types/BeerPostQueryResult.ts b/services/BeerPost/schema/BeerPostQueryResult.ts similarity index 100% rename from services/BeerPost/types/BeerPostQueryResult.ts rename to services/BeerPost/schema/BeerPostQueryResult.ts diff --git a/services/BeerPost/types/BeerReccomendationQueryResult.ts b/services/BeerPost/schema/BeerReccomendationQueryResult.ts similarity index 100% rename from services/BeerPost/types/BeerReccomendationQueryResult.ts rename to services/BeerPost/schema/BeerReccomendationQueryResult.ts diff --git a/validation/CreateBeerPostValidationSchema.ts b/services/BeerPost/schema/CreateBeerPostValidationSchema.ts similarity index 100% rename from validation/CreateBeerPostValidationSchema.ts rename to services/BeerPost/schema/CreateBeerPostValidationSchema.ts diff --git a/services/BeerPost/types/BeerCommentQueryResult.ts b/services/BeerPost/types/BeerCommentQueryResult.ts deleted file mode 100644 index e06ed27..0000000 --- a/services/BeerPost/types/BeerCommentQueryResult.ts +++ /dev/null @@ -1,13 +0,0 @@ -interface BeerCommentQueryResult { - id: string; - content: string; - rating: number; - createdAt: Date; - postedBy: { - id: string; - createdAt: Date; - username: string; - }; -} - -export default BeerCommentQueryResult; diff --git a/tailwind.config.js b/tailwind.config.js index 9a629fe..7e0ac46 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,12 +1,35 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: ['./pages/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,jsx,tsx}'], + content: [ + './pages/**/*.{js,ts,jsx,tsx}', + './components/**/*.{js,ts,jsx,tsx}', + 'node_modules/daisyui/dist/**/*.js', + 'node_modules/react-daisyui/dist/**/*.js', + ], theme: { extend: {}, }, plugins: [require('daisyui')], daisyui: { logs: false, - themes: ['dracula'], + themes: [ + { + default: { + primary: 'hsl(227, 46%, 25%)', + secondary: 'hsl(47, 100%, 80%)', + accent: '#fe3bd9', + neutral: '#131520', + info: '#0A7CFF', + success: '#8ACE2B', + warning: '#F9D002', + error: '#CF1259', + 'primary-content': '#FAF9F6', + 'error-content': '#FAF9F6', + 'base-100': 'hsl(190, 4%, 15%)', + 'base-200': 'hsl(190, 4%, 12%)', + 'base-300': 'hsl(190, 4%, 10%)', + }, + }, + ], }, };