-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoomStatus.tsx
82 lines (76 loc) · 1.62 KB
/
RoomStatus.tsx
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
72
73
74
75
76
77
78
79
80
81
82
import React from 'react'
import styled from '@emotion/styled'
import CheckIcon from '@mui/icons-material/Check'
import {
useCurrentRoom,
useRoomById,
useRoomStatusActions
} from '../../../state/rooms/hooks'
import { useSocketActions } from '../../../state/socket/hooks'
export const SettingRoomStatus = () => {
const { currentRoomId } = useCurrentRoom()
const { setRoomStatus } = useRoomStatusActions()
const { openRoom, closeRoom } = useSocketActions()
const room = useRoomById(currentRoomId)
const status = room?.status
const clickOpen = () => {
openRoom(currentRoomId)
setRoomStatus(currentRoomId, 'open')
}
const clickClose = () => {
closeRoom(currentRoomId)
setRoomStatus(currentRoomId, 'close')
}
return (
<Wrap>
<h4>公開設定</h4>
<ul>
<li>
<div
className={status === 'open' ? 'active' : ''}
onClick={clickOpen}
>
<CheckIcon />
公開
</div>
</li>
<li>
<div
className={status === 'close' ? 'active' : ''}
onClick={clickClose}
>
<CheckIcon />
非公開
</div>
</li>
</ul>
</Wrap>
)
}
const Wrap = styled.div`
margin-top: 16px;
> ul {
list-style-type: none;
margin: 0;
padding: 0;
> li {
> div {
display: flex;
align-items: center;
cursor: pointer;
}
padding-left: 0;
margin: 1em 0;
}
}
svg {
opacity: 0;
margin: 0 0.5em 0 0;
color: #50e9a3;
}
.active {
svg {
opacity: 1;
}
}
`