diff --git a/components/diaries/diary-create/diary-create.tsx b/components/diaries/diary-create/diary-create.tsx index 4a466572..3a28ae3d 100644 --- a/components/diaries/diary-create/diary-create.tsx +++ b/components/diaries/diary-create/diary-create.tsx @@ -13,7 +13,7 @@ import PetCheckbox from '@/components/diaries/pet-checkbox'; import ImageSkeleton from '@/components/skeleton/image/'; import { useRouter } from 'next/router'; -interface DiaryData { +export interface DiaryData { content: string; weather: string; isShare: boolean; @@ -183,7 +183,9 @@ const DiaryCreate: React.FC = () => { {Array.from({ length: 5 }).map((_, index) => (
(fileInputRefs.current[index] = el!)} + ref={(el) => { + fileInputRefs.current[index] = el!; + }} type="file" accept="image/*" onChange={handleImageChange(index)} diff --git a/components/diaries/pet-checkbox.tsx b/components/diaries/pet-checkbox.tsx index b55ec373..e47a17b0 100644 --- a/components/diaries/pet-checkbox.tsx +++ b/components/diaries/pet-checkbox.tsx @@ -1,7 +1,7 @@ import Image from 'next/image'; import styles from './pet-checkbox.module.scss'; import { UseFormRegister, FieldValues } from 'react-hook-form'; -import { DiaryData } from '@/types/diary'; +import { DiaryData } from './diary-create/diary-create'; interface PetCheckboxProps { register: UseFormRegister; diff --git a/components/family/diary/family-diary-contents-empty.tsx b/components/family/diary/family-diary-contents-empty.tsx index 40f13bf5..9d5d366c 100644 --- a/components/family/diary/family-diary-contents-empty.tsx +++ b/components/family/diary/family-diary-contents-empty.tsx @@ -1,7 +1,5 @@ import React from 'react'; -import Link from 'next/link'; import Image from 'next/image'; -import FamilyDiaryLayout from './layout/family-diary-layout'; import styles from './family-diary-contents-empty.module.scss'; import Hyperlink from '@/components/common/button/hyperlink'; diff --git a/components/family/growth/family-growth-empty.tsx b/components/family/growth/family-growth-empty.tsx index 0efdfa94..544f8da0 100644 --- a/components/family/growth/family-growth-empty.tsx +++ b/components/family/growth/family-growth-empty.tsx @@ -1,6 +1,5 @@ import React from 'react'; import styles from './family-growth-empty.module.scss'; -import Hyperlink from '@/components/common/button/hyperlink'; import Image from 'next/image'; import Link from 'next/link'; diff --git a/pages/growth/create/category-inputs/category-inputs.module.scss b/components/growth/category-inputs/category-inputs.module.scss similarity index 100% rename from pages/growth/create/category-inputs/category-inputs.module.scss rename to components/growth/category-inputs/category-inputs.module.scss diff --git a/pages/growth/create/category-inputs/index.tsx b/components/growth/category-inputs/index.tsx similarity index 100% rename from pages/growth/create/category-inputs/index.tsx rename to components/growth/category-inputs/index.tsx diff --git a/pages/growth/create/complete-modal/complete-modal.module.scss b/components/growth/complete-modal/complete-modal.module.scss similarity index 100% rename from pages/growth/create/complete-modal/complete-modal.module.scss rename to components/growth/complete-modal/complete-modal.module.scss diff --git a/pages/growth/create/complete-modal/index.tsx b/components/growth/complete-modal/index.tsx similarity index 100% rename from pages/growth/create/complete-modal/index.tsx rename to components/growth/complete-modal/index.tsx diff --git a/components/growth/list/list-header/index.tsx b/components/growth/list/list-header/index.tsx index cbd6fdc8..44a865e9 100644 --- a/components/growth/list/list-header/index.tsx +++ b/components/growth/list/list-header/index.tsx @@ -5,7 +5,7 @@ import DropdownMenu from '@/components/kebab/kebab'; import useToggle from '@/hooks/use-toggle'; import { useDeleteGrowthMutation } from '@/hooks/queries/growth/use-post-growth-query'; import { useRouter } from 'next/router'; -import CompleteModal from '@/pages/growth/create/complete-modal'; +import CompleteModal from '../../complete-modal'; import useModal from '@/hooks/use-modal'; import { GROWTH_CATEGORY_IMAGES } from '@/utils/constants/growth'; import Image from 'next/image'; diff --git a/hooks/queries/growth/use-get-growth-queries.ts b/hooks/queries/growth/use-get-growth-queries.ts index 1ec0b037..56d6c73c 100644 --- a/hooks/queries/growth/use-get-growth-queries.ts +++ b/hooks/queries/growth/use-get-growth-queries.ts @@ -14,6 +14,30 @@ export const useGetGrowthDetailQuery = (growthId: number) => { return useQuery({ queryKey: ['growth', growthId], queryFn: () => growthAPI.getGrowthDetails(growthId), + initialData: { + data: { + id: 0, + writerProfileImageUrl: '', + petProfileImageUrl: '', + category: '', + content: { + food: '', + snack: '', + abnormalSymptom: '', + hospitalName: '', + symptom: '', + diagnosis: '', + medicationMethod: '', + price: 0, + memo: '', + }, + dateTime: '', + nickname: '', + isMine: false, + petName: '', + date: '', + }, + }, }); }; diff --git a/middleware.ts b/middleware.ts index 4f47176e..bf07a2ad 100644 --- a/middleware.ts +++ b/middleware.ts @@ -2,7 +2,7 @@ import { NextResponse } from 'next/server'; import { NextRequest } from 'next/server'; import { MiddlewareData } from './utils/constants/middleware-data'; -const { PROTECTED_PAGES, PUBLIC_PAGES, NON_FAMILY_PAGES, FAMILY_PAGES, MATCHER_PAGES } = new MiddlewareData(); +const { PROTECTED_PAGES, PUBLIC_PAGES, NON_FAMILY_PAGES, FAMILY_PAGES } = new MiddlewareData(); export default function middleware(request: NextRequest) { const { cookies, nextUrl } = request; @@ -59,5 +59,5 @@ export default function middleware(request: NextRequest) { } export const config = { - matcher: MATCHER_PAGES, + matcher: '/:path*', }; diff --git a/pages/_app.tsx b/pages/_app.tsx index f683a8b3..5cf2fcfb 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,6 +1,5 @@ import type { AppProps } from 'next/app'; import '@/styles/globals.css'; -import { isHeader } from '@/utils/is-header'; import { isNav } from '@/utils/is-nav'; import { useRouter } from 'next/router'; import Nav from '@/components/common/nav/nav'; @@ -8,8 +7,6 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { useState, useRef } from 'react'; import usePullReload from '@/hooks/use-pull-to-refresh'; import Spinner from '@/components/spinner/spinner'; -import MainHeader from '@/components/common/Header/main-header'; -import CreateHeader from '@/components/common/Header/create-header'; import Header from '@/components/common/Header'; import { AnimatePresence } from 'framer-motion'; diff --git a/pages/diaries/[diaryId]/index.tsx b/pages/diaries/[diaryId]/index.tsx index f815dcbd..e0c023dc 100644 --- a/pages/diaries/[diaryId]/index.tsx +++ b/pages/diaries/[diaryId]/index.tsx @@ -37,7 +37,6 @@ export default function DiaryById({ diaryId }: InferGetServerSidePropsType weather.label === diaryQuery.data.weather); const { year, month, date, day } = disintegrateDateTime(diaryQuery.data && diaryQuery.data.date); - return (
@@ -69,7 +68,7 @@ export default function DiaryById({ diaryId }: InferGetServerSidePropsType ) : diaryQuery.isError ? (

Error: {diaryQuery.error.message}

- ) : ( + ) : diaryQuery.data ? ( <>
- )} + ) : null}
diff --git a/pages/growth/[growthId]/content/content.module.scss b/pages/growth/[growthId]/content/content.module.scss deleted file mode 100644 index 21a8d9f5..00000000 --- a/pages/growth/[growthId]/content/content.module.scss +++ /dev/null @@ -1,40 +0,0 @@ -.contentContainer { - display: flex; - flex-direction: column; - gap: 38px; - .wrapper { - display: flex; - flex-direction: column; - gap: 12px; - } - .title { - padding-left: 8px; - } - .content { - padding: 11px 12px; - } - .snackTitle { - border-left: 2px solid var(--snack-color); - } - .foodTitle { - border-left: 2px solid var(--main-color); - } - .abnormalSymptomTitle { - border-left: 2px solid var(--abnormalSymptom-color); - } - .hospitalTitle { - border-left: 2px solid var(--hospital-color); - } - .snackContent { - border-bottom: 1.5px solid var(--snack-color); - } - .foodContent { - border-bottom: 1.5px solid var(--main-color); - } - .abnormalSymptomContent { - border-bottom: 1.5px solid var(--abnormalSymptom-color); - } - .hospitalContent { - border-bottom: 1.5px solid var(--hospital-color); - } -} diff --git a/pages/growth/[growthId]/content/index.tsx b/pages/growth/[growthId]/content/index.tsx deleted file mode 100644 index 57ff33be..00000000 --- a/pages/growth/[growthId]/content/index.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import React from 'react'; -import styles from './content.module.scss'; -import { GrowthDetailsContent } from '@/types/growth/details'; - -interface ContentProps { - category: string; - content: GrowthDetailsContent; -} - -export default function Content({ category, content }: ContentProps) { - const getTitleColor = (category: string) => { - switch (category) { - case '간식': - return styles.snackTitle; - case '이상 증상': - return styles.abnormalSymptomTitle; - case '병원 기록': - return styles.hospitalTitle; - default: - return styles.foodTitle; - } - }; - const getContentColor = (category: string) => { - switch (category) { - case '간식': - return styles.snackContent; - case '이상 증상': - return styles.abnormalSymptomContent; - case '병원 기록': - return styles.hospitalContent; - default: - return styles.foodContent; - } - }; - const getTitleAndContent = (): { title: string; content: React.ReactNode } => { - switch (category) { - case '간식': - return { title: '간식', content: content.snack }; - case '이상 증상': - return { title: '이상 증상', content: content.abnormalSymptom }; - default: - return { title: '사료', content: content.food }; - } - }; - - const { title, content: displayContent } = getTitleAndContent(); - - if (category === '병원 기록') { - return ( -
- {content.hospitalName && ( -
-
병원명
-
{content.hospitalName}
-
- )} - {content.symptom && ( -
-
증상*
-
{content.symptom}
-
- )} - {content.diagnosis && ( -
-
진료 내용
-
{content.diagnosis}
-
- )} - {content.medicationMethod && ( -
-
복용 방법
-
{content.medicationMethod}
-
- )} - {content.price && ( -
-
가격
-
{content.price}
-
- )} -
- ); - } else { - return ( -
-
-
{title}
-
{displayContent}
-
-
- ); - } -} diff --git a/pages/growth/[growthId]/edit/index.tsx b/pages/growth/[growthId]/edit/index.tsx index f2bf744a..c0cabc7d 100644 --- a/pages/growth/[growthId]/edit/index.tsx +++ b/pages/growth/[growthId]/edit/index.tsx @@ -10,9 +10,9 @@ import { useRouter } from 'next/router'; import React, { useEffect, useState } from 'react'; import { SubmitHandler, useForm } from 'react-hook-form'; import styles from '../../create/create.module.scss'; -import CategoryInputs from '../../create/category-inputs'; +import CategoryInputs from '../../../../components/growth/category-inputs'; import classNames from 'classnames'; -import CompleteModal from '../../create/complete-modal'; +import CompleteModal from '../../../../components/growth/complete-modal'; import PetRadio from '@/components/calendar-monthly/pet-radio'; import useCalenderDateStore from '@/store/calendar.store'; import { convertToLocalDate } from '@/utils/convert-local-date'; @@ -44,7 +44,7 @@ export default function GrowthModify({ growthId }: InferGetServerSidePropsType { - if (growthList?.data) { + if (growthList) { setMemo(growthList.data.content.memo); setSelectedCategory(growthList.data.category); setContent(growthList.data.content); diff --git a/pages/growth/[growthId]/index.tsx b/pages/growth/[growthId]/index.tsx index 03458d33..bcc7b428 100644 --- a/pages/growth/[growthId]/index.tsx +++ b/pages/growth/[growthId]/index.tsx @@ -10,7 +10,7 @@ import { useDeleteGrowthMutation } from '@/hooks/queries/growth/use-post-growth- import { useRouter } from 'next/router'; import useModal from '@/hooks/use-modal'; import Image from 'next/image'; -import CompleteModal from '../create/complete-modal'; +import CompleteModal from '../../../components/growth/complete-modal'; import { GrowthDetailsContent, GrowthDetailsData } from '@/types/growth/details'; import { GROWTH_CATEGORY_IMAGES, GROWTH_MEMO_IMAGES } from '@/utils/constants/growth'; import Content from '../../../components/growth/content'; @@ -54,7 +54,7 @@ export default function GrowthDetailPage({ growthId }: GrowthDetailPageProps) { const [petName, setPetName] = useState(''); useEffect(() => { - if (growthDatas?.data) { + if (growthDatas) { const { category, nickname, writerProfileImageUrl, petProfileImageUrl, content, isMine, petName } = growthDatas.data as GrowthDetailsData; diff --git a/pages/growth/create/index.tsx b/pages/growth/create/index.tsx index 777f1d73..c1b2585f 100644 --- a/pages/growth/create/index.tsx +++ b/pages/growth/create/index.tsx @@ -5,14 +5,14 @@ import PetRadio from '@/components/calendar-monthly/pet-radio'; import { GROWTH_CATEGORY, GROWTH_CATEGORY_ICON } from '@/utils/constants/growth'; import { GrowthDetailsData, GrowthDetailsContent } from '@/types/growth/details'; import classNames from 'classnames'; -import CategoryInputs from './category-inputs'; +import CategoryInputs from '../../../components/growth/category-inputs'; import usePetsQuery from '@/hooks/queries/calendar/use-pets-query'; import { useCreateGrotwthMutation } from '@/hooks/queries/growth/use-post-growth-query'; import useCalenderDateStore from '@/store/calendar.store'; import { convertToLocalDate } from '@/utils/convert-local-date'; import { useRouter } from 'next/router'; import useModal from '@/hooks/use-modal'; -import CompleteModal from './complete-modal'; +import CompleteModal from '../../../components/growth/complete-modal'; import Image from 'next/image'; import MemoItem from '@/components/diaries/jihye/diary-edit-memo'; import ImageSkeleton from '@/components/skeleton/image/'; diff --git a/pages/growth/index.tsx b/pages/growth/index.tsx index f7916b83..3bb89098 100644 --- a/pages/growth/index.tsx +++ b/pages/growth/index.tsx @@ -38,9 +38,9 @@ export default function GrowthPage() {
- ) : ( + ) : growthLists ? (
- {growthLists?.data.map((growth, index) => { + {growthLists.data.map((growth, index) => { return ( - )} + ) : null}
diff --git a/pages/test/button-test/index.module.scss b/pages/test/button-test/index.module.scss deleted file mode 100644 index 7627201e..00000000 --- a/pages/test/button-test/index.module.scss +++ /dev/null @@ -1,6 +0,0 @@ -.box { - display: flex; - width: 100%; - color: var(--text-color); - overflow: hidden; -} diff --git a/pages/test/button-test/index.tsx b/pages/test/button-test/index.tsx deleted file mode 100644 index 69b09ffd..00000000 --- a/pages/test/button-test/index.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import Button from '@/components/common/button/button'; -import styles from './index.module.scss'; -import useModal from '@/hooks/use-modal'; - -function Buttons({ onClose }: { onClose: (v: boolean) => void }) { - const handleClick = () => { - console.log('b'); - onClose(false); - }; - return ( -
- -
- ); -} - -export default function ButtonTest() { - const [Modal, handleModal] = useModal(); - return ( - - - - ); -} diff --git a/pages/test/calendar/index.tsx b/pages/test/calendar/index.tsx deleted file mode 100644 index 7cb8a246..00000000 --- a/pages/test/calendar/index.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import useCalenderDateStore from '@/store/calendar.store'; -import Calendar from '../../../components/calendar-compound/calendar'; -import React from 'react'; - -export default function CalendarPage() { - // 모두 다 가져와야할 때. - const calenderStore = useCalenderDateStore(); - - // 데이터가 하나만 필요할 때. 아래와 같이 사용해야 성능적인 리렌더링 문제가 해결 됩니다. - // const onSelectedMonth = useCalenderDateStore.use.onSelectedMonth(); - // const onSelectedDate = useCalenderDateStore.use.onSelectedDate(); - // const onSelectedYear = useCalenderDateStore.use.onSelectedYear(); - // const onResetToday = useCalenderDateStore.use.onResetToday(); - // const year = useCalenderDateStore.use.year(); - // const month = useCalenderDateStore.use.month(); - // const date = useCalenderDateStore.use.date(); - - return ( - - 다이어리 - - - - - ); -} diff --git a/pages/test/input-test/index.module.scss b/pages/test/input-test/index.module.scss deleted file mode 100644 index 17de276a..00000000 --- a/pages/test/input-test/index.module.scss +++ /dev/null @@ -1,3 +0,0 @@ -.form { - padding-top: 72px; -} diff --git a/pages/test/input-test/index.tsx b/pages/test/input-test/index.tsx deleted file mode 100644 index f1ee4772..00000000 --- a/pages/test/input-test/index.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react'; -import Form from '@/components/common/Form'; -import { useForm } from 'react-hook-form'; - -const options = ['고양이', '강아지']; - -export default function InputTest() { - // eslint-disable-next-line - const methods = useForm({ - mode: 'onBlur', - }); - const { - handleSubmit, - control, - formState: { isValid }, - } = methods; - - // eslint-disable-next-line - const onSubmit = (data: any) => { - console.log(data); - }; - - return ( -
-
- 이름 - - 생일 - - 입양일 - - 무게 - - 품종 - - - -
- ); -} diff --git a/pages/test/kebab/index.tsx b/pages/test/kebab/index.tsx deleted file mode 100644 index d6381b0f..00000000 --- a/pages/test/kebab/index.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import useToggle from '../../../hooks/use-toggle'; -import DropdownMenu from '../../../components/kebab/kebab'; - -export default function index() { - const { isToggle: isOpen, handleCloseToggle: onCloseToggle, handleOpenToggle: onOpenToggle } = useToggle(); - - const updateFn = () => { - console.log('Update'); - onCloseToggle(); - }; - - const deleteFn = () => { - console.log('Delete'); - onCloseToggle(); - }; - - return ( -
- - - - 수정 - 삭제 - - -
- ); -} diff --git a/pages/test/modal-test/index.tsx b/pages/test/modal-test/index.tsx deleted file mode 100644 index 96792b37..00000000 --- a/pages/test/modal-test/index.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import useModal from '@/hooks/use-modal'; - -export default function ModalTest() { - const [Modal, handleModal] = useModal(); - - return ( - <> - - -
modal test
-
- - ); -} diff --git a/pages/test/radio-test/index.tsx b/pages/test/radio-test/index.tsx deleted file mode 100644 index cd9773b7..00000000 --- a/pages/test/radio-test/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import Radio from '@/components/common/radio/radio'; -import { useForm } from 'react-hook-form'; - -export interface RadioType { - type: string; -} - -export default function RadioTest() { - const { control, handleSubmit } = useForm({ - defaultValues: { - type: 'dog', - }, - }); - - const onSubmit = (data: RadioType) => { - console.log(data); - }; - - const radioValue = [ - { - value: 'dog', - text: '강아지', - id: 'dog', - }, - { - value: 'cat', - text: '고양이', - id: 'cat', - }, - ]; - return ( -
- - - - ); -} diff --git a/pages/test/refresh-test/index.tsx b/pages/test/refresh-test/index.tsx deleted file mode 100644 index cff91036..00000000 --- a/pages/test/refresh-test/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import MyFamilyApi from '@/api/my/groups'; - -export default function RefreshTest() { - const petsApi = new MyFamilyApi(); - const handleClick = async () => { - try { - const response = await petsApi.myFamilyCode(); - console.log(response); - } catch { - console.log('에러'); - } - }; - return ( -
- -
- ); -} diff --git a/pages/test/skeleton/index.tsx b/pages/test/skeleton/index.tsx deleted file mode 100644 index 800edc84..00000000 --- a/pages/test/skeleton/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import GrowthDetailSkeleton from '@/components/skeleton/growth/growth-detail'; -import GrowthListSkeleton from '@/components/skeleton/growth/growth-list'; -import React from 'react'; - -export default function Test() { - return ( -
- {/* */} - -
- ); -}