Skip to content

Commit

Permalink
Merge pull request #109 from prgrms-fe-devcourse/108-bug/api-type-dis…
Browse files Browse the repository at this point in the history
…match

108 bug/api type dismatch
  • Loading branch information
shlee9999 authored Sep 30, 2024
2 parents 2d1aeae + 179ab81 commit 00cb2af
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/hooks/useAward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import getApiUrl from '@/utils/getApiUrl';
*
* @param {AwardRequestType} params - 수상작 목록 조회에 필요한 요청 매개변수입니다.
* @returns {{ data: AwardResponseType | undefined, isLoading: boolean }} - 수상작 목록 데이터와 로딩 상태를 반환합니다.
* @example
* const { data } = useAward({ cpage: 1, eddate: '20241201', rows: 10, stdate: '20240901' });
*/
export default function useAward(params: AwardRequestType) {
const url = getApiUrl<AwardRequestType>('prfawad', params);
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useBoxOffice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import getApiUrl from '@/utils/getApiUrl';
*
* @param {BoxOfficeRequestType} params - 예매 상황판 조회에 필요한 요청 매개변수입니다.
* @returns {{ data: BoxOfficeResponseType | undefined, isLoading: boolean }} - 예매 상황판 데이터와 로딩 상태를 반환합니다.
* @example
* const { data } = useBoxOffice({ date: '20240101', ststype: 'month', area: 11 });
*/
export default function useBoxOffice(params: BoxOfficeRequestType) {
const url = getApiUrl<BoxOfficeRequestType>('boxoffice', params);
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useFacilityDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import getApiUrl from '@/utils/getApiUrl';
*
* @param {FacilityDetailRequestType} params - 공연 시설 상세 조회에 필요한 요청 매개변수입니다.
* @returns {{ data: FacilityDetailResponseType | undefined, isLoading: boolean }} - 공연 시설 상세 데이터와 로딩 상태를 반환합니다.
* @example
* const { data } = useFacilityDetail({ mt10id: 'FC001247' });
*/
export default function useFacilityDetail(params: FacilityDetailRequestType) {
const url = getApiUrl<FacilityDetailRequestType>('prfplc', params);
const url = getApiUrl<FacilityDetailRequestType>(`prfplc/${params.mt10id}`); //* api url 구조 다르게 생김 주의
const { data, isLoading } = useFetch<FacilityDetailResponseType>(url);
return { data, isLoading };
}
4 changes: 3 additions & 1 deletion src/hooks/usePDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import getApiUrl from '@/utils/getApiUrl';
*
* @param {PDetailRequestType} params - 공연 상세 조회에 필요한 요청 매개변수입니다.
* @returns {{ data: PDetailResponseType | undefined, isLoading: boolean }} - 공연 상세 데이터와 로딩 상태를 반환합니다.
* @example
* const { data } = usePDetail({ mt20id: 'PF132236' });
*/
export default function usePDetail(params: PDetailRequestType) {
const url = getApiUrl<PDetailRequestType>('pblprfr', params);
const url = getApiUrl<PDetailRequestType>(`pblprfr/${params.mt20id}`);
const { data, isLoading } = useFetch<PDetailResponseType>(url);
return { data, isLoading };
}
2 changes: 2 additions & 0 deletions src/hooks/usePList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import getApiUrl from '@/utils/getApiUrl';
*
* @param {PListRequestType} params - 공연 목록 조회에 필요한 요청 매개변수입니다.
* @returns {{ data: PListResponseType | undefined, isLoading: boolean }} - 공연 목록 데이터와 로딩 상태를 반환합니다.
* @example
* const { data } = usePList({ cpage: 1, eddate: '20241201', rows: 10, stdate: '20241101' });
*/
export default function usePList(params: PListRequestType) {
const url = getApiUrl<PListRequestType>('pblprfr', params);
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/usePStatistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import getApiUrl from '@/utils/getApiUrl';
*
* @param {PStatisticsRequestType} params - 공연별 통계 목록 조회에 필요한 요청 매개변수입니다.
* @returns {{ data: PStatisticsResponseType | undefined, isLoading: boolean }} - 공연별 통계 데이터와 로딩 상태를 반환합니다.
* @example
* const { data } = usePStatistics({ cpage: 1, eddate: '20240901', rows: 10, stdate: '20240505' });
*/
export default function usePStatistics(params: PStatisticsRequestType) {
const url = getApiUrl<PStatisticsRequestType>('prfstsPrfBy', params);
Expand Down
28 changes: 16 additions & 12 deletions src/types/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export type CommonRequestType = {
* 요청구분
* @example "month", "week", "day"
*/
ststype?: string;
ststype?: 'month' | 'week' | 'day';
/**
* 기준일
* @example "20230101"
Expand All @@ -75,7 +75,7 @@ export type CommonRequestType = {
* 지역코드
* @example "11"
*/
area?: string;
area?: number;
/**
* 좌석수코드
* @example 0(미상), 100(1~300석 미만), 300(300~500석 미만), 500(500~1000석 미만), 1000(1000~5000석 미만), 5000(5000~10000석 미만), 10000(10000석 이상)
Expand Down Expand Up @@ -553,8 +553,8 @@ export type PListResponseType = {
db: Pick<
Db,
'mt20id' | 'prfnm' | 'genrenm' | 'prfstate' | 'prfpdfrom' | 'prfpdto' | 'poster' | 'fcltynm' | 'openrun' | 'area'
>;
}[];
>[];
};
};

//* 2. 공연상세조회서비스
Expand Down Expand Up @@ -592,7 +592,7 @@ export type PDetailResponseType = {
| 'styurls'
| 'dtguidance'
>;
}[];
};
};

//* 4. 공연시설상세조회서비스
Expand Down Expand Up @@ -623,7 +623,7 @@ export type FacilityDetailResponseType = {
| 'elevbarrier'
| 'parkinglot'
>;
}[];
};
};

//* 6. 예매상황판조회서비스
Expand All @@ -633,14 +633,16 @@ export type BoxOfficeResponseType = {
boxofs?: {
basedate: string;
boxof: Boxof[];
}[];
};
};

//* 15. 공연별통계목록조회서비스
export type PStatisticsRequestType = Required<Pick<CommonRequestType, 'cpage' | 'rows' | 'stdate' | 'eddate'>> &
Partial<Pick<CommonRequestType, 'shcate' | 'shprfnm'>>;
export type PStatisticsResponseType = {
prfst?: Pick<Prfst, 'prfnm' | 'cate' | 'mt20id' | 'fcltynm' | 'entrpsnm' | 'prfpdfrom' | 'prfpdto' | 'prfdtcnt'>[];
prfsts?: {
prfst: Pick<Prfst, 'prfnm' | 'cate' | 'mt20id' | 'fcltynm' | 'entrpsnm' | 'prfpdfrom' | 'prfpdto' | 'prfdtcnt'>[];
};
};

//* 18. 수상작목록조회서비스
Expand All @@ -652,8 +654,10 @@ export type AwardRequestType = Required<Pick<CommonRequestType, 'stdate' | 'edda
>
>;
export type AwardResponseType = {
db?: Pick<
Db,
'mt20id' | 'prfnm' | 'prfpdfrom' | 'prfpdto' | 'fcltynm' | 'poster' | 'genrenm' | 'prfstate' | 'awards'
>;
dbs?: {
db: Pick<
Db,
'mt20id' | 'prfnm' | 'prfpdfrom' | 'prfpdto' | 'fcltynm' | 'poster' | 'genrenm' | 'prfstate' | 'awards'
>[];
};
};

0 comments on commit 00cb2af

Please sign in to comment.