-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
56 lines (50 loc) · 1.19 KB
/
App.js
File metadata and controls
56 lines (50 loc) · 1.19 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
import './App.css';
import {useState} from 'react';
function App() {
const [isOver18, setIsOver18] = useState(false);
const [notOver18, setNotOver18] = useState(true);
const verified = (e) => {
e.preventDefault();
setIsOver18(true);
}
const notVerified = (e) => {
e.preventDefault();
setNotOver18(false);
}
if (!notOver18) {
return (
<div className="access-denied">
<h2>This website is not accessible</h2>
<h1><span style={{color: 'red'}}>Access Denied.</span></h1>
</div>
)
}
if (!isOver18) {
return (
<div className="age-verification">
<h2>We need to verify your age</h2>
<h1>Are you over 18?</h1>
<div style={{display: 'flex'}}>
<button onClick={verified}>Yes</button>
<button onClick={notVerified}>No</button>
</div>
</div>
)
}
return (
<div className="website-content">
<header>
<h1>Smoking Kills</h1>
<nav>
<ul>
<li><a href="#about">About</a></li>
<li><a href="#health-risks">Health Risks</a></li>
<li><a href="#quitting">Thinking of Quitting?</a></li>
<li><a href="#contact-us">Contact Us</a></li>
</ul>
</nav>
</header>
</div>
)
}
export default App;