From dd49803697d9e07fd11a7767db393eff0bf5df23 Mon Sep 17 00:00:00 2001 From: Minji Lee <79428205+alswlfl29@users.noreply.github.com> Date: Thu, 4 Jul 2024 16:36:33 +0900 Subject: [PATCH] =?UTF-8?q?[Feat/#44]=20=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A4,=20=ED=98=B8=EC=8A=A4=ED=8A=B8=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20api=20=EC=97=B0=EB=8F=99,=20QR=20=EA=B2=B0=EC=A0=9C?= =?UTF-8?q?=20api=20=EC=88=98=EC=A0=95=20(#45)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: QR 결제 클래스 날짜 제외 * feat: 호스트 여부 판단 api * feat: 호스트 등록 api 연동 * feat: 클래스 등록 api 연동 * fix: console 삭제 및 주소창 zindex 높임 --------- Co-authored-by: seoyeon Moon <66253833+seoyeon08@users.noreply.github.com> --- src/apis/apiClient.ts | 25 +++- src/apis/imageApiClient.ts | 65 +++++++++ src/apis/interfaces/lessonApi.ts | 2 + src/apis/interfaces/reservationApi.ts | 14 +- .../molecules/AddLessonTimeList.tsx | 17 ++- src/components/molecules/SelectAddress.tsx | 6 +- src/constants/hostMain.ts | 17 +++ src/pages/main/HanaFunMain.tsx | 7 +- src/pages/main/Home.tsx | 3 - src/pages/main/QRPay.tsx | 66 +-------- src/pages/openLesson/OpenLessonMain.tsx | 36 ++--- src/pages/openLesson/RegisterHost.tsx | 38 ++++- src/pages/openLesson/RegisterLesson.tsx | 131 +++++++++++------- src/pages/search/LessonDetail.tsx | 9 +- src/pages/search/LessonSearch.tsx | 31 ----- src/types/host.d.ts | 15 +- src/types/lesson.d.ts | 19 ++- src/types/transaction.d.ts | 4 +- 18 files changed, 282 insertions(+), 223 deletions(-) create mode 100644 src/apis/imageApiClient.ts create mode 100644 src/constants/hostMain.ts delete mode 100644 src/pages/main/Home.tsx diff --git a/src/apis/apiClient.ts b/src/apis/apiClient.ts index a6794c2..6326a68 100644 --- a/src/apis/apiClient.ts +++ b/src/apis/apiClient.ts @@ -5,15 +5,17 @@ import { userApi } from './interfaces/userApi'; import { accountApi } from './interfaces/accountApi'; import { hostApi } from './interfaces/hostApi'; import { categoryApi } from './interfaces/categoryApi'; -import { - CreateHostReqType, - CreateHostResType, - HostInfoType, -} from '../types/host'; import { transactionApi } from './interfaces/transactionApi'; +import { reservationApi } from './interfaces/reservationApi'; export class ApiClient - implements userApi, accountApi, hostApi, categoryApi, transactionApi + implements + userApi, + accountApi, + hostApi, + categoryApi, + transactionApi, + reservationApi { private static instance: ApiClient; private axiosInstance: AxiosInstance; @@ -44,7 +46,7 @@ export class ApiClient BaseResponseType<{ isHost: boolean }> >({ method: 'get', - url: '/user/ishost', + url: '/user/isHost', }); return response.data; } @@ -215,6 +217,15 @@ export class ApiClient return response.data; } + async postCreateLesson(reqData: CreateLessonReqType) { + const response = await this.axiosInstance.request({ + method: 'post', + url: '/lesson/create', + data: reqData, + }); + return response.data; + } + //---------reservation--------- // 마이페이지 출력 diff --git a/src/apis/imageApiClient.ts b/src/apis/imageApiClient.ts new file mode 100644 index 0000000..448cbe3 --- /dev/null +++ b/src/apis/imageApiClient.ts @@ -0,0 +1,65 @@ +import axios, { AxiosInstance } from 'axios'; +import { API_BASE_URL } from './url'; +import { getCookie } from '../utils/cookie'; + +export class ImageApiClient { + private static instance: ImageApiClient; + private axiosImgInstance: AxiosInstance; + + constructor() { + this.axiosImgInstance = this.createImageAxiosInstance(); + } + + // 이미지 업로드 + async postLessonImg(formData: FormData) { + console.log('ddddfsdjf>>', formData); + const response = await this.axiosImgInstance.request({ + method: 'post', + url: '/lesson/image-upload', + data: formData, + }); + return response.data; + } + + static getImageInstance(): ImageApiClient { + return this.instance || (this.instance = new this()); + } + + // registerToken(newToken: string) { + // this.axiosInstance = this.createAxiosInstance(newToken); + // } + + logout() { + this.axiosImgInstance = this.createImageAxiosInstance(); + } + + private createImageAxiosInstance = () => { + const headers: any = { + 'content-type': 'multipart/form-data', + }; + + const newInstance = axios.create({ + baseURL: API_BASE_URL, + timeout: 100000, + headers, + }); + + newInstance.interceptors.request.use( + (config) => { + const TOKEN = getCookie('token'); + if (TOKEN) { + config.headers['Authorization'] = `Bearer ${TOKEN}`; + } + + config.headers['Content-Type'] = 'multipart/form-data'; + return config; + }, + (error) => { + console.log(error); + return Promise.reject(error); + } + ); + + return newInstance; + }; +} diff --git a/src/apis/interfaces/lessonApi.ts b/src/apis/interfaces/lessonApi.ts index e427436..574322d 100644 --- a/src/apis/interfaces/lessonApi.ts +++ b/src/apis/interfaces/lessonApi.ts @@ -3,4 +3,6 @@ export interface lessonApi { lesson_id: number ): Promise>; getLessonDate(lessonId: number): Promise>; + postLessonImg(file: FormData): Promise; + postCreateLesson(reqData: CreateLessonReqType): Promise; } diff --git a/src/apis/interfaces/reservationApi.ts b/src/apis/interfaces/reservationApi.ts index e967597..ce4cd22 100644 --- a/src/apis/interfaces/reservationApi.ts +++ b/src/apis/interfaces/reservationApi.ts @@ -5,18 +5,18 @@ export interface reservationApi { lesson_id: number ): Promise>; - postLessonReservation(reqData: ReservationReqType): Promise< - BaseResponseType<{ - reservationId: number; - }> - >; + postLessonReservation( + reqData: ReservationReqType + ): Promise>; getMyLesson(): Promise>; getMyLessonAll(): Promise>; - getMyLessonCalendar(): Promise>; + // getMyLessonCalendar(): Promise>; - cancelLesson(): Promise>; + cancelLesson( + reservationId: CancelLessonReqType + ): Promise; peopleList( lessondate_id: PeopleListReqType diff --git a/src/components/molecules/AddLessonTimeList.tsx b/src/components/molecules/AddLessonTimeList.tsx index 790afc6..59ba1aa 100644 --- a/src/components/molecules/AddLessonTimeList.tsx +++ b/src/components/molecules/AddLessonTimeList.tsx @@ -2,18 +2,17 @@ import { FC, useEffect, useRef, useState } from 'react'; import { LuMinusCircle, LuPlusCircle } from 'react-icons/lu'; import { AddLessonInputLabel } from '../Atom/AddLessonInputLabel'; import { format } from 'date-fns'; -import { LessonTime } from '../../pages/openLesson/RegisterLesson'; import { useModal } from '../../context/ModalContext'; interface IProps { - onChangeTimes: (lessontime: LessonTime[]) => void; + onChangeTimes: (lessontime: LessonDateCommonType[]) => void; } type TimeType = { id: number; date: Date | null; - startTime: number | null; - endTime: number | null; + startTime: Date | null; + endTime: Date | null; }; export const AddLessonTimeList: FC = ({ onChangeTimes }) => { @@ -75,12 +74,18 @@ export const AddLessonTimeList: FC = ({ onChangeTimes }) => { setInputTimeItems(inputTimeItems.filter((item) => item.id !== index)); return; } - inputItemsCopy[index][name] = e.target.value; + if (name !== 'date') { + const time_date = inputItemsCopy[index]['date'] + ? inputItemsCopy[index]['date'] + ' ' + e.target.value + ':00' + : format(new Date(), 'yyyy-MM-dd') + ' ' + e.target.value + ':00'; + inputItemsCopy[index][name] = time_date; + } else inputItemsCopy[index][name] = e.target.value; + setInputTimeItems(inputItemsCopy); }; const handlechangeTimes = () => { - let datetime: LessonTime[] = []; + let datetime: LessonDateCommonType[] = []; inputTimeItems.map((time) => { if ( time.date !== null && diff --git a/src/components/molecules/SelectAddress.tsx b/src/components/molecules/SelectAddress.tsx index 6e6a580..96153d9 100644 --- a/src/components/molecules/SelectAddress.tsx +++ b/src/components/molecules/SelectAddress.tsx @@ -21,10 +21,10 @@ export const SelectAddress: FC = ({ onChangeAddress }) => { }; const postCodeStyle = { - width: '360px', + width: '380px', height: '480px', - marginTop: '25px', - zIndex: '60px', + marginTop: '30px', + zIndex: 100, }; const handleOpenAddressPopup = () => { diff --git a/src/constants/hostMain.ts b/src/constants/hostMain.ts new file mode 100644 index 0000000..86ee4aa --- /dev/null +++ b/src/constants/hostMain.ts @@ -0,0 +1,17 @@ +export const InfoHost = [ + { + title: '호스트 등록', + desc: `간편한 방법으로\n호스트가 되어보세요.`, + image: '/images/openlesson1.gif', + }, + { + title: '클래스 개설 및 운영', + desc: '진행할 클래스를 등록하고 운영해보세요.', + image: '/images/openlesson2.gif', + }, + { + title: '정산 및 수익 관리', + desc: `매 수업마다 정산을 받을 수 있어요.\n하나펀에서 제공하는\n월별 수익 관리를 받아보세요.`, + image: '/images/openlesson3.gif', + }, +]; diff --git a/src/pages/main/HanaFunMain.tsx b/src/pages/main/HanaFunMain.tsx index 90b0224..8f2829c 100644 --- a/src/pages/main/HanaFunMain.tsx +++ b/src/pages/main/HanaFunMain.tsx @@ -12,7 +12,7 @@ import { AccountPwKeypad } from '../../components/organisms/AccountPwKeypad'; import { Slide } from '../../components/organisms/Slide'; import { QR } from '../../components/molecules/QR'; import { RiQrScan2Line } from 'react-icons/ri'; -import { getCookie, setCookie } from '../../utils/cookie'; +import { getCookie } from '../../utils/cookie'; import { useNavigate } from 'react-router-dom'; import { QRScanner } from '../../components/molecules/QRScanner'; import { useMutation, useQuery } from '@tanstack/react-query'; @@ -30,11 +30,6 @@ export const HanaFunMain = () => { const [isScan, setIsScan] = useState(false); const [active, setActive] = useState(null); - setCookie( - 'token', - 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiLsnbTrr7zsp4AiLCJ1c2VySWQiOjEsImlhdCI6MTcyMDA1MjI0MywiZXhwIjoxNzIwMTM4NjQzfQ.BJSSTGaXMZQo3F_66Xtso9k8LRVeBgNUnZif94vgLnU' - ); - const [selectedAccount, setSelectedAccount] = useState({ accountId: -1, accountName: '', diff --git a/src/pages/main/Home.tsx b/src/pages/main/Home.tsx deleted file mode 100644 index ea76d0f..0000000 --- a/src/pages/main/Home.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export const Home = () => { - return <>; -}; diff --git a/src/pages/main/QRPay.tsx b/src/pages/main/QRPay.tsx index 311e6e4..400b309 100644 --- a/src/pages/main/QRPay.tsx +++ b/src/pages/main/QRPay.tsx @@ -22,9 +22,6 @@ export const QRPay = () => { const [isBtnActive, setIsBtnActive] = useState(false); const [showLessonList, setShowLessonList] = useState(false); const [selectedLesson, setSelectedLesson] = useState(null); - const [showLessonDateList, setShowLessonDateList] = useState(false); - const [selectedLessonDate, setSelectedLessonDate] = - useState(null); const [money, setMoney] = useState(-1); const [isSend, setIsSend] = useState(false); @@ -44,12 +41,6 @@ export const QRPay = () => { checkValid(); }; - const onChangeLessonDate = (date: HostLessonDetailType) => { - setSelectedLessonDate(date); - setShowLessonDateList(false); - checkValid(); - }; - const onChangeMoney = (money: number) => { setMoney(money); }; @@ -59,7 +50,6 @@ export const QRPay = () => { userInfo.accountId && hostInfo?.data?.account.accountId && selectedLesson?.lessonId && - selectedLessonDate?.lessondateId && money > 0 && money <= userInfo.balance ) @@ -68,12 +58,11 @@ export const QRPay = () => { }; const handleSendPayment = () => { - if (hostInfo && hostInfo.data && selectedLesson && selectedLessonDate) { + if (hostInfo && hostInfo.data && selectedLesson) { postQrPay({ withdrawId: userInfo.accountId, depositId: hostInfo.data.account.accountId, lessonId: selectedLesson.lessonId, - lessondateId: selectedLessonDate.lessondateId, payment: money, }); } @@ -81,7 +70,7 @@ export const QRPay = () => { useEffect(() => { if (!getHostInfoLoading && !getHostInfoError) checkValid(); - }, [money, selectedLesson?.lessonId, selectedLessonDate?.lessondateId]); + }, [money, selectedLesson?.lessonId]); const { data: hostInfo, @@ -96,18 +85,6 @@ export const QRPay = () => { retry: 1, }); - const { data: hostLessonDetail } = useQuery({ - queryKey: ['hostLessonDetail', selectedLesson?.lessonId], - queryFn: async () => { - if (!selectedLesson || !selectedLesson.lessonId) return; - const response = await ApiClient.getInstance().getHostLessonDetailList( - selectedLesson.lessonId - ); - return response; - }, - enabled: !!selectedLesson && !!selectedLesson.lessonId, - }); - if (getHostInfoLoading) return ; if (getHostInfoError) { @@ -141,30 +118,6 @@ export const QRPay = () => { )} - {hostLessonDetail && showLessonDateList && ( - setShowLessonDateList(false)} - > -

클래스 일정을 선택해주세요.

-
-
-
- {hostLessonDetail.data?.map((date, idx) => ( -
-

onChangeLessonDate(date)} - > - {date.date} -

- {idx + 1 !== hostLessonDetail.data?.length &&
} -
- ))} -
-
-
- )} navigate('/')} /> {hostInfo && hostInfo.data && ( <> @@ -187,22 +140,7 @@ export const QRPay = () => { } openModal={() => setShowLessonList(true)} /> - {selectedLesson && ( - <> -

클래스 일정

- setShowLessonDateList(true)} - /> - - )} - { const navigate = useNavigate(); - const [isHost, setIsHost] = useState(true); + + const { data: isHostData } = useQuery({ + queryKey: ['isHost', getCookie('token')], + queryFn: () => { + const res = ApiClient.getInstance().getIsHost(); + return res; + }, + }); return ( <> @@ -55,7 +47,7 @@ export const OpenLessonMain = () => { 호스트가 되는 과정 - {infoHost.map((info, index) => ( + {InfoHost.map((info, index) => (
{index !== 1 ? (
@@ -93,7 +85,7 @@ export const OpenLessonMain = () => { isActive={true} message='클래스 개설하기' onClick={() => { - isHost + isHostData?.data?.isHost ? navigate('/open-lesson/lesson') : navigate('/open-lesson/host'); }} diff --git a/src/pages/openLesson/RegisterHost.tsx b/src/pages/openLesson/RegisterHost.tsx index 6337bf4..59069f2 100644 --- a/src/pages/openLesson/RegisterHost.tsx +++ b/src/pages/openLesson/RegisterHost.tsx @@ -4,6 +4,10 @@ import { Button } from '../../components/common/Button'; import { ChoiceAccount } from '../../components/organisms/ChoiceAccount'; import { useRef, useState } from 'react'; import { CompleteSend } from '../../components/organisms/CompleteSend'; +import { useMutation, useQuery } from '@tanstack/react-query'; +import { getCookie } from '../../utils/cookie'; +import { ApiClient } from '../../apis/apiClient'; +import { Loading } from '../Loading'; export const RegisterHost = () => { const navigate = useNavigate(); @@ -11,21 +15,43 @@ export const RegisterHost = () => { const [account, setAccount] = useState(null); const inputRef = useRef(null); + const { isLoading: isGetAccountList, data: accountList } = useQuery({ + queryKey: ['accountList', getCookie('token')], + queryFn: () => { + const res = ApiClient.getInstance().getAccountList(); + return res; + }, + }); + + const { mutate: createHost } = useMutation({ + mutationFn: (reqData: CreateHostReqType) => { + const res = ApiClient.getInstance().postCreateHost(reqData); + return res; + }, + onSuccess: (data) => { + if (data.isSuccess && data.data?.hostId) setIsSend(true); + }, + }); + const selectedAccountId = (account: AccountType) => { setAccount(account); }; const handleRegisterHost = () => { if (account && inputRef.current) { - console.log(account.accountId + ' ' + inputRef.current.value); - setIsSend(true); + createHost({ + accountId: account.accountId, + introduction: inputRef.current.value, + }); } }; + if (isGetAccountList) return ; + return ( <> navigate(-1)} /> - {!isSend ? ( + {accountList?.data && !isSend ? (
@@ -35,11 +61,11 @@ export const RegisterHost = () => {

입금계좌

- {/* */} + />

소개

diff --git a/src/pages/openLesson/RegisterLesson.tsx b/src/pages/openLesson/RegisterLesson.tsx index dd6a1c8..18cf737 100644 --- a/src/pages/openLesson/RegisterLesson.tsx +++ b/src/pages/openLesson/RegisterLesson.tsx @@ -11,23 +11,9 @@ import { AddLessonInput } from '../../components/molecules/AddLessonInput'; import { AddLessonMaterialList } from '../../components/molecules/AddLessonMaterialList'; import { AddLessonTimeList } from '../../components/molecules/AddLessonTimeList'; import { ChoiceInput } from '../../components/molecules/ChoiceInput'; - -export const categories = [ - '요리', - '여행', - '스포츠', - '예술', - '심리상담', - '재테크', - '자기계발', - '뷰티', -]; - -export type LessonTime = { - date: Date; - startTime: number; - endTime: number; -}; +import { useMutation, useQuery } from '@tanstack/react-query'; +import { ApiClient } from '../../apis/apiClient'; +import { ImageApiClient } from '../../apis/imageApiClient'; export const RegisterLesson = () => { const navigate = useNavigate(); @@ -35,35 +21,78 @@ export const RegisterLesson = () => { const [isSend, setIsSend] = useState(false); const [showModal, setShowModal] = useState(false); - const [uploadImageFile, setUploadImageFile] = useState(null); + const [file, setFile] = useState(); + const [uploadImageUrl, setUploadImageUrl] = useState(null); const inputTitle = useRef(null); - const [category, setCategory] = useState(''); + const [category, setCategory] = useState(); const [address, setAddress] = useState(''); const inputCapacity = useRef(null); const inputPrice = useRef(null); - const [lessonTime, setLessonTime] = useState([]); + const [lessonTime, setLessonTime] = useState([]); const [materials, setMaterials] = useState(''); const inputDetailInfo = useRef(null); + const { data: categories } = useQuery({ + queryKey: ['categories'], + queryFn: () => { + const res = ApiClient.getInstance().getCategoryList(); + return res; + }, + staleTime: 100000, + }); + + const { mutate: postImage } = useMutation({ + mutationFn: (formData: FormData) => { + const res = ImageApiClient.getImageInstance().postLessonImg(formData); + return res; + }, + onSuccess: (data) => { + if ( + category && + inputTitle.current?.value && + inputPrice.current?.value && + inputCapacity.current?.value && + inputDetailInfo.current?.value + ) { + postCreateLesson({ + categoryId: category?.categoryId, + title: inputTitle.current?.value, + location: address, + price: +inputPrice.current?.value, + capacity: +inputCapacity.current?.value, + image: data, + description: inputDetailInfo.current?.value, + materials: materials, + lessonDate: lessonTime, + }); + } + }, + }); + + const { mutate: postCreateLesson } = useMutation({ + mutationFn: (reqData: CreateLessonReqType) => { + const res = ApiClient.getInstance().postCreateLesson(reqData); + return res; + }, + onSuccess: () => setIsSend(true), + }); + const onChangeUploadImage = (e: ChangeEvent) => { if (e.target.files) { const file = e.target.files[0]; + setFile(file); const imageUrl = URL.createObjectURL(file); - setUploadImageFile(imageUrl); - // const formData = new FormData(); - // if (file) { - // formData.append('file', file); - // console.log('formData>>', formData); - // } + setUploadImageUrl(imageUrl); } }; - const onChangeCategory = (category: string) => { + const onChangeCategory = (category: CategoryType) => { setCategory(category); setShowModal(false); }; - const onChangeLessonTime = (lessontime: LessonTime[]) => { + const onChangeLessonTime = (lessontime: LessonDateCommonType[]) => { + console.log('aaa>', lessonTime); setLessonTime(lessontime); }; @@ -79,19 +108,19 @@ export const RegisterLesson = () => { const checkValid = () => { if ( - !uploadImageFile || + !file || inputTitle.current?.value === '' || - category === '' || + !category || inputCapacity.current?.value === '' || inputPrice.current?.value === '' || - lessonTime.length === 0 || + // lessonTime === 0 || address === '' || inputDetailInfo.current?.value === '' ) { setIsBtnActive(false); return; } - if (inputPrice.current && +inputPrice.current.value <= 0) { + if (inputPrice.current && +inputPrice.current.value < 0) { setIsBtnActive(false); return; } @@ -99,30 +128,24 @@ export const RegisterLesson = () => { setIsBtnActive(false); return; } - setIsBtnActive(true); }; const handlePostAddLesson = () => { - console.log('사진>>', uploadImageFile); - console.log('강좌명>>', inputTitle.current?.value); - console.log('카테고리>>', category); - console.log('모집인원>>', inputCapacity.current?.value); - console.log('가격>>', inputPrice.current?.value); - console.log('클래스 일정>>', lessonTime); - console.log('장소>>', address); - console.log('준비물>>', materials); - console.log('상세설명>>', inputDetailInfo.current?.value); - setIsSend(true); + if (file) { + const formData = new FormData(); + formData.append('file', file); + postImage(formData); + } }; useEffect(() => { checkValid(); - }, [uploadImageFile, category, lessonTime, materials, address]); + }, [file, category, lessonTime, materials, address]); return ( <> - {showModal && ( + {categories?.data && showModal && ( setShowModal(false)} @@ -131,15 +154,15 @@ export const RegisterLesson = () => {

- {categories.map((category, idx) => ( -
+ {categories?.data.map((category, idx) => ( +

onChangeCategory(category)} > - {category} + {category.categoryName}

- {idx !== categories.length - 1 &&
} + {idx + 1 !== categories.data?.length &&
}
))}
@@ -158,9 +181,9 @@ export const RegisterLesson = () => { className='hidden' />
diff --git a/src/pages/search/LessonDetail.tsx b/src/pages/search/LessonDetail.tsx index c23b34e..3127fa4 100644 --- a/src/pages/search/LessonDetail.tsx +++ b/src/pages/search/LessonDetail.tsx @@ -52,13 +52,18 @@ export const LessonDetail = () => { }; const splitMaterials = (materials: string) => { - setMaterials(materials.split(',').map((material) => material.trim())); + setMaterials( + materials + .split(',') + .filter((material) => material !== '') + .map((material) => material.trim()) + ); }; useEffect(() => { if (lesson?.data && lesson.data?.materials !== '') splitMaterials(lesson.data.materials); - }, []); + }, [lesson]); if (isGetLessonLoading || isGetLessonDateLoading) return ; diff --git a/src/pages/search/LessonSearch.tsx b/src/pages/search/LessonSearch.tsx index 36ad2c8..a77a817 100644 --- a/src/pages/search/LessonSearch.tsx +++ b/src/pages/search/LessonSearch.tsx @@ -10,37 +10,6 @@ import { ApiClient } from '../../apis/apiClient'; import { Loading } from '../Loading'; import { SortCategories, SortType } from '../../constants/sortList'; -export const Lessondata = [ - { - lesson_id: 5, - image: 'https://picsum.photos/200/200', - title: '맛있는 치즈케이크 만들기', - price: 60000, - host_name: '김헨리', - }, - { - lesson_id: 6, - image: 'https://picsum.photos/200/200', - title: '수제 캔들 만들기', - price: 30000, - host_name: '김하나', - }, - { - lesson_id: 7, - image: 'https://picsum.photos/200/200', - title: '클라이밍 배우기', - price: 30000, - host_name: '홍길동', - }, - { - lesson_id: 8, - image: 'https://picsum.photos/200/200', - title: '재미있는 재테크', - price: 30000, - host_name: '별돌이', - }, -]; - export const LessonSearch = () => { const navigate = useNavigate(); const [selectedCategory, setSelectedCategory] = useState(-1); diff --git a/src/types/host.d.ts b/src/types/host.d.ts index 8fddec5..08a9543 100644 --- a/src/types/host.d.ts +++ b/src/types/host.d.ts @@ -1,16 +1,13 @@ -import { AccountType } from './account'; -import { LessonType } from './lesson'; - -type CreateHostReqType = { +interface CreateHostReqType { accountId: number; introduction: string; -}; +} -type CreateHostResType = { +interface CreateHostResType { hostId: number; -}; +} -type HostInfoType = { +interface HostInfoType { account: AccountType; lessonList: LessonType[]; -}; +} diff --git a/src/types/lesson.d.ts b/src/types/lesson.d.ts index 8aa4a28..870b642 100644 --- a/src/types/lesson.d.ts +++ b/src/types/lesson.d.ts @@ -3,11 +3,14 @@ interface LessonType { title: string; } -interface LessonDateType { - lessondateId: number; +interface LessonDateCommonType { date: Date; startTime: Date; endTime: Date; +} + +interface LessonDateType extends LessonDateCommonType { + lessondateId: number; quantityLeft: number; } @@ -22,3 +25,15 @@ interface LessonDetailType { capacity: number; categoryName: string; } + +interface CreateLessonReqType { + categoryId: number; + title: string; + location: string; + price: number; + capacity: number; + image: string; + description: string; + materials: string; + lessonDate: LessonDateCommonType[]; +} diff --git a/src/types/transaction.d.ts b/src/types/transaction.d.ts index e0c1281..d9b9d53 100644 --- a/src/types/transaction.d.ts +++ b/src/types/transaction.d.ts @@ -1,6 +1,5 @@ interface PayCommonReqType { withdrawId: number; - lessondateId: number; payment: number; } @@ -10,13 +9,14 @@ interface QrPayReqType extends PayCommonReqType { } interface SimplePayReqType extends PayCommonReqType { + lessondateId: number; reservationId: number; point: number; } interface PayResType { transactionId: number; -}; +} interface PaybackReqType { reservationId: number;