Skip to content

Commit

Permalink
refactor(member): 활동 2차 QA 피드백 반영 (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeong-Ag authored Sep 13, 2024
1 parent 1925c3a commit f0e322a
Show file tree
Hide file tree
Showing 39 changed files with 786 additions and 325 deletions.
7 changes: 7 additions & 0 deletions .changeset/hungry-sloths-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@clab-platforms/auth": patch
"@clab-platforms/member": patch
"@clab-platforms/design-system": patch
---

refactor(member): 활동 2차 QA 피드백 반영
2 changes: 1 addition & 1 deletion apps/auth/src/utils/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const SERVICE_MAP: Record<ServiceCode, ServiceMap> = {
play: { url: 'https://play.clab.page/auth', name: '플레이' },
members: { url: 'https://members.clab.page/auth', name: '멤버스' },
test: {
url: 'https://members.test.clab.page/auth',
url: 'https://members.test.clab.page/test',
name: '스테이징 멤버스',
},
} as const;
Expand Down
87 changes: 74 additions & 13 deletions apps/member/src/api/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import { server } from './server';
import {
postFilesActivityPhotos,
postUploadedFileAssignment,
postUploadedFileNotice,
postUploadedFileSubmit,
postUploadedFileWeekly,
} from './uploadedFile';

export interface PatchActivityGroupMemberApplyParams {
activityGroupId: number;
memberId: string;
memberId: Array<string>;
status: string;
}

Expand Down Expand Up @@ -278,21 +280,19 @@ export async function postActivityBoard({

if (
body.category === ACTIVITY_BOARD_CATEGORY_STATE.ASSIGNMENT &&
parentId &&
memberId &&
activityGroupId &&
files
) {
// 파일이 있을 경우 파일 업로드 진행 (과제 파일)
const data = await postUploadedFileAssignment({
groupId: activityGroupId,
groupBoardId: parentId,
files,
});

fileUrl = data.map((file) => file.fileUrl);
} else if (
body.category === ACTIVITY_BOARD_CATEGORY_STATE.WEEKLY_ACTIVITY &&
memberId &&
activityGroupId &&
files
) {
// 파일이 있을 경우 파일 업로드 진행 (주차별 파일)
Expand All @@ -301,6 +301,32 @@ export async function postActivityBoard({
files,
});

fileUrl = data.map((file) => file.fileUrl);
} else if (
body.category === ACTIVITY_BOARD_CATEGORY_STATE.NOTICE &&
activityGroupId &&
files
) {
// 파일이 있을 경우 파일 업로드 진행 (공지사항 파일)
const data = await postUploadedFileNotice({
groupId: activityGroupId,
files,
});

fileUrl = data.map((file) => file.fileUrl);
} else if (
body.category === ACTIVITY_BOARD_CATEGORY_STATE.SUBMIT &&
activityGroupId &&
parentId &&
files
) {
// 파일이 있을 경우 파일 업로드 진행 (과제 제출물 파일)
const data = await postUploadedFileSubmit({
groupId: activityGroupId,
groupBoardId: parentId,
files,
});

fileUrl = data.map((file) => file.fileUrl);
}

Expand Down Expand Up @@ -330,20 +356,55 @@ export async function patchActivityBoard({
}: PatchActivityBoardParams) {
let fileUrl: Array<string> | null = null;

if (groupBoardId === null && groupId && files) {
// 파일이 있을 경우 파일 업로드 진행 (주차별 활동 파일)
if (
body.category === ACTIVITY_BOARD_CATEGORY_STATE.ASSIGNMENT &&
groupId &&
files
) {
// 파일이 있을 경우 파일 업로드 진행 (과제 파일)
const data = await postUploadedFileAssignment({
groupId,
files,
});

fileUrl = data.map((file) => file.fileUrl);
} else if (
body.category === ACTIVITY_BOARD_CATEGORY_STATE.WEEKLY_ACTIVITY &&
groupId &&
files
) {
// 파일이 있을 경우 파일 업로드 진행 (주차별 파일)
const data = await postUploadedFileWeekly({
groupId: groupId,
groupId,
files,
});

fileUrl = data.map((file) => file.fileUrl);
} else if (groupId && groupBoardId && files) {
// 파일이 있을 경우 파일 업로드 진행 (과제 파일)
const data = await postUploadedFileAssignment({
groupId: groupId,
groupBoardId: groupBoardId,
} else if (
body.category === ACTIVITY_BOARD_CATEGORY_STATE.NOTICE &&
groupId &&
files
) {
// 파일이 있을 경우 파일 업로드 진행 (공지사항 파일)
const data = await postUploadedFileNotice({
groupId,
files,
});

fileUrl = data.map((file) => file.fileUrl);
} else if (
body.category === ACTIVITY_BOARD_CATEGORY_STATE.SUBMIT &&
groupId &&
groupBoardId &&
files
) {
// 파일이 있을 경우 파일 업로드 진행 (과제 제출물 파일)
const data = await postUploadedFileSubmit({
groupId,
groupBoardId,
files,
});

fileUrl = data.map((file) => file.fileUrl);
}

Expand Down
74 changes: 55 additions & 19 deletions apps/member/src/api/uploadedFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,6 @@ export async function postUploadedFileMembershipFee(multipartFile: FormData) {

return data;
}
/**
* 활동 그룹 과제 업로드
*/
export async function postUploadedFileAssignment({
groupId,
groupBoardId,
files,
}: PostUploadedFileAssignmentParams) {
const url = createURL(
END_POINT.UPLOADEDFILE_ACTIVITY_ASSIGNMENT(groupId, groupBoardId),
STORAGE_PERIOD(3), // 활동 과제 파일은 3년간 보관
);
const { data } = await server.post<FormData, BaseResponse<ResponseFile[]>>({
url,
body: files,
});

return data;
}
/**
* 멤버 프로필 사진 업로드
*/
Expand Down Expand Up @@ -109,6 +90,42 @@ export async function postUploadedFileWeekly({
}: PostUploadedFileWeeklyParams) {
const url = createURL(
END_POINT.UPLOADEDFILE_ACTIVITY_WEEKLY(groupId),
STORAGE_PERIOD(3), // 활동 주차별활동 파일은 3년간 보관
);
const { data } = await server.post<FormData, BaseResponse<ResponseFile[]>>({
url,
body: files,
});

return data;
}
/**
* 활동 그룹 공지사항 파일 업로드
*/
export async function postUploadedFileNotice({
groupId,
files,
}: PostUploadedFileWeeklyParams) {
const url = createURL(
END_POINT.UPLOADEDFILE_ACTIVITY_NOTICE(groupId),
STORAGE_PERIOD(3), // 활동 공지사항 파일은 3년간 보관
);
const { data } = await server.post<FormData, BaseResponse<ResponseFile[]>>({
url,
body: files,
});

return data;
}
/**
* 활동 그룹 과제 파일 업로드
*/
export async function postUploadedFileAssignment({
groupId,
files,
}: PostUploadedFileWeeklyParams) {
const url = createURL(
END_POINT.UPLOADEDFILE_ACTIVITY_ASSIGNMENT(groupId),
STORAGE_PERIOD(3), // 활동 과제 파일은 3년간 보관
);
const { data } = await server.post<FormData, BaseResponse<ResponseFile[]>>({
Expand All @@ -118,3 +135,22 @@ export async function postUploadedFileWeekly({

return data;
}
/**
* 활동 그룹 과제 제출물 업로드
*/
export async function postUploadedFileSubmit({
groupId,
groupBoardId,
files,
}: PostUploadedFileAssignmentParams) {
const url = createURL(
END_POINT.UPLOADEDFILE_ACTIVITY_SUBMIT(groupId, groupBoardId),
STORAGE_PERIOD(3), // 활동 과제 제출물 파일은 3년간 보관
);
const { data } = await server.post<FormData, BaseResponse<ResponseFile[]>>({
url,
body: files,
});

return data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface ApplicationInfoModalProps {
applicationInfo: ApplicationMemberType;
}

const ApplicationInfoModal = ({
export const ApplicationInfoModal = ({
applicationInfo,
}: ApplicationInfoModalProps) => {
const {
Expand Down Expand Up @@ -39,5 +39,3 @@ const ApplicationInfoModal = ({
</DetailsList>
);
};

export default ApplicationInfoModal;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Badge, Button, Table } from '@clab-platforms/design-system';
import Pagination from '@components/common/Pagination/Pagination';
import { Section } from '@components/common/Section';
import Select from '@components/common/Select/Select';
import ApplicationInfoModal from '@components/modal/ApplicationInfoModal/ApplicationInfoModal';

import { TABLE_HEAD } from '@constants/head';
import useModal from '@hooks/common/useModal';
Expand All @@ -19,7 +18,9 @@ import {
useApplicationPassMutation,
} from '@hooks/queries/application';

import { ApplicationMemberType } from '@type/application';
import type { ApplicationMemberType } from '@type/application';

import { ApplicationInfoModal } from './ApplicationInfoModal';

interface RecruitmentItem {
id: number;
Expand Down
1 change: 1 addition & 0 deletions apps/member/src/components/common/File/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const File = ({ href, name }: FileProps) => {
.then((blob) => {
const href = window.URL.createObjectURL(new Blob([blob]));
const a = document.createElement('a');

a.href = href;
a.download = name;
document.body.appendChild(a);
Expand Down
22 changes: 22 additions & 0 deletions apps/member/src/components/common/TextCounting/TextCounting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { cn } from '@clab-platforms/utils';

interface MaxLengthCounterProps {
maxLength: number;
text?: string;
children?: string;
}

const TextCounting = ({ maxLength, text, children }: MaxLengthCounterProps) => {
return (
<p
className={cn('mt-2 text-right text-xs', children, {
'text-red-500': text && text.length > maxLength,
})}
>
<span>{text ? text.length : '0'}</span>
<span>{'/' + maxLength + '자'}</span>
</p>
);
};

export default TextCounting;
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Button, Table } from '@clab-platforms/design-system';

import { Section } from '@components/common/Section';
import { ActivityBoardEditModal } from '@components/modal';

import { TABLE_HEAD } from '@constants/head';
import useModal from '@hooks/common/useModal';
import { useActivityGroupBoardDeleteMutation } from '@hooks/queries';
import { formattedDate, toKoreaISOString } from '@utils/date';

import { ActivityBoardType } from '@type/activity';

import ActivityBoardEditModal from '../ActivityBoardEditModal/ActivityBoardEditModal';
import type { ActivityBoardType } from '@type/activity';

interface ActivityConfigTableSectionProps {
tableList: ActivityBoardType[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useState } from 'react';
import { useRef, useState } from 'react';

import { Button, Input } from '@clab-platforms/design-system';

import Hr from '@components/common/Hr/Hr';
import Section from '@components/common/Section/Section';
import Textarea from '@components/common/Textarea/Textarea';

import { FORM_DATA_KEY } from '@constants/api';
import useToast from '@hooks/common/useToast';
import { useActivityGroupBoardMutation } from '@hooks/queries';

Expand All @@ -32,6 +33,7 @@ const defaultNotice: ActivityBoardType = {
const ActivityNoticeEditor = ({ groupId, data }: ActivityNoticeEditorProps) => {
const toast = useToast();
const [notice, setNotice] = useState<ActivityBoardType>(defaultNotice);
const uploaderRef = useRef<HTMLInputElement>(null);
const { activityGroupBoardMutate, activityGroupBoardIsPending } =
useActivityGroupBoardMutation();

Expand All @@ -41,16 +43,27 @@ const ActivityNoticeEditor = ({ groupId, data }: ActivityNoticeEditorProps) => {
const { name, value } = e.target;
setNotice((prev) => ({ ...prev, [name]: value }));
};

const handleAddNoticeButtonClick = () => {
const formData = new FormData();
const files = uploaderRef.current?.files;

if (!notice.title || !notice.content)
return toast({
state: 'error',
message: '제목, 내용은 필수 입력 요소입니다.',
});
if (files) {
Array.from(files).forEach((file) => {
formData.append(FORM_DATA_KEY, file);
});
}

activityGroupBoardMutate(
{
activityGroupId: groupId,
body: notice,
files: files?.length ? formData : undefined,
},
{ onSuccess: () => setNotice(defaultNotice) },
);
Expand Down Expand Up @@ -79,6 +92,7 @@ const ActivityNoticeEditor = ({ groupId, data }: ActivityNoticeEditorProps) => {
value={notice.content}
onChange={handleNoticeChange}
/>
<input ref={uploaderRef} id="uploader" type="file" multiple />
</div>
<Hr>미리보기</Hr>
<ActivityNoticeSection data={[notice, ...data]} />
Expand Down
Loading

0 comments on commit f0e322a

Please sign in to comment.