-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(member): 회비 사용 신청서 개선 (#78)
- Loading branch information
Showing
4 changed files
with
206 additions
and
81 deletions.
There are no files selected for viewing
225 changes: 145 additions & 80 deletions
225
apps/member/src/components/support/SupportRequestForm/SupportRequestForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
apps/member/src/components/support/SupportRequestSection/SupportRequestSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Section from '@components/common/Section/Section'; | ||
import { useMembershipFeeMutation } from '@hooks/queries/useMembershipFeeMutation'; | ||
import { FORM_DATA_KEY } from '@constants/api'; | ||
import SupportRequestForm from '../SupportRequestForm/SupportRequestForm'; | ||
import Linker from '@components/common/Linker/Linker'; | ||
import { PATH } from '@constants/path'; | ||
import type { SupportRequestDataType } from '@type/support'; | ||
|
||
const SupportRequestSection = () => { | ||
const { membershipFeeMutate, isPending } = useMembershipFeeMutation(); | ||
/** | ||
* 사용 신청서를 제출합니다. | ||
*/ | ||
const handleRequestSubmit = async (data: SupportRequestDataType) => { | ||
const formData = new FormData(); | ||
if (data.file) { | ||
formData.append( | ||
FORM_DATA_KEY, | ||
data.file, | ||
encodeURIComponent(data.file.name), | ||
); | ||
} | ||
membershipFeeMutate({ | ||
body: data, | ||
multipartFile: formData.get(FORM_DATA_KEY) ? formData : null, | ||
}); | ||
}; | ||
|
||
return ( | ||
<Section> | ||
<Section.Header title="사용 신청서" /> | ||
<Linker to={PATH.LIBRARY}> | ||
혹시 도서 신청을 하시나요? 이미 보유중인 책일 수도 있어요. | ||
</Linker> | ||
<hr className="mt-4 border border-dashed" /> | ||
<Section.Body> | ||
<SupportRequestForm | ||
isPending={isPending} | ||
onSubmit={handleRequestSubmit} | ||
/> | ||
</Section.Body> | ||
</Section> | ||
); | ||
}; | ||
|
||
export default SupportRequestSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* SupportRequestForm에서 사용되는 데이터 타입 | ||
*/ | ||
export interface SupportRequestDataType { | ||
category: string; | ||
amount: number; | ||
content: string; | ||
file: File | null; | ||
} |