-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHostEditForm.tsx
More file actions
61 lines (54 loc) · 2.41 KB
/
HostEditForm.tsx
File metadata and controls
61 lines (54 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import useHostChannelInfo from '../hook/useHostChannelInfoHook';
import { useHostInfoSave } from '../../../features/host/hook/useHostInfoHook';
import { hostInfoSchema } from '../../../shared/lib/formValidation';
import DefaultTextField from '../../../../design-system/ui/textFields/DefaultTextField';
import TertiaryButton from '../../../../design-system/ui/buttons/TertiaryButton';
import MultilineTextField from '../../../../design-system/ui/textFields/MultilineTextField';
const HostEditForm = () => {
const { id } = useParams<{ id: string }>();
const hostChannelId = Number(id);
const [email, setEmail] = useState('');
const [channelDescription, setChannelDescription] = useState('');
const { data: hostInfo } = useHostChannelInfo(hostChannelId);
const { handleSave } = useHostInfoSave(hostChannelId, hostInfo!, email, channelDescription);
const emailValidation = hostInfoSchema.safeParse({ email });
useEffect(() => {
if (hostInfo?.result.email) setEmail(hostInfo.result.email);
if (hostInfo?.result.channelDescription) setChannelDescription(hostInfo.result.channelDescription);
}, [hostInfo]);
return (
<div className="flex flex-col gap-4 md:gap-8 px-8 md:px-6 mb-4 md:mb-8">
<div className="flex flex-col gap-2">
<DefaultTextField
label="대표 이메일"
detail="채널 혹은, 채널에서 주최하는 이벤트에 대해 문의 할 수 있는 메일로 작성해주세요."
value={email}
onChange={e => setEmail(e.target.value)}
className="h-12"
labelClassName="sm:text-base md:text-lg"
errorMessage={!emailValidation.success ? emailValidation.error.errors[0].message : ''}
/>
<TertiaryButton
type="button"
label="수정하기"
size="large"
color="pink"
onClick={handleSave}
disabled={!emailValidation.success}
/>
</div>
<div className="flex flex-col gap-2">
<MultilineTextField
label="채널에 대한 설명"
value={channelDescription}
onChange={e => setChannelDescription(e.target.value)}
className="h-24 mb-8"
/>
<TertiaryButton type="button" label="수정하기" size="large" color="pink" onClick={handleSave} />
</div>
</div>
);
};
export default HostEditForm;