Skip to content

Commit ce74273

Browse files
committed
install dependences, adjust components/css
1 parent 147c072 commit ce74273

File tree

10 files changed

+16135
-24
lines changed

10 files changed

+16135
-24
lines changed

reactapp/package-lock.json

+16,072
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

reactapp/package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
"@testing-library/jest-dom": "^4.2.4",
77
"@testing-library/react": "^9.3.2",
88
"@testing-library/user-event": "^7.1.2",
9+
"axios": "^0.19.2",
910
"react": "^16.13.1",
1011
"react-dom": "^16.13.1",
11-
"react-scripts": "3.4.1"
12+
"react-icons": "^3.10.0",
13+
"react-router-dom": "^5.2.0",
14+
"react-scripts": "3.4.1",
15+
"react-toastify": "^6.0.8"
1216
},
1317
"scripts": {
1418
"start": "react-scripts start",

reactapp/src/App.js

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import "react-toastify/dist/ReactToastify.css";
88

99
class App extends Component {
1010
state = {
11+
1112
isAuthenticated: true,
1213
};
1314

@@ -24,6 +25,19 @@ class App extends Component {
2425
let routes = (
2526
<Switch>
2627
<Layout>
28+
<Route
29+
path="/login/"
30+
render={() => (
31+
<Redirect to={`/onepage/`} />
32+
)}
33+
/>
34+
<Route
35+
exact
36+
path="/"
37+
render={() => (
38+
<Redirect to={`/onepage/`} />
39+
)}
40+
/>
2741
<Route path="/*" component={Routes} />
2842
</Layout>
2943
</Switch>

reactapp/src/Routes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default class Routes extends Component {
77
return (
88
<div>
99
<Switch>
10-
<Route path="/*" component={Onepage} />
10+
<Route path="/onepage/" component={Onepage} />
1111
</Switch>
1212
</div>
1313
)

reactapp/src/configs/config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

22
export default {
3-
API_URL: "http://127.0.0.1:8000",
3+
API_URL: "http://127.0.0.1:8000/api/v1",
4+
CRU_URL : "http://127.0.0.1:8000"
45
};

reactapp/src/containers/Accounts/Login.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import myConfig from "../../configs/config";
77
import { ToastContainer, toast } from "react-toastify";
88

99
const Login = () => {
10-
1110
const [email, setEmail] = useState("");
1211
const [password, setPassword] = useState("");
1312

@@ -17,16 +16,19 @@ const Login = () => {
1716
form_data.append("username", email);
1817
form_data.append("password", password);
1918
form_data.append("grant_type", "password");
20-
form_data.append("client_id", "YOUR_CLIENT_ID");
21-
form_data.append("client_secret","YOUR_CLIENT_SECRET");
22-
19+
form_data.append("client_id", "api");
20+
form_data.append(
21+
"client_secret",
22+
"H4s2b6ATJHBnmYcah9vxnpwuKJxQgEjbRo0TlmvDgVVgB02MYugfNGLpGU1w3Pz9CbRwoR9caGOw3zXOCv0GUS13udR8GAgMIYzLKBcBh5ErnFg7r8EW6gPw2jKVQnsm"
23+
);
24+
2325
return form_data;
2426
}
2527

2628
function handleSave(e) {
2729
e.preventDefault();
2830

29-
const LOGIN_URL = `${myConfig.API_URL}/o/token/`;
31+
const LOGIN_URL = `${myConfig.CRU_URL}/o/token/`;
3032

3133
axios({
3234
baseURL: LOGIN_URL,
@@ -38,20 +40,20 @@ const Login = () => {
3840
console.log(res.data);
3941
localStorage.setItem("user-token", res.data.access_token);
4042
toast("Login realizado com sucesso.");
43+
window.location.href = "/";
4144
}
4245
})
4346
.catch((error) => {
44-
// console.log("ERROR", error);
47+
console.log("ERROR", error);
4548
toast("Email ou senha inválidos.");
4649
});
47-
// setTimeout(() => {}, 3500);
4850
}
4951

5052
return (
5153
<div className="login_content">
5254
<section className="form">
5355
<form onSubmit={handleSave}>
54-
<h1>Faça o seu Login</h1>
56+
<h1>Login</h1>
5557

5658
<input
5759
value={email}
@@ -60,25 +62,26 @@ const Login = () => {
6062
placeholder="Email"
6163
type="email"
6264
/>
65+
<br />
6366
<input
6467
value={password}
6568
name="password"
6669
type="password"
6770
onChange={(e) => setPassword(e.target.value)}
6871
placeholder="Senha"
6972
/>
73+
<br />
7074
<button className="button" type="submit">
7175
Entrar
7276
</button>
73-
77+
<br />
7478
<Link to="/signup" className="back-link">
75-
<FiLogIn size={16} color="007bff" />
79+
<FiLogIn size={16} color="b366ff" />
7680
Não tenho cadastro
7781
</Link>
7882
</form>
7983
<ToastContainer />
8084
</section>
81-
8285
</div>
8386
);
8487
};

reactapp/src/containers/Accounts/Signup.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ export default function Register() {
3737
history.push("/login/");
3838
}, 5000);
3939
})
40-
.catch((error) => {
40+
.catch((error) => {
41+
console.log(error);
4142
let error_msg = "";
4243
Object.keys(error.response.data).forEach(function (e) {
4344
error_msg += e + ": " + error.response.data[e][0] + " - ";
4445
});
45-
toast(error_msg);
46+
toast(error);
4647
});
4748
}
4849

@@ -51,18 +52,14 @@ export default function Register() {
5152
<div className="content">
5253
<section className="">
5354
<h1>Cadastro</h1>
54-
<Link to="/" className="back-link">
55-
<FiArrowLeft size={16} color="007bff" />
56-
Não tenho cadastro
57-
</Link>
5855
</section>
5956
<form onSubmit={handleRegister}>
6057
<input
6158
value={name_establishment}
6259
onChange={(e) => setEst(e.target.value)}
6360
placeholder="Nome"
6461
/>
65-
62+
<br />
6663
<input
6764
value={username}
6865
onChange={(e) => setName(e.target.value)}
@@ -85,12 +82,16 @@ export default function Register() {
8582
placeholder="Confirmar senha"
8683
type="password"
8784
/>
88-
85+
<br/>
8986
<button className="button" type="submit">
9087
Cadastrar
9188
</button>
9289
</form>
9390
</div>
91+
<Link to="/" className="back-link">
92+
<FiArrowLeft size={16} color="b366ff" />
93+
Já tenho cadastro
94+
</Link>
9495
<ToastContainer />
9596
</div>
9697
);

reactapp/src/containers/Base/Layout.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React, { Component } from 'react'
2+
import TopMenu from './Navbar'
23

34
export default class Layout extends Component {
45
render() {
56
return (
67
<div>
7-
8+
<TopMenu />
9+
{this.props.children}
810
</div>
911
)
1012
}

reactapp/src/containers/Base/index.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.header {
2-
background-color: #007bff;
2+
background-color: #b366ff;
33
width: 100%;
44
height: 9vh;
55
line-height: 9vh;

reactapp/src/index.css

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@import url("https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap");
2+
3+
* {
4+
margin: 0;
5+
padding: 0;
6+
outline: 0;
7+
box-sizing: border-box;
8+
}
9+
10+
body {
11+
font: 400 14px Roboto, sans-serif;
12+
background: #f0f0f5;
13+
-webkit-font-smoothing: antialiased;
14+
}

0 commit comments

Comments
 (0)