Skip to content

Commit 9558738

Browse files
authored
Merge pull request #971 from Moadong/feature/#970-admin-edit-api-fix-MOA-460
[feature] 관리자페이지 기본정보 및 소개정보 수정 api 연동
2 parents 44227fd + cc6bdd1 commit 9558738

File tree

4 files changed

+44
-46
lines changed

4 files changed

+44
-46
lines changed

frontend/src/constants/eventName.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export const ADMIN_EVENT = {
4545
FORGOT_PASSWORD_BUTTON_CLICKED: '비밀번호 찾기 버튼클릭',
4646

4747
// 사이드바
48+
CLUB_COVER_UPLOAD_BUTTON_CLICKED: '동아리 커버 업로드 버튼클릭',
49+
CLUB_COVER_RESET_BUTTON_CLICKED: '동아리 커버 초기화 버튼클릭',
4850
CLUB_LOGO_UPLOAD_BUTTON_CLICKED: '동아리 로고 업로드 버튼클릭',
4951
CLUB_LOGO_EDIT_BUTTON_CLICKED: '동아리 로고 수정 버튼클릭',
5052
CLUB_LOGO_RESET_BUTTON_CLICKED: '동아리 로고 초기화 버튼클릭',

frontend/src/pages/AdminPage/components/ClubCoverEditor/ClubCoverEditor.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import defaultCover from '@/assets/images/logos/default_profile_image.svg';
33
import { ADMIN_EVENT } from '@/constants/eventName';
44
import { MAX_FILE_SIZE } from '@/constants/uploadLimit';
55
import { useAdminClubContext } from '@/context/AdminClubContext';
6+
import {
7+
useDeleteCover,
8+
useUploadCover,
9+
} from '@/hooks/queries/club/cover/useCoverMutation';
610
import useMixpanelTrack from '@/hooks/useMixpanelTrack';
711
import * as Styled from './ClubCoverEditor.styles';
812

@@ -17,12 +21,13 @@ const ClubCoverEditor = ({ coverImage }: ClubCoverEditorProps) => {
1721

1822
if (!clubId) return null;
1923

20-
// TODO: useCoverMutation 추가 예정
21-
// const uploadMutation = useUploadCover();
22-
// const deleteMutation = useDeleteCover();
24+
const uploadMutation = useUploadCover();
25+
const deleteMutation = useDeleteCover();
2326

2427
const isCoverImageEmpty = !coverImage?.trim();
25-
const displayedCover = isCoverImageEmpty ? defaultCover : coverImage;
28+
const displayedCover: string = isCoverImageEmpty
29+
? defaultCover
30+
: (coverImage ?? defaultCover);
2631

2732
const handleFileSelect = (e: React.ChangeEvent<HTMLInputElement>) => {
2833
const file = e.target.files?.[0];
@@ -36,9 +41,8 @@ const ClubCoverEditor = ({ coverImage }: ClubCoverEditorProps) => {
3641
return;
3742
}
3843

39-
trackEvent(ADMIN_EVENT.CLUB_LOGO_UPLOAD_BUTTON_CLICKED);
40-
// TODO: uploadMutation.mutate({ clubId, file });
41-
console.log('Cover image upload:', file);
44+
trackEvent(ADMIN_EVENT.CLUB_COVER_UPLOAD_BUTTON_CLICKED);
45+
uploadMutation.mutate({ clubId, file });
4246
};
4347

4448
const triggerFileInput = () => {
@@ -54,9 +58,8 @@ const ClubCoverEditor = ({ coverImage }: ClubCoverEditorProps) => {
5458

5559
if (!window.confirm('정말 커버 이미지를 기본 이미지로 되돌릴까요?')) return;
5660

57-
trackEvent(ADMIN_EVENT.CLUB_LOGO_RESET_BUTTON_CLICKED);
58-
// TODO: deleteMutation.mutate(clubId);
59-
console.log('Cover image delete');
61+
trackEvent(ADMIN_EVENT.CLUB_COVER_RESET_BUTTON_CLICKED);
62+
deleteMutation.mutate(clubId);
6063
};
6164

6265
return (

frontend/src/pages/AdminPage/tabs/ClubInfoEditTab/ClubInfoEditTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { SNS_CONFIG } from '@/constants/snsConfig';
88
import { useUpdateClubDetail } from '@/hooks/queries/club/useUpdateClubDetail';
99
import useMixpanelTrack from '@/hooks/useMixpanelTrack';
1010
import useTrackPageView from '@/hooks/useTrackPageView';
11-
import ClubLogoEditor from '@/pages/AdminPage/components/ClubLogoEditor/ClubLogoEditor';
1211
import ClubCoverEditor from '@/pages/AdminPage/components/ClubCoverEditor/ClubCoverEditor';
12+
import ClubLogoEditor from '@/pages/AdminPage/components/ClubLogoEditor/ClubLogoEditor';
1313
import { ContentSection } from '@/pages/AdminPage/components/ContentSection/ContentSection';
1414
import MakeTags from '@/pages/AdminPage/tabs/ClubInfoEditTab/components/MakeTags/MakeTags';
1515
import SelectTags from '@/pages/AdminPage/tabs/ClubInfoEditTab/components/SelectTags/SelectTags';
@@ -119,7 +119,6 @@ const ClubInfoEditTab = () => {
119119
}
120120

121121
const updatedData = {
122-
id: clubDetail.id,
123122
name: clubName,
124123
category: selectedCategory,
125124
division: selectedDivision,
@@ -128,6 +127,7 @@ const ClubInfoEditTab = () => {
128127
presidentName: clubPresidentName,
129128
presidentPhoneNumber: telephoneNumber,
130129
socialLinks: socialLinks,
130+
description: clubDetail.description,
131131
};
132132

133133
updateClub(updatedData, {

frontend/src/pages/AdminPage/tabs/ClubIntroTab/ClubIntroTab.tsx

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,11 @@ import { useUpdateClubDetail } from '@/hooks/queries/club/useUpdateClubDetail';
88
import useMixpanelTrack from '@/hooks/useMixpanelTrack';
99
import useTrackPageView from '@/hooks/useTrackPageView';
1010
import { ContentSection } from '@/pages/AdminPage/components/ContentSection/ContentSection';
11-
import { ClubDetail } from '@/types/club';
11+
import { Award, ClubDetail, FAQ, IdealCandidate } from '@/types/club';
1212
import * as Styled from './ClubIntroTab.styles';
1313
import AwardEditor from './components/AwardEditor/AwardEditor';
1414
import FAQEditor from './components/FAQEditor/FAQEditor';
1515

16-
export interface Award {
17-
semester: string;
18-
achievements: string[];
19-
}
20-
21-
export interface FAQ {
22-
id: string;
23-
question: string;
24-
answer: string;
25-
}
26-
27-
export interface IdealCandidate {
28-
tags: string[];
29-
content: string;
30-
}
31-
3216
const ClubIntroTab = () => {
3317
const trackEvent = useMixpanelTrack();
3418
useTrackPageView(PAGE_VIEW.CLUB_INFO_EDIT_PAGE);
@@ -49,14 +33,15 @@ const ClubIntroTab = () => {
4933
const queryClient = useQueryClient();
5034

5135
useEffect(() => {
52-
if (clubDetail) {
53-
// TODO: API 연동 시 실제 데이터로 대체
54-
setIntroDescription('');
55-
setActivityDescription('');
56-
setAwards([]);
57-
setIdealCandidate({ tags: [], content: '' });
58-
setBenefits('');
59-
setFaqs([]);
36+
if (clubDetail?.description) {
37+
setIntroDescription(clubDetail.description.introDescription || '');
38+
setActivityDescription(clubDetail.description.activityDescription || '');
39+
setAwards(clubDetail.description.awards || []);
40+
setIdealCandidate(
41+
clubDetail.description.idealCandidate || { tags: [], content: '' },
42+
);
43+
setBenefits(clubDetail.description.benefits || '');
44+
setFaqs(clubDetail.description.faqs || []);
6045
}
6146
}, [clubDetail]);
6247

@@ -69,17 +54,25 @@ const ClubIntroTab = () => {
6954
trackEvent(ADMIN_EVENT.UPDATE_CLUB_BUTTON_CLICKED);
7055

7156
const updatedData = {
72-
id: clubDetail.id,
73-
introDescription,
74-
activityDescription,
75-
awards,
76-
idealCandidate,
77-
benefits,
78-
faqs,
57+
name: clubDetail.name,
58+
category: clubDetail.category,
59+
division: clubDetail.division,
60+
tags: clubDetail.tags,
61+
introduction: clubDetail.introduction,
62+
presidentName: clubDetail.presidentName,
63+
presidentPhoneNumber: clubDetail.presidentPhoneNumber,
64+
socialLinks: clubDetail.socialLinks,
65+
description: {
66+
introDescription,
67+
activityDescription,
68+
awards,
69+
idealCandidate,
70+
benefits,
71+
faqs,
72+
},
7973
};
8074

81-
// TODO: API 연동
82-
updateClub(updatedData as any, {
75+
updateClub(updatedData, {
8376
onSuccess: () => {
8477
alert('동아리 상세 정보가 성공적으로 수정되었습니다.');
8578
queryClient.invalidateQueries({

0 commit comments

Comments
 (0)