diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..bc7258e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,19 @@ +name: Build # workflow 의 이름 + +on: push # workflow 의 실행 시점 + +jobs: + build: # job 의 이름 + runs-on: ubuntu-latest # 실행할 OS 환경 + steps: # job 의 세부 단계 + # step1 : 코드 체크아웃 + - name: Checkout code + uses: actions/checkout@v4 + + # step2 : Node.js 설치 + - name: Install dependencies + run: npm install + + # step3 : 빌드 + - name: Build Next.js app + run: npm run build diff --git a/components/ActivityDetails/ActivityDetails.tsx b/components/ActivityDetails/ActivityDetails.tsx index bd23154..d990a5d 100644 --- a/components/ActivityDetails/ActivityDetails.tsx +++ b/components/ActivityDetails/ActivityDetails.tsx @@ -19,6 +19,7 @@ import { getActivityInfoResponse, getActivityReviewsResponse, } from '@/pages/api/activities/apiactivities.types'; +import Spinner from '../Spinner/Spinner'; export default function ActivityDetails({ id }: ActivityDetailsProps) { const router = useRouter(); @@ -50,7 +51,7 @@ export default function ActivityDetails({ id }: ActivityDetailsProps) { }); if (isLoadingActivity || isLoadingReviews) { - return
Loading...
; + return ; } if (activityError || reviewError) { diff --git a/components/ActivityDetails/Reservation/Reservation.tsx b/components/ActivityDetails/Reservation/Reservation.tsx index 997a1fc..11b9efc 100644 --- a/components/ActivityDetails/Reservation/Reservation.tsx +++ b/components/ActivityDetails/Reservation/Reservation.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useCallback } from 'react'; import { format, addDays } from 'date-fns'; import { PrimaryButton } from '@/components/Button/Button'; import { usePopup } from '@/hooks/usePopup'; @@ -25,21 +25,47 @@ export default function Reservation({ activity }: ReservationProps) { const { openPopup } = usePopup(); const { openModal, closeModal } = useModal(); - useEffect(() => { - if (selectedDate) { - updateModal(selectedDate, selectedTime); - } - }, [selectedDate]); + const getAvailableTimes = useCallback( + (date: Date | null) => { + if (!date) return []; + return schedules + .filter( + (schedule) => + format(new Date(schedule.date), 'yyyy-MM-dd') === + format(date, 'yyyy-MM-dd') + ) + .map((schedule) => `${schedule.startTime} ~ ${schedule.endTime}`); + }, + [schedules] + ); + + const updateModal = useCallback( + (date: Date | null, time: string | null) => { + setModal((prevModal) => ({ + ...prevModal, + content: ( + + ), + })); + }, + [getAvailableTimes, setModal] + ); useEffect(() => { - if (selectedTime) { + if (selectedDate) { updateModal(selectedDate, selectedTime); } if (selectedDate && selectedTime) { setButtonText(`${format(selectedDate, 'yy/MM/dd')} ${selectedTime}`); } - }, [selectedTime]); + }, [selectedDate, selectedTime, updateModal]); useEffect(() => { const isDisabled = !selectedTime; @@ -79,32 +105,6 @@ export default function Reservation({ activity }: ReservationProps) { const totalPrice = pricePerPerson * participants; - const updateModal = (date: Date | null, time: string | null) => { - setModal((prevModal) => ({ - ...prevModal, - content: ( - - ), - })); - }; - - const getAvailableTimes = (date: Date | null) => { - if (!date) return []; - return schedules - .filter( - (schedule) => - format(new Date(schedule.date), 'yyyy-MM-dd') === - format(date, 'yyyy-MM-dd') - ) - .map((schedule) => `${schedule.startTime} ~ ${schedule.endTime}`); - }; - useEffect(() => { setModal((prevModal) => ({ ...prevModal, diff --git a/components/Button/Button.tsx b/components/Button/Button.tsx index e81214b..0a36b07 100644 --- a/components/Button/Button.tsx +++ b/components/Button/Button.tsx @@ -125,7 +125,7 @@ export function CircleCloseButton({ onClick }: SimpleButtonProps) { /* 닫기 버튼 - 기본 버전 */ export function CloseButton({ onClick }: SimpleButtonProps) { return ( - ); @@ -185,7 +185,7 @@ export function MeatballButton({ onClick }: SimpleButtonProps) { /* 추가하기 버튼 - 항목 추가 시 사용 */ export function PlusButton({ onClick }: SimpleButtonProps) { return ( - ); @@ -194,7 +194,7 @@ export function PlusButton({ onClick }: SimpleButtonProps) { /* 제거하기 버튼 - 항목 제거 시 사용 */ export function MinusButton({ onClick }: SimpleButtonProps) { return ( - ); @@ -215,14 +215,11 @@ export function ArrowCircleButton({ onClick }: SimpleButtonProps) { } /* 이미지 등록하기 버튼 */ -export function ImageUploadButton({ onClick }: SimpleButtonProps) { +export function ImageUploadButton() { return ( - + ); } diff --git a/components/Button/Button.types.ts b/components/Button/Button.types.ts index adc4307..f853e0b 100644 --- a/components/Button/Button.types.ts +++ b/components/Button/Button.types.ts @@ -1,7 +1,7 @@ export interface PrimaryButtonProps { size: 'small' | 'medium' | 'large'; style: 'dark' | 'bright' | 'disabled' | 'enabled'; - children: string; + children?: string; disabled?: boolean; onClick: () => void; } diff --git a/components/InputBox/InputBox.tsx b/components/InputBox/InputBox.tsx index e3e1e88..b49d837 100644 --- a/components/InputBox/InputBox.tsx +++ b/components/InputBox/InputBox.tsx @@ -21,8 +21,13 @@ export default function InputBox({ }: InputBoxProps) { return (
- {label && } + {label && ( + + )} + {label && } +