-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHostEditPage.tsx
More file actions
71 lines (64 loc) · 2.62 KB
/
HostEditPage.tsx
File metadata and controls
71 lines (64 loc) · 2.62 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
62
63
64
65
66
67
68
69
70
71
import { useState } from 'react';
import HostDetailLayout from '../../../../shared/ui/backgrounds/HostDetailLayout';
import { useParams } from 'react-router-dom';
import useHostChannelInfo from '../../../../entities/host/hook/useHostChannelInfoHook';
import { useInviteMembers } from '../../../../features/host/hook/useInviteHostHook';
import HostInfo from '../../../../entities/host/ui/HostInfo';
import HostEditForm from '../../../../entities/host/ui/HostEditForm';
import MemberInvite from '../../../../entities/host/ui/MemberInvite';
const HostEditPage = () => {
const { id } = useParams<{ id: string }>();
const [selectedHost, setSelectedHost] = useState(true);
const [selectedInfo, setSelectedInfo] = useState(false);
const [emails, setEmails] = useState<string[]>([]);
const hostChannelId = Number(id);
const { data: hostInfo } = useHostChannelInfo(hostChannelId);
const { inviteMembers } = useInviteMembers(hostChannelId);
const handeHostInfoClick = () => {
setSelectedHost(true);
setSelectedInfo(false);
};
const handeInfoEditClick = () => {
setSelectedInfo(true);
setSelectedHost(false);
};
const handleInviteMembers = () => {
if (!hostInfo?.result.id) return;
inviteMembers(emails, () => setEmails([]));
};
return (
<HostDetailLayout>
<div className="relative overflow-y-auto">
<div className="flex flex-col w-full px-8 py-8 gap-3">
<div className="flex justify-between px-12 md:px-20 text-16 md:text-base">
<span
onClick={handeHostInfoClick}
className={`cursor-pointer ${selectedHost ? 'text-black' : 'text-placeholderText'} transition-colors`}
>
호스트 정보
</span>
<span
onClick={handeInfoEditClick}
className={`cursor-pointer ${selectedInfo ? 'text-black' : 'text-placeholderText'} transition-colors`}
>
정보 수정
</span>
</div>
<div className="relative">
{selectedHost && <div className="absolute top-0 left-8 md:left-15 w-28 border-t-2 border-black" />}
{selectedInfo && <div className="absolute top-0 right-7 md:right-15 w-24 border-t-2 border-black" />}
<hr className="border-t-2" />
</div>
</div>
{selectedHost && <HostInfo hostInfo={hostInfo} />}
{selectedInfo && (
<>
<HostEditForm />
<MemberInvite emails={emails} setEmails={setEmails} handleInviteMembers={handleInviteMembers} />
</>
)}
</div>
</HostDetailLayout>
);
};
export default HostEditPage;