-
Notifications
You must be signed in to change notification settings - Fork 0
/
Header.jsx
182 lines (173 loc) · 6.07 KB
/
Header.jsx
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import { AiFillSetting } from "react-icons/ai";
import {
Container,
Nav,
Navbar,
NavDropdown,
Offcanvas,
} from "react-bootstrap";
import { useNavigate } from "react-router-dom";
import { LinkContainer } from "react-router-bootstrap";
import { PiPersonSimpleWalkBold } from "react-icons/pi";
import { CiSettings } from "react-icons/ci";
import { IoMdArrowDropdown } from "react-icons/io";
import { clearUserSession, getUserSession } from "../js/userAction";
import styles from "../styles/components/NavStyle.module.scss";
import ImageOfYLHLogo from "../assets/ylhlogo.png";
export default function Header({ expand = "lg" }) {
const user = getUserSession();
const permission = user?.permission;
const navigate = useNavigate();
return (
<Navbar
collapseOnSelect
id={styles.navBarContainer}
expand={expand}
className="mb-3"
variant="light"
fixed="top"
>
<Container fluid>
<LinkContainer to="/Home">
<Navbar.Brand>
<img
src={ImageOfYLHLogo}
alt="台大醫院雲林分院衛教系統"
className={`d-inline-block align-top ${styles.logo}`}
fluid="true"
/>
</Navbar.Brand>
</LinkContainer>
<Navbar.Toggle aria-controls={`offcanvasNavbar-expand-${expand}`} />
<Navbar.Offcanvas
id={`offcanvasNavbar-expand-${expand}`}
aria-labelledby={`offcanvasNavbarLabel-expand-${expand}`}
placement="end"
>
<Offcanvas.Header closeButton>
<Offcanvas.Title id={`offcanvasNavbarLabel-expand-${expand}`}>
選單
</Offcanvas.Title>
</Offcanvas.Header>
<Offcanvas.Body>
<Nav className="me-auto">
{user !== null ? (
<NavDropdown
title={
<>
衛教資訊
<IoMdArrowDropdown />
</>
}
id="collasible-nav-dropdown"
>
<LinkContainer to="/basic">
<NavDropdown.Item>基礎練習</NavDropdown.Item>
</LinkContainer>
<LinkContainer to="/Pratice">
<NavDropdown.Item>練習</NavDropdown.Item>
</LinkContainer>{" "}
<LinkContainer to="/test">
<NavDropdown.Item>測驗</NavDropdown.Item>
</LinkContainer>{" "}
</NavDropdown>
) : null}
{/* 衛教天地Nav */}
<Nav.Link href="https://www.ylh.gov.tw/?aid=612">
衛教天地
</Nav.Link>
{/* 練習紀錄 */}
{user !== null && permission === "ylhClient" ? (
<NavDropdown
title={
<>
練習紀錄
<IoMdArrowDropdown />
</>
}
id="collasible-nav-dropdown"
>
<LinkContainer to="/record/basic">
<NavDropdown.Item>基礎練習</NavDropdown.Item>
</LinkContainer>
<LinkContainer to="/record/pratice">
<NavDropdown.Item>練習</NavDropdown.Item>
</LinkContainer>{" "}
<LinkContainer to="/record/test">
<NavDropdown.Item>測驗</NavDropdown.Item>
</LinkContainer>{" "}
</NavDropdown>
) : null}
{/* 使用教學Nav */}
{user !== null ? (
<LinkContainer to="/usingTip">
<Nav.Link>使用教學</Nav.Link>
</LinkContainer>
) : null}
{/* 問題建議Nav */}
{user !== null ? (
<LinkContainer to="/comment">
<Nav.Link>滿意度調查</Nav.Link>
</LinkContainer>
) : null}
<LinkContainer to="/about">
<Nav.Link>關於我們</Nav.Link>
</LinkContainer>
</Nav>
{/* 語系選擇 不一定會做 */}
{/* <Nav>
<NavDropdown
title={<BsGlobeAmericas />}
id="collasible-nav-dropdown"
>
<LinkContainer to="/">
<NavDropdown.Item>中文</NavDropdown.Item>
</LinkContainer>{" "}
<LinkContainer to="/">
<NavDropdown.Item>英文</NavDropdown.Item>
</LinkContainer>{" "}
</NavDropdown>
</Nav> */}
<Nav>
{user !== null ? (
<NavDropdown
title={
<>
設定
<AiFillSetting />
<IoMdArrowDropdown />
</>
}
id="collasible-nav-dropdown"
align={{ lg: "end" }}
>
{user !== null && permission === "ylhClient" ? (
<LinkContainer to="/setting">
<NavDropdown.Item>使用者設定</NavDropdown.Item>
</LinkContainer>
) : null}
{user !== null && permission === "ylhClient" ? (
<NavDropdown.Item
as={"button"}
onClick={() => {
clearUserSession();
navigate("/");
}}
>
登出
<PiPersonSimpleWalkBold />
</NavDropdown.Item>
) : (
<LinkContainer to="/">
<NavDropdown.Item>登入</NavDropdown.Item>
</LinkContainer>
)}
</NavDropdown>
) : null}
</Nav>
</Offcanvas.Body>
</Navbar.Offcanvas>
</Container>
</Navbar>
);
}