Skip to content

Commit bbff552

Browse files
authored
Merge pull request #159 from kakao-tech-campus-3rd-step3/fix/club-apply-button-path#158
[FIX] clubId 가 string이지 못하게 교정 (#158)
2 parents 0f13a9d + ac446b9 commit bbff552

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

src/mocks/repositories/club.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export const clubs: Club[] = [
239239

240240
export const mockClubDetail: ClubDetail[] = [
241241
{
242-
id: 1,
242+
clubId: 1,
243243
clubName: '인터엑스',
244244
location: '공7 201호',
245245
category: '사회연구',
@@ -268,7 +268,7 @@ export const mockClubDetail: ClubDetail[] = [
268268
applicationNotice: '현재 지원은 휴학생을 제외한 1~3학년만 받고 있습니다.',
269269
},
270270
{
271-
id: 2,
271+
clubId: 2,
272272
clubName: '코드마스터',
273273
location: '공5 102호',
274274
category: '프로그래밍',
@@ -296,7 +296,7 @@ export const mockClubDetail: ClubDetail[] = [
296296
applicationNotice: '1~4학년 모두 지원 가능합니다.',
297297
},
298298
{
299-
id: 3,
299+
clubId: 3,
300300
clubName: '아트픽',
301301
location: '예술관 301호',
302302
category: '예술',
@@ -332,11 +332,11 @@ export const clubRepository = {
332332
},
333333

334334
getClubDetailById: (id: number) => {
335-
return mockClubDetail.find((club) => club.id === id);
335+
return mockClubDetail.find((club) => club.clubId === id);
336336
},
337337

338338
updateClubDetail: (id: number, updatedData: Partial<ClubDetail>) => {
339-
const index = mockClubDetail.findIndex((club) => club.id === id);
339+
const index = mockClubDetail.findIndex((club) => club.clubId === id);
340340
if (index === -1) return;
341341

342342
mockClubDetail[index] = {

src/pages/user/ClubDetail/Page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ import type { ClubDetail } from './types/clubDetail';
1515

1616
export const ClubDetailPage = () => {
1717
const { clubId } = useParams<{ clubId: string }>();
18+
const clubIdNumber = Number(clubId);
1819
const [club, setClub] = useState<ClubDetail | null>(null);
1920

2021
useEffect(() => {
21-
if (!clubId) return;
22-
fetchClubDetail(clubId).then(setClub).catch(console.error);
23-
}, [clubId]);
22+
if (!clubIdNumber) return;
23+
fetchClubDetail(clubIdNumber).then(setClub).catch(console.error);
24+
}, [clubIdNumber]);
2425

2526
if (!club) return <div>Loading...</div>;
2627

@@ -46,7 +47,7 @@ export const ClubDetailPage = () => {
4647
regularMeetingInfo={club.regularMeetingInfo}
4748
recruitStatus={club.recruitStatus}
4849
applicationNotice={club.applicationNotice}
49-
clubId={club.id}
50+
clubId={club.clubId}
5051
/>
5152
</ContentRight>
5253
</Layout>
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import type { ClubDetail } from '../types/clubDetail';
22

3-
export const fetchClubDetail = async (clubId: string | number): Promise<ClubDetail> => {
4-
const url = `/api/clubs/${clubId}`;
5-
const response = await fetch(url);
3+
const BASE_URL = import.meta.env.VITE_API_BASE_URL;
64

7-
if (!response.ok) {
8-
throw new Error('동아리 상세 정보를 가져오는데 실패했습니다.');
9-
}
10-
return response.json() as Promise<ClubDetail>;
5+
export const fetchClubDetail = async (clubId: number): Promise<ClubDetail> => {
6+
const res = await fetch(`${BASE_URL}/clubs/${clubId}`);
7+
if (!res.ok) throw new Error('동아리 상세 정보를 가져오는데 실패했습니다.');
8+
return res.json() as Promise<ClubDetail>;
119
};

src/pages/user/ClubDetail/components/ClubInfoSidebarSection/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ClubDetail } from '@/pages/user/ClubDetail/types/clubDetail';
55

66
type ClubInfoSidebarSectionProps = Pick<
77
ClubDetail,
8+
| 'clubId'
89
| 'presidentName'
910
| 'presidentPhoneNumber'
1011
| 'location'
@@ -13,11 +14,10 @@ type ClubInfoSidebarSectionProps = Pick<
1314
| 'regularMeetingInfo'
1415
| 'recruitStatus'
1516
| 'applicationNotice'
16-
> & {
17-
clubId: number | string;
18-
};
17+
>;
1918

2019
export const ClubInfoSidebarSection = ({
20+
clubId,
2121
presidentName,
2222
presidentPhoneNumber,
2323
location,
@@ -26,7 +26,6 @@ export const ClubInfoSidebarSection = ({
2626
regularMeetingInfo,
2727
recruitStatus,
2828
applicationNotice,
29-
clubId,
3029
}: ClubInfoSidebarSectionProps) => {
3130
return (
3231
<SidebarContainer>

src/pages/user/ClubDetail/types/clubDetail.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export type RecruitStatus = '모집중' | '모집 준비중' | '모집 종료';
22

33
export type ClubDetail = {
4-
id: number;
4+
clubId: number;
55
clubName: string;
66
location: string;
77
category: string;

0 commit comments

Comments
 (0)