-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(member): 활동 2차 QA 피드백 반영 수정 #231
Changes from all commits
ae4f007
2ad18e2
d0fc817
32a10a9
b3a3d9d
6e78d76
b6f4a35
36fc6d3
5b797be
8d3640a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@clab-platforms/member": patch | ||
--- | ||
|
||
refactor(member): 활동 2차 QA 피드백 반영 수정 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
import { createURL } from '@clab-platforms/utils'; | ||
|
||
import { SERVER_BASE_URL } from '@constants/api'; | ||
import useToast from '@hooks/common/useToast'; | ||
|
||
interface FileProps extends React.PropsWithChildren { | ||
href: string; | ||
name: string; | ||
} | ||
|
||
const File = ({ children, href }: FileProps) => { | ||
const File = ({ href, name }: FileProps) => { | ||
const toast = useToast(); | ||
|
||
if (!href.startsWith(SERVER_BASE_URL)) { | ||
href = createURL(SERVER_BASE_URL, href); | ||
} | ||
|
||
const handleClickImgLink = () => { | ||
fetch(href) | ||
.then((res) => res.blob()) | ||
.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); | ||
a.click(); | ||
window.URL.revokeObjectURL(href); | ||
a.remove(); | ||
}) | ||
.catch(() => { | ||
toast({ state: 'error', message: '파일 다운로드에 실패했습니다' }); | ||
}); | ||
}; | ||
|
||
return ( | ||
<a | ||
href={href} | ||
target="_blank" | ||
className="underline-offset-4 hover:underline" | ||
className="text-gray-700 underline-offset-4 hover:underline" | ||
rel="noreferrer" | ||
onClick={handleClickImgLink} | ||
> | ||
{children} | ||
{name} | ||
Comment on lines
-21
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이전에는 children 으로 |
||
</a> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ const Notice = ({ | |
}, | ||
)} | ||
> | ||
D-{dDay} | ||
{dDay === 0 ? 'D-Day' : `D-${dDay}`} | ||
</div> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,15 +40,17 @@ const ActivityAssignmentEditor = ({ parentId, activityGroupId }: Props) => { | |
}; | ||
const handleAddAssignmentClick = () => { | ||
const formData = new FormData(); | ||
const file = uploaderRef.current?.files?.[0]; | ||
const files = uploaderRef.current?.files; | ||
|
||
if (!board.title || !board.content || !board.dueDateTime) | ||
return toast({ | ||
state: 'error', | ||
message: '제목, 내용, 종료 일시는 필수 입력 요소입니다.', | ||
}); | ||
if (file) { | ||
formData.append(FORM_DATA_KEY, file); | ||
if (files) { | ||
Array.from(files).forEach((file) => { | ||
formData.append(FORM_DATA_KEY, file); | ||
}); | ||
} | ||
Comment on lines
+50
to
54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
activityGroupBoardMutate( | ||
|
@@ -60,25 +62,15 @@ const ActivityAssignmentEditor = ({ parentId, activityGroupId }: Props) => { | |
category: ACTIVITY_BOARD_CATEGORY_STATE.ASSIGNMENT, | ||
...board, | ||
}, | ||
files: file ? formData : undefined, | ||
files: files?.length ? formData : undefined, | ||
}, | ||
{ onSuccess: () => setBoard(defaultBoard) }, | ||
); | ||
}; | ||
|
||
return ( | ||
<Section> | ||
<Section.Header title="과제 관리"> | ||
<div className="space-x-2"> | ||
<Button | ||
size="sm" | ||
onClick={handleAddAssignmentClick} | ||
disabled={activityGroupBoardIsPending} | ||
> | ||
추가 | ||
</Button> | ||
</div> | ||
</Section.Header> | ||
<Section.Header title="과제 관리" /> | ||
<Section.Body className="space-y-4"> | ||
<div className="space-y-2"> | ||
<Input | ||
|
@@ -112,10 +104,17 @@ const ActivityAssignmentEditor = ({ parentId, activityGroupId }: Props) => { | |
<label htmlFor="fileUpload" className="mb-1 ml-1 text-xs"> | ||
첨부 파일 | ||
</label> | ||
<input ref={uploaderRef} id="fileUpload" type="file" /> | ||
<input ref={uploaderRef} id="fileUpload" type="file" multiple /> | ||
</div> | ||
</Grid> | ||
</div> | ||
<Button | ||
className="w-full" | ||
onClick={handleAddAssignmentClick} | ||
disabled={activityGroupBoardIsPending} | ||
> | ||
추가 | ||
</Button> | ||
</Section.Body> | ||
</Section> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
긴 라인은 문맥을 한번 구분해주는게 가독성에 좋아요