generated from pricelees/issue-pr-template
refactor: 예약 페이지에서의 프론트엔드 지역 선택 오류 해결 및 홈페이지 인기 테마 API 처리 로직 수정
This commit is contained in:
parent
48ef315f14
commit
475c1da119
@ -1,6 +1,12 @@
|
||||
import apiClient from "@_api/apiClient";
|
||||
import type { AdminScheduleSummaryListResponse, ScheduleCreateRequest, ScheduleCreateResponse, ScheduleStatus, ScheduleUpdateRequest, ScheduleWithThemeListResponse } from "./scheduleTypes";
|
||||
import type { AuditInfo } from "@_api/common/commonTypes";
|
||||
import type {AuditInfo} from "@_api/common/commonTypes";
|
||||
import type {
|
||||
AdminScheduleSummaryListResponse,
|
||||
ScheduleCreateRequest,
|
||||
ScheduleCreateResponse,
|
||||
ScheduleUpdateRequest,
|
||||
ScheduleWithThemeListResponse
|
||||
} from "./scheduleTypes";
|
||||
|
||||
// admin
|
||||
export const fetchAdminSchedules = async (storeId: string, date?: string, themeId?: string): Promise<AdminScheduleSummaryListResponse> => {
|
||||
|
||||
@ -12,11 +12,11 @@ export const getStores = async (sidoCode?: string, sigunguCode?: string): Promis
|
||||
const queryParams: string[] = [];
|
||||
|
||||
if (sidoCode && sidoCode.trim() !== '') {
|
||||
queryParams.push(`sidoCode=${sidoCode}`);
|
||||
queryParams.push(`sido=${sidoCode}`);
|
||||
}
|
||||
|
||||
if (sigunguCode && sigunguCode.trim() !== '') {
|
||||
queryParams.push(`sigunguCode=${sigunguCode}`);
|
||||
queryParams.push(`sigungu=${sigunguCode}`);
|
||||
}
|
||||
|
||||
const baseUrl = `/stores`;
|
||||
|
||||
@ -42,3 +42,7 @@ export const fetchThemesByIds = async (request: ThemeIdListResponse): Promise<Th
|
||||
export const fetchThemeById = async (id: string): Promise<ThemeInfoResponse> => {
|
||||
return await apiClient.get<ThemeInfoResponse>(`/themes/${id}`);
|
||||
}
|
||||
|
||||
export const fetchMostReservedThemes = async (count: number): Promise<ThemeInfoListResponse> => {
|
||||
return await apiClient.get<ThemeInfoListResponse>(`/themes/most-reserved?count=${count}`);
|
||||
};
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import {fetchMostReservedThemeIds} from '@_api/reservation/reservationAPI';
|
||||
import '@_css/home-page-v2.css';
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import {useNavigate} from 'react-router-dom';
|
||||
import {fetchThemesByIds} from '@_api/theme/themeAPI';
|
||||
import {fetchMostReservedThemes} from '@_api/theme/themeAPI';
|
||||
import {DifficultyKoreanMap, mapThemeResponse, type ThemeInfoResponse} from '@_api/theme/themeTypes';
|
||||
|
||||
const HomePage: React.FC = () => {
|
||||
@ -13,19 +12,8 @@ const HomePage: React.FC = () => {
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const themeIds = await fetchMostReservedThemeIds().then(res => {
|
||||
const themeIds = res.themeIds;
|
||||
if (themeIds.length === 0) {
|
||||
setRanking([]);
|
||||
return;
|
||||
}
|
||||
return themeIds;
|
||||
})
|
||||
|
||||
if (themeIds === undefined) return;
|
||||
if (themeIds.length === 0) return;
|
||||
|
||||
const response = await fetchThemesByIds({ themeIds: themeIds });
|
||||
const themeFetchCount = 10;
|
||||
const response = await fetchMostReservedThemes(themeFetchCount);
|
||||
setRanking(response.themes.map(mapThemeResponse));
|
||||
} catch (err) {
|
||||
console.error('Error fetching ranking:', err);
|
||||
|
||||
@ -60,9 +60,13 @@ const ReservationStep1Page: React.FC = () => {
|
||||
}, [selectedSido]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedSido) {
|
||||
getStores(selectedSido, selectedSigungu)
|
||||
.then(res => setStoreList(res.stores))
|
||||
.catch(handleError);
|
||||
} else {
|
||||
setStoreList([]);
|
||||
}
|
||||
setSelectedStore(null);
|
||||
}, [selectedSido, selectedSigungu]);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user