Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions apps/audience/src/entities/festival/api/festival.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,15 @@ import type {
WishListResponseData,
} from '@shared/types/festival';
import type {
AllFestivalsResponse,
NicknameResponse,
FestivalsResponse,
UpcomingFestivalResponse,
UpcomingFestivalsResponse,
} from '@shared/types/home-response';
Comment on lines +10 to 12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Suggest: FestivalsResponsehome-response 밖으로 분리해 주세요.

getAllFestivalsgetWishlists는 공용 festival entity API인데, 응답 타입이 @shared/types/home-response에 머물면 home이라는 페이지 의미가 entity 레이어로 스며듭니다. 이번처럼 재사용 범위가 넓어진 타입은 festival 전용 응답 타입 파일로 옮기거나 API 근처로 이동하는 편이 의존성 방향이 더 자연스럽습니다.

As per coding guidelines apps/**/src/entities/**: Entity 레이어예요. - 단일 도메인 개념을 표현해요. - 페이지/라우트 개념은 금지예요.

Also applies to: 15-18

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/audience/src/entities/festival/api/festival.ts` around lines 10 - 12,
The FestivalsResponse and UpcomingFestivalResponse types currently imported from
`@shared/types/home-response` bleed page-specific semantics into the festival
entity API; create a festival-specific response types file (e.g.,
festival-response.ts) next to the festival entity/API, move/define
FestivalsResponse and UpcomingFestivalResponse there, update imports in
functions like getAllFestivals and getWishlists to import from the new
festival-response module, and remove the dependency on
`@shared/types/home-response` so the entity layer no longer depends on a
page-scoped module.


export const getAllFestivals = (params: PageSizeParams = {}) =>
get<AllFestivalsResponse, PageSizeParams>(
END_POINT.GET_ALL_FESTIVALS,
params,
);
get<FestivalsResponse, PageSizeParams>(END_POINT.GET_ALL_FESTIVALS, params);

export const getPlannedFestivals = (params: PageSizeParams = {}) =>
get<UpcomingFestivalsResponse, PageSizeParams>(
END_POINT.GET_PLANNED_FESTIVALS,
params,
);
export const getWishlists = (params: PageSizeParams = {}) =>
get<FestivalsResponse, PageSizeParams>(END_POINT.GET_WISHLISTS, params);

export const getUpcomingFestival = (params: PageSizeParams = {}) =>
get<UpcomingFestivalResponse, PageSizeParams>(
Expand All @@ -36,6 +28,3 @@ export const putWishList = (festivalId: number, body: WishListRequest) =>
END_POINT.PUT_WISH_LIST(festivalId),
body,
);

export const getUserNickname = () =>
get<NicknameResponse>(END_POINT.GET_NICKNAME);
10 changes: 2 additions & 8 deletions apps/audience/src/entities/festival/model/query-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { USERS_QUERY_KEY } from '@shared/constants/query-key';

import {
getAllFestivals,
getPlannedFestivals,
getUpcomingFestival,
getUserNickname,
getWishlists,
} from '../api/festival';

export const FESTIVAL_QUERY_OPTIONS = {
Expand All @@ -20,16 +19,11 @@ export const FESTIVAL_QUERY_OPTIONS = {
PLANNED_FESTIVALS: (params: PageSizeParams = { page: 0, size: 20 }) =>
queryOptions({
queryKey: [...USERS_QUERY_KEY.HOME_FESTIVALS_PLANNED(), params],
queryFn: () => getPlannedFestivals(params),
queryFn: () => getWishlists(params),
}),
UPCOMING_FESTIVAL: (params: PageSizeParams = {}) =>
queryOptions({
queryKey: [...USERS_QUERY_KEY.HOME_FESTIVAL_UPCOMING(), params],
queryFn: () => getUpcomingFestival(params),
}),
NICKNAME: () =>
queryOptions({
queryKey: [...USERS_QUERY_KEY.NICKNAME()],
queryFn: () => getUserNickname(),
}),
} as const;
19 changes: 0 additions & 19 deletions apps/audience/src/features/my-events/query.ts

This file was deleted.

18 changes: 14 additions & 4 deletions apps/audience/src/pages/home/home.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
import { useQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router';

import { HomeBanner } from '@amp/compositions';

import FestivalSection from '@widgets/home/components/festival-section/festival-section';

import { FESTIVAL_QUERY_OPTIONS } from '@entities/festival/model/query-options';
import { USER_QUERY_OPTIONS } from '@entities/user/model/query-options';

import { ROUTE } from '@shared/constants/path';

import useHomeFestivals from './model/use-home-festivals';

import { page } from './home.css';

const HomePage = () => {
const navigate = useNavigate();

const { data } = useQuery({
...FESTIVAL_QUERY_OPTIONS.NICKNAME(),
...USER_QUERY_OPTIONS.NICKNAME(),
});
const nickname = data?.nickname;

const {
allFestivals,
upcomingFestivals,
plannedFestivals,
bannerFestival,
selectedTab,
setSelectedTab,
} = useHomeFestivals();

const handleCardClick = (festivalId: number) => {
navigate(ROUTE.noticeList(festivalId));
};

return (
<div className={page}>
{bannerFestival ? (
Expand All @@ -43,7 +52,8 @@ const HomePage = () => {
selectedTab={selectedTab}
onTabChange={setSelectedTab}
allFestivals={allFestivals}
upcomingFestivals={upcomingFestivals}
plannedFestivals={plannedFestivals}
onCardClick={handleCardClick}
/>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions apps/audience/src/pages/home/model/use-home-festivals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ const useHomeFestivals = () => {

return {
allFestivals: allFestivalsData?.festivals ?? [],
upcomingFestivals: plannedFestivalsData?.festivals ?? [],
plannedFestivals: plannedFestivalsData?.festivals ?? [],
bannerFestival: upcomingFestivalData
? {
festivalId: upcomingFestivalData.festivalId,
title: upcomingFestivalData.title,
mainImageUrl: upcomingFestivalData.mainImageUrl,
location: upcomingFestivalData.location,
period: `${upcomingFestivalData.startDate} ~ ${upcomingFestivalData.endDate}`,
dDay: upcomingFestivalData.dday,
dDay: upcomingFestivalData.dDay,
}
: undefined,
selectedTab,
Expand Down
29 changes: 21 additions & 8 deletions apps/audience/src/pages/my-events/my-events.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
import { useQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router';

import { EmptyView } from '@amp/ads-ui';
import { Loading } from '@amp/compositions';

import FestivalList from '@widgets/my-events/festival-list';
import FestivalCard from '@widgets/home/components/festival-card/festival-card';

import { MY_EVENTS_QUERY_OPTIONS } from '@features/my-events/query';
import { MY_PAGE_QUERY_OPTIONS } from '@features/mypage/apis/query';

import { ROUTE } from '@shared/constants/path';

import * as styles from './my-events.css';

const MyEventsPage = () => {
const { data: viewedData } = useQuery(
const navigate = useNavigate();
const { data: viewedData, isPending } = useQuery(
MY_PAGE_QUERY_OPTIONS.VIEWED_FESTIVALS(),
);
const { data, isPending } = useQuery(
MY_EVENTS_QUERY_OPTIONS.LIST({ page: 0, size: 20 }),
);

const festivals = viewedData?.festivals ?? [];

const handleCardClick = (festivalId: number) => {
navigate(ROUTE.noticeList(festivalId));
};

if (isPending) {
return <Loading />;
}

if (!data || festivals.length === 0) {
if (!viewedData || festivals.length === 0) {
return (
<section className={styles.page}>
<div className={styles.empty}>
Expand All @@ -37,7 +41,16 @@ const MyEventsPage = () => {
return (
<section className={styles.page}>
<div className={styles.list}>
<FestivalList festivals={festivals} />
{festivals.map((festival) => {
return (
<FestivalCard
key={festival.festivalId}
festival={festival}
showWishList={false}
onCardClick={handleCardClick}
/>
);
})}
</div>
</section>
);
Expand Down
4 changes: 1 addition & 3 deletions apps/audience/src/shared/constants/end-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export const END_POINT = {
POST_FCM_TOKEN: '/notifications/fcm-token', // FCM 토큰 기기 동기화

// WishList
//TODO: 하나로 합치기
GET_MY_FESTIVALS_ALL: '/wishlists', // 홈 화면 관람 예정 공연 리스트
GET_PLANNED_FESTIVALS: '/wishlists', // 홈 화면 관람 예정 공연 리스트
GET_WISHLISTS: '/wishlists', // 홈 화면 관람 예정 공연 리스트
GET_VIEWED_FESTIVALS: '/wishlists/all', // 마이페이지 관람 공연 전체 조회
GET_UPCOMING_FESTIVAL: '/wishlists/recent', // 가장 임박한 관람 예정 공연 조회
PUT_WISH_LIST: (festivalId: number) => `/wishlists/${festivalId}`, // 관람 예정 공연 등록 / 해제
Expand Down
8 changes: 8 additions & 0 deletions apps/audience/src/shared/constants/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ export const ROUTE_PATH = {
NOTICE_EDIT: '/events/:eventId/notices/:noticeId/edit',
NOT_FOUND: '/not-found',
} as const;

export const ROUTE = {
noticeList: (eventId: number) => `/events/${eventId}/notices`,
noticeDetails: (eventId: number, noticeId: number) =>
`/events/${eventId}/notices/${noticeId}`,
noticeEdit: (eventId: number, noticeId: number) =>
`/events/${eventId}/notices/${noticeId}/edit`,
};
21 changes: 21 additions & 0 deletions apps/audience/src/shared/types/festival.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
export type FestivalStatus = '관람 중' | '관람 예정' | '관람 완료';

export interface Festival {
festivalId: number;
title: string;
mainImageUrl: string;
period: string;
status: FestivalStatus;
wishList: boolean;
dDay?: number;
}

export interface PaginationResponse {
currentPage: number;
totalPages: number;
totalElements: number;
size: number;
hasNext: boolean;
hasPrevious: boolean;
}

export interface WishListRequest {
wishList: boolean;
}
Expand Down
41 changes: 4 additions & 37 deletions apps/audience/src/shared/types/home-response.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,7 @@
export interface AllFestivalItem {
festivalId: number;
title: string;
mainImageUrl: string;
location: string;
period: string;
wishList: boolean;
dDay: number;
}
import type { Festival, PaginationResponse } from './festival';

export interface UpcomingFestivalItem {
festivalId: number;
title: string;
mainImageUrl: string;
location: string;
period: string;
status: string;
wishList: boolean;
dDay: number;
}

export interface PaginationResponse {
currentPage: number;
totalPages: number;
totalElements: number;
size: number;
hasNext: boolean;
hasPrevious: boolean;
}

export interface AllFestivalsResponse {
festivals: AllFestivalItem[];
pagination: PaginationResponse;
}

export interface UpcomingFestivalsResponse {
festivals: UpcomingFestivalItem[];
export interface FestivalsResponse {
festivals: Festival[];
pagination: PaginationResponse;
}

Expand All @@ -45,7 +12,7 @@ export interface UpcomingFestivalResponse {
location: string;
startDate: string;
endDate: string;
dday: number;
dDay: number;
}

export interface NicknameResponse {
Expand Down
22 changes: 0 additions & 22 deletions apps/audience/src/shared/types/my-events-response.ts

This file was deleted.

23 changes: 3 additions & 20 deletions apps/audience/src/shared/types/viewed-festival.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
export interface ViewedFestival {
festivalId: number;
title: string;
mainImageUrl: string;
period: string;
status: '관람 중' | '관람 예정' | '관람 완료';
wishList: boolean;
}

export interface Pagination {
currentPage: number;
totalPages: number;
totalElements: number;
size: number;
hasNext: boolean;
hasPrevious: boolean;
}

import type { Festival, PaginationResponse } from './festival';
export interface ViewedFestivalsResponse {
festivals: ViewedFestival[];
pagination: Pagination;
festivals: Festival[];
pagination: PaginationResponse;
}
Loading
Loading