Commit ·
10ed4af
1
Parent(s): 54420c0
refactor: change dashboard section
Browse files- web/.eslintcache +0 -1
- web/src/App.js +2 -1
- web/src/Pages/Dashboard/index.js +62 -0
- web/src/Pages/Dashboard/style.js +24 -0
- web/src/Pages/Statement/index.js +32 -0
- web/src/Pages/Statement/style.js +16 -0
web/.eslintcache
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
[{"D:\\Projetos\\frontend-shawn-and-partner\\src\\index.js":"1","D:\\Projetos\\frontend-shawn-and-partner\\src\\App.js":"2","D:\\Projetos\\frontend-shawn-and-partner\\src\\utils\\api.js":"3","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserList\\index.js":"4","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserCard\\index.js":"5","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserCard\\style.js":"6","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserList\\style.js":"7","D:\\Projetos\\frontend-shawn-and-partner\\src\\styles\\index.js":"8","D:\\Projetos\\frontend-shawn-and-partner\\src\\utils\\router.js":"9","D:\\Projetos\\frontend-shawn-and-partner\\src\\utils\\Router.js":"10","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserDetails\\index.js":"11","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserCardSkeleton\\index.js":"12","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserCardSkeleton\\style.js":"13","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserDetails\\style.js":"14","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\RepositoriesTable\\index.js":"15","D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\RepositoriesTable\\style.js":"16","D:\\Projetos\\warren-code-challenge\\web\\src\\index.js":"17","D:\\Projetos\\warren-code-challenge\\web\\src\\App.js":"18","D:\\Projetos\\warren-code-challenge\\web\\src\\styles\\index.js":"19","D:\\Projetos\\warren-code-challenge\\web\\src\\components\\Dashboard\\index.js":"20","D:\\Projetos\\warren-code-challenge\\web\\src\\components\\Statement\\index.js":"21","D:\\Projetos\\warren-code-challenge\\web\\src\\components\\Header\\index.js":"22","D:\\Projetos\\warren-code-challenge\\web\\src\\components\\Dashboard\\style.js":"23"},{"size":432,"mtime":1611170824604,"results":"24","hashOfConfig":"25"},{"size":348,"mtime":1611459787158,"results":"26","hashOfConfig":"25"},{"size":1383,"mtime":1611510777828,"results":"27","hashOfConfig":"25"},{"size":2854,"mtime":1611469318735,"results":"28","hashOfConfig":"25"},{"size":403,"mtime":1611458356841,"results":"29","hashOfConfig":"25"},{"size":523,"mtime":1611513220728,"results":"30","hashOfConfig":"25"},{"size":439,"mtime":1611512663097,"results":"31","hashOfConfig":"25"},{"size":497,"mtime":1611513093002,"results":"32","hashOfConfig":"25"},{"size":0,"mtime":1611182955112,"results":"33","hashOfConfig":"25"},{"size":465,"mtime":1611184891822,"results":"34","hashOfConfig":"25"},{"size":1958,"mtime":1611510760196,"results":"35","hashOfConfig":"25"},{"size":981,"mtime":1611519717219,"results":"36","hashOfConfig":"25"},{"size":557,"mtime":1611519072348,"results":"37","hashOfConfig":"25"},{"size":725,"mtime":1611518872721,"results":"38","hashOfConfig":"25"},{"size":1528,"mtime":1611469733827,"results":"39","hashOfConfig":"25"},{"size":922,"mtime":1611519016991,"results":"40","hashOfConfig":"25"},{"size":432,"mtime":1611170824604,"results":"41","hashOfConfig":"42"},{"size":141,"mtime":1613551044942,"results":"43","hashOfConfig":"44"},{"size":497,"mtime":1611513093002,"results":"45","hashOfConfig":"42"},{"size":324,"mtime":1613551036481,"results":"46","hashOfConfig":"44"},{"size":114,"mtime":1613550181510,"results":"47","hashOfConfig":"44"},{"size":207,"mtime":1613549834831,"results":"48","hashOfConfig":"44"},{"size":216,"mtime":1613551071236,"results":"49","hashOfConfig":"44"},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},"17ttc5q",{"filePath":"53","messages":"54","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"55","messages":"56","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"57","messages":"58","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"59","messages":"60","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"61","messages":"62","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"63","messages":"64","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"65","messages":"66","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"67","messages":"68","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"69","messages":"70","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"71","messages":"72","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"75","messages":"76","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"77","messages":"78","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"81","messages":"82","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"83","messages":"84","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"85"},"1tvfta5",{"filePath":"86","messages":"87","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"2pmbrd",{"filePath":"88","messages":"89","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"90"},{"filePath":"91","messages":"92","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"93","messages":"94","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"95","messages":"96","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"97","messages":"98","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"D:\\Projetos\\frontend-shawn-and-partner\\src\\index.js",[],["99","100"],"D:\\Projetos\\frontend-shawn-and-partner\\src\\App.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\utils\\api.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserList\\index.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserCard\\index.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserCard\\style.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserList\\style.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\styles\\index.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\utils\\router.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\utils\\Router.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserDetails\\index.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserCardSkeleton\\index.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserCardSkeleton\\style.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\UserDetails\\style.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\RepositoriesTable\\index.js",[],"D:\\Projetos\\frontend-shawn-and-partner\\src\\components\\RepositoriesTable\\style.js",[],"D:\\Projetos\\warren-code-challenge\\web\\src\\index.js",[],["101","102"],"D:\\Projetos\\warren-code-challenge\\web\\src\\App.js",[],"D:\\Projetos\\warren-code-challenge\\web\\src\\styles\\index.js",[],["103","104"],"D:\\Projetos\\warren-code-challenge\\web\\src\\components\\Dashboard\\index.js",[],"D:\\Projetos\\warren-code-challenge\\web\\src\\components\\Statement\\index.js",[],"D:\\Projetos\\warren-code-challenge\\web\\src\\components\\Header\\index.js",[],"D:\\Projetos\\warren-code-challenge\\web\\src\\components\\Dashboard\\style.js",[],{"ruleId":"105","replacedBy":"106"},{"ruleId":"107","replacedBy":"108"},{"ruleId":"105","replacedBy":"109"},{"ruleId":"107","replacedBy":"110"},{"ruleId":"105","replacedBy":"111"},{"ruleId":"107","replacedBy":"112"},"no-native-reassign",["113"],"no-negated-in-lhs",["114"],["113"],["114"],["113"],["114"],"no-global-assign","no-unsafe-negation"]
|
|
|
|
|
|
web/src/App.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import './App.css';
|
| 2 |
-
import
|
|
|
|
| 3 |
|
| 4 |
function App() {
|
| 5 |
return <Dashboard />;
|
|
|
|
| 1 |
import './App.css';
|
| 2 |
+
import React from 'react';
|
| 3 |
+
import Dashboard from './Pages/Dashboard';
|
| 4 |
|
| 5 |
function App() {
|
| 6 |
return <Dashboard />;
|
web/src/Pages/Dashboard/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useEffect, useState } from 'react';
|
| 2 |
+
import Statement from '../Statement';
|
| 3 |
+
import Header from '../../components/Header';
|
| 4 |
+
import { Container, TransactionButton } from './style';
|
| 5 |
+
import Modal from '../../components/Modal';
|
| 6 |
+
import { getUserDetails, getUserStatement } from '../../utils/api';
|
| 7 |
+
import { statementFormatter } from '../../utils/informationFormatters';
|
| 8 |
+
|
| 9 |
+
function Dashboard(props) {
|
| 10 |
+
const [showModal, setShowModal] = useState(false);
|
| 11 |
+
const [loading, setLoading] = useState(true);
|
| 12 |
+
const [userStatement, setUserStatement] = useState(undefined);
|
| 13 |
+
const [userInformation, setUserInformation] = useState(undefined);
|
| 14 |
+
|
| 15 |
+
useEffect(() => {
|
| 16 |
+
fetchAllIData();
|
| 17 |
+
}, []);
|
| 18 |
+
|
| 19 |
+
const fetchAllIData = async () => {
|
| 20 |
+
await fetchUserStatement();
|
| 21 |
+
await fetchUserInformation();
|
| 22 |
+
setLoading(false);
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
const fetchUserInformation = async () => {
|
| 26 |
+
const userInfo = await getUserDetails(process.env.REACT_APP_USER_ID);
|
| 27 |
+
setUserInformation(userInfo.body);
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
const fetchUserStatement = async () => {
|
| 31 |
+
const userStatementData = await getUserStatement(
|
| 32 |
+
process.env.REACT_APP_USER_ID,
|
| 33 |
+
0,
|
| 34 |
+
10,
|
| 35 |
+
1
|
| 36 |
+
);
|
| 37 |
+
const formattedStatement = userStatementData.body.map((statement) => {
|
| 38 |
+
return statementFormatter(statement);
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
setUserStatement(formattedStatement);
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
return (
|
| 45 |
+
<div>
|
| 46 |
+
<Container>
|
| 47 |
+
<Header loading={loading} userInformation={userInformation} />
|
| 48 |
+
<Statement loading={loading} statement={userStatement} />
|
| 49 |
+
<TransactionButton onClick={() => setShowModal(true)}>
|
| 50 |
+
Fazer Transação
|
| 51 |
+
</TransactionButton>
|
| 52 |
+
<Modal
|
| 53 |
+
show={showModal}
|
| 54 |
+
onClose={() => setShowModal(false)}
|
| 55 |
+
userId={userInformation && userInformation._id}
|
| 56 |
+
/>
|
| 57 |
+
</Container>
|
| 58 |
+
</div>
|
| 59 |
+
);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
export default Dashboard;
|
web/src/Pages/Dashboard/style.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import styled from 'styled-components';
|
| 2 |
+
|
| 3 |
+
export const Container = styled.div`
|
| 4 |
+
width: 100%;
|
| 5 |
+
display: flex;
|
| 6 |
+
flex-direction: column;
|
| 7 |
+
justify-content: center;
|
| 8 |
+
align-items: center;
|
| 9 |
+
margin-top: 15px;
|
| 10 |
+
`;
|
| 11 |
+
|
| 12 |
+
export const TransactionButton = styled.button`
|
| 13 |
+
font-size: 18px;
|
| 14 |
+
text-transform: uppercase;
|
| 15 |
+
border-radius: 100px;
|
| 16 |
+
line-height: 24px;
|
| 17 |
+
background-color: var(--pink);
|
| 18 |
+
color: var(--white);
|
| 19 |
+
cursor: pointer;
|
| 20 |
+
border: none;
|
| 21 |
+
padding: 8px 24px;
|
| 22 |
+
letter-spacing: 0;
|
| 23 |
+
font-weight: 600;
|
| 24 |
+
`;
|
web/src/Pages/Statement/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useState } from 'react';
|
| 2 |
+
import SkeletonTransaction from '../../components/SkeletonTransaction';
|
| 3 |
+
import StatementTransaction from '../../components/StatementTransaction';
|
| 4 |
+
import { Container } from './style';
|
| 5 |
+
|
| 6 |
+
function Statement(props) {
|
| 7 |
+
const loading = props.loading;
|
| 8 |
+
const statement = props.statement;
|
| 9 |
+
|
| 10 |
+
return (
|
| 11 |
+
<Container>
|
| 12 |
+
<h2>Últimas movimentações</h2>
|
| 13 |
+
<div>
|
| 14 |
+
{loading && !statement && <SkeletonTransaction transactions={5} />}
|
| 15 |
+
{statement &&
|
| 16 |
+
statement.map((transaction,index) => {
|
| 17 |
+
return (
|
| 18 |
+
<StatementTransaction
|
| 19 |
+
loading={loading}
|
| 20 |
+
category={transaction.category}
|
| 21 |
+
created_at={transaction.created_at}
|
| 22 |
+
amount={transaction.amount}
|
| 23 |
+
key={index}
|
| 24 |
+
/>
|
| 25 |
+
);
|
| 26 |
+
})}
|
| 27 |
+
</div>
|
| 28 |
+
</Container>
|
| 29 |
+
);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
export default Statement;
|
web/src/Pages/Statement/style.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import styled from 'styled-components';
|
| 2 |
+
|
| 3 |
+
export const Container = styled.div`
|
| 4 |
+
margin-top: 32px;
|
| 5 |
+
display: flex;
|
| 6 |
+
flex-direction: column;
|
| 7 |
+
|
| 8 |
+
h2 {
|
| 9 |
+
margin: 0;
|
| 10 |
+
text-align: center;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
div {
|
| 14 |
+
justify-content: center;
|
| 15 |
+
}
|
| 16 |
+
`;
|