|
1 |
| -import { addGroupSchedule } from '@/apis/groupScheduleApis'; |
2 | 1 | import GroupForm from '@/components/Group/GroupForm';
|
3 | 2 | import AppBar from '@/components/common/AppBar';
|
| 3 | +import Dialog from '@/components/common/Dialog'; |
| 4 | +import { useAddGroupSchedule } from '@/hooks/useAddGroupSchedule'; |
4 | 5 | import { Member } from '@/types/Member';
|
5 | 6 |
|
6 | 7 | const AddGroupPage = () => {
|
| 8 | + const { addGroupSchedule, isPending, failDialogRef, successDialogRef } = useAddGroupSchedule(); |
7 | 9 | const handleSubmit = (e: React.FormEvent<HTMLFormElement>, userList: Member[]) => {
|
8 | 10 | e.preventDefault();
|
9 |
| - const formData = new FormData(e.currentTarget); |
10 |
| - const addSchedule = { |
11 |
| - title: formData.get('name') as string, |
12 |
| - description: formData.get('description') as string, |
13 |
| - startDate: formData.get('startDate') as string, |
14 |
| - endDate: formData.get('endDate') as string, |
15 |
| - memo: formData.get('memo') as string, |
16 |
| - newMemberList: userList, |
17 |
| - }; |
18 |
| - addGroupSchedule(addSchedule); |
| 11 | + addGroupSchedule(e, userList); |
19 | 12 | };
|
20 | 13 |
|
21 | 14 | return (
|
22 | 15 | <div className="flex min-h-dvh w-screen flex-col overflow-x-hidden px-6">
|
23 | 16 | <AppBar backButton title={'모임 일정 등록하기'} />
|
24 |
| - <GroupForm onSubmit={handleSubmit} /> |
| 17 | + <GroupForm onSubmit={handleSubmit} isLoading={isPending} /> |
| 18 | + <Dialog ref={successDialogRef} desc="모임 일정이 등록되었습니다." /> |
| 19 | + <Dialog ref={failDialogRef} desc="모임 일정 등록에 실패했습니다." /> |
25 | 20 | </div>
|
26 | 21 | );
|
27 | 22 | };
|
|
0 commit comments