-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwoven-react-ChangePasswordAlert.js
124 lines (113 loc) · 3.17 KB
/
woven-react-ChangePasswordAlert.js
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
// // AlertCard.jsx
// import React from "react";
// export default function AlertCard({ auth }) {
// const accs = auth.meta.breachedAccounts;
// const [isAlert, setIsAlert] = React.useState(
// !auth.meta.suggestPasswordChange
// );
// return (
// <div className="card">
// {isAlert ? (
// <p style={{ background: "white" }}>No alerts</p>
// ) : (
// <div>
// <h1 className="card-header" style={{ background: "GoldenRod" }}>
// Alert!
// </h1>
// <div className="card-body" style={{ background: "gold" }}>
// <p>Your email was involved in a breach on the following sites:</p>
// <ul>
// {accs.map((acc) => (
// <li key={acc.name}>
// {acc.addedDate} - {acc.name}
// </li>
// ))}
// </ul>
// <p>
// Although your information on our site is safe, we recommend you
// change your password in case your AppCo account shares a password
// with any of the sites above.
// </p>
// <button>Change Password</button>
// <button onClick={() => setIsAlert(true)}>Dismiss</button>
// </div>
// </div>
// )}
// </div>
// );
// }
// // Dashboard.jsx
// import React from "react";
// import TasksCard from "./cards/TasksCard";
// import AlertCard from "./cards/AlertCard";
// export default function Dashboard({ auth }) {
// return (
// <div>
// <h2 className="mt-3">Dashboard</h2>
// <div className="row mt-5">
// <div className="col-12">
// <AlertCard auth={auth} />
// <TasksCard />
// </div>
// </div>
// </div>
// );
// }
// App.jsx
import React, { useState } from "react";
import LoginForm from "./LoginForm";
import Dashboard from "./Dashboard";
export default function App() {
const [auth, setAuth] = useState({
token: "",
user: {},
meta: {},
});
const onLoginSuccess = (auth) => {
setAuth(auth);
console.log(auth);
};
const onLogOut = (e) => {
setAuth({
token: "",
user: {},
meta: {},
});
};
const currentPage = () => {
return auth.token ? (
<Dashboard auth={auth} />
) : (
<LoginForm onLoginSuccess={onLoginSuccess} />
);
};
return (
<div>
<nav className="navbar navbar-expand navbar-dark bg-info">
<a className="navbar-brand mr-auto" href="#">
AppCo
</a>
{auth.token && (
<ul className="navbar-nav">
<li className="nav-item active">
<a className="nav-link" href="#">
Home <span className="sr-only">(current)</span>
</a>
</li>
<li className="nav-item">
<a className="nav-link" href="#">
Tasks
</a>
</li>
<li className="nav-item">
<a className="nav-link" onClick={onLogOut}>
Log out
</a>
</li>
</ul>
)}
</nav>
<div className="container">{currentPage()}</div>
</div>
);
}