Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2 from n-caro/develop
Browse files Browse the repository at this point in the history
Develop to v1.0.0
  • Loading branch information
n-caro committed Mar 17, 2021
2 parents db40b71 + 82b754e commit 1af4c9c
Show file tree
Hide file tree
Showing 49 changed files with 739 additions and 464 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_APIURL = http://localhost:4000/api
105 changes: 62 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,89 @@
# Getting Started with Create React App
# myBudget-app

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Overview

## Available Scripts
A personal budget management 馃捀 web app built in React and Material UI and **myBudget-api**

In the project directory, you can run:
This is the frontend (client side) of the myBudget app. To see the backend API (server side) visit the repository: [github.com/n-caro/mybudget-backend](https://github.com/n-caro/mybudget-backend)

### `yarn start`
## 1. About myBudget
Some features and dependencies:

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
* 馃帹 Material UI and Material UI icons.
* Axios for API calls
* Form validations with Formik
* React router doom.

The page will reload if you make edits.\
You will also see any lint errors in the console.
## 2. Features
* User registration and authentication
* Create operations of type Income or Expenses
* Edit operations that have already been created
* Delete operations
* View account balance (current balance, total incomes, total expenses)
* List of all operations, with pagination
## 2. Install and usage

### `yarn test`
#### Install

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
```shell
#clone the repository and go

### `yarn build`
$ git clone https://github.com/n-caro/mybudget-frontend.git
$ cd mybudget-frontend

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
#Install dependencies (yarn recommended)
$ yarn install

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
#or npm
$ npm install
```

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
After install dependencies, create a .env file (you can rename `.env.example` file) and set the URL for myBudget-api ([github.com/n-caro/mybudget-backend](https://github.com/n-caro/mybudget-backend))

### `yarn eject`
**.env (example):**

**Note: this is a one-way operation. Once you `eject`, you can鈥檛 go back!**
```
REACT_APP_APIURL = http://localhost:4000/api
```

If you aren鈥檛 satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
#### Usage

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you鈥檙e on your own.
```shell
$ yarn start

You don鈥檛 have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn鈥檛 feel obligated to use this feature. However we understand that this tool wouldn鈥檛 be useful if you couldn鈥檛 customize it when you are ready for it.
#or npm
$ npm start
```

## Learn More
And go to http://localhost:3000

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
## 3. Screenshots
###### Sign up (and validations)
![Sign up and validations](docs/resources/signUp-validations.gif)

To learn React, check out the [React documentation](https://reactjs.org/).
###### Sign in (and validations)
![Sign in](docs/resources/login.gif)

### Code Splitting
###### Add operation
![Add operations](docs/resources/addOperation.gif)

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
###### Edit operation
![Edit operation](docs/resources/edit.gif)

### Analyzing the Bundle Size
###### Delete operation
![Delete operation](docs/resources/delete.gif)

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
###### Operations (and pagination)
![Operations](docs/resources/operations.gif)

### Making a Progressive Web App
###### Menu
![Sign in](docs/resources/actions-logout.gif)

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
## 4. Upcoming Features

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `yarn build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
* Operations: Filter by type
* Operations: Select limit of results per page
* Loading bar when API calls are made
* Store and Actions for Operations (Redux or UseContext and useDispatch)
* Animations for route change and data loading
* Reports page (graphs) [Requires API update]
Binary file added docs/resources/actions-logout.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/addOperation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/delete.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/edit.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/login.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/operations.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/signUp-validations.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
"moment": "^2.29.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-helmet": "^6.1.0",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"redux": "^4.0.5",
"web-vitals": "^1.0.1",
"yup": "^0.32.9"
},
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>myBudget</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Be+Vietnam:wght@300;400;500;700&display=swap" rel="stylesheet">
</head>
Expand Down
Binary file modified public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
}

.App {
padding-top: 100px;
padding-top: 120px;
}

@media only screen and (max-width: 600px) {
.App {
padding-top: 150px;
padding-top: 160px;
}
}
52 changes: 40 additions & 12 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,54 @@ import Operations from "pages/Operations";
import Home from "pages/Home";

import Header from "components/Header";
import Footer from "components/Footer";
import Container from "@material-ui/core/Container";
import { makeStyles } from "@material-ui/core/styles";

function App() {
const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
flexDirection: "column",
minHeight: "100vh",
paddingTop: "100px",
[theme.breakpoints.down("xs")]: {
paddingTop: "160px",
},
},
main: {
marginBottom: theme.spacing(3),
},
footer: {
padding: theme.spacing(3, 2),
marginTop: "auto",
backgroundColor:
theme.palette.type === "light"
? theme.palette.grey[50]
: theme.palette.grey[800],
},
}));

function App() {
const classes = useStyles();
return (
<Router>
<UserContextProvider>
<div className="App">
<div className={classes.root}>
<Header />
<Container maxWidth="md">
<Switch>
<Route path="/signin" component={SignIn} />
<Route path="/signup" component={SignUp} />
<Route exact path="/add" component={Add} />
<Route exact path="/edit" component={Edit} />
<Route exact path="/operations" component={Operations} />
<Route exact path="/" component={Home} />
<Route path="*" component={NotFound} />
</Switch>
<Container maxWidth="md" className={classes.main}>
<Switch>
<Route path="/signin" component={SignIn} />
<Route path="/signup" component={SignUp} />
<Route exact path="/add" component={Add} />
<Route exact path="/edit" component={Edit} />
<Route exact path="/operations" component={Operations} />
<Route exact path="/" component={Home} />
<Route path="*" component={NotFound} />
</Switch>
</Container>
<footer className={classes.footer}>
<Footer />
</footer>
</div>
</UserContextProvider>
</Router>
Expand Down
25 changes: 11 additions & 14 deletions src/components/Add/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { Container, Box, Typography } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles";
import OperationAddForm from "components/OperationAddForm";
import { useEffect } from "react";
import { useState, useContext } from "react";
import { getCategories } from 'services/Categories'
import UserContext from "context/UserContext";
import { useState } from "react";
import { getCategories } from "services/Categories";

const useStyles = makeStyles((theme) => ({
title: {
Expand All @@ -14,25 +13,23 @@ const useStyles = makeStyles((theme) => ({

export default function Add() {
const classes = useStyles();
const { session } = useContext(UserContext);
const [categories, setCategories] = useState([]);

useEffect(() => {
console.log("cargar categorias")
let token = session.token;
getCategories({token})
.then(res => {
if(res.categories){
setCategories(res.categories)
getCategories().then((res) => {
if (res.categories) {
setCategories(res.categories);
}
})
}, [session])
});
}, []);

return (
<Container maxWidth="sm">
<Typography variant="h6" className={classes.title}>Add operation</Typography>
<Typography variant="h6" className={classes.title}>
Add operation
</Typography>
<Box>
<OperationAddForm categories={categories}/>
<OperationAddForm categories={categories} />
</Box>
</Container>
);
Expand Down
98 changes: 91 additions & 7 deletions src/components/Balance/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,98 @@
import { Card, CardContent, Typography } from "@material-ui/core";
import {
Avatar,
Card,
CardContent,
Grid,
makeStyles,
Typography,
} from "@material-ui/core";
import TrendingUpRoundedIcon from "@material-ui/icons/TrendingUpRounded";
import TrendingDownRoundedIcon from "@material-ui/icons/TrendingDownRounded";
import { green, red } from "@material-ui/core/colors";

export default function Balance({ amount }) {
const useStyles = makeStyles((theme) => ({
root: {
boxShadow:
"rgb(145 158 171 / 24%) 0px 0px 2px 0px,rgb(145 158 171 / 24%) 0px 16px 32px -4px",
padding: theme.spacing(2),
marginBottom: theme.spacing(1),
},
}));

function CardTotal({ amount, title, isIncome, isExpense }) {
const classes = useStyles();
return (
<Card>
<Card className={classes.root}>
<CardContent>
<Typography variant="h6" color="textSecondary" gutterBottom>
Current balance
</Typography>
<Typography variant="h3">$ {!isNaN(amount) ? amount.toFixed(2) : "..."}</Typography>
<Grid
container
direction="row"
justify="center"
alignItems="center"
spacing={2}
>
<Grid item>
{isIncome && (
<Avatar style={{ color: green[500], background: green[50] }}>
<TrendingUpRoundedIcon fontSize="small" />
</Avatar>
)}
{isExpense && (
<Avatar style={{ color: red[500], background: red[50] }}>
<TrendingDownRoundedIcon fontSize="small" />
</Avatar>
)}
</Grid>
<Grid item>
<Typography
variant="caption"
style={{ fontWeight: 700 }}
color="textSecondary"
>
{title}
</Typography>
<Typography variant="h6">
{!isNaN(amount) ? "$" + amount.toFixed(2) : "..."}
</Typography>
</Grid>
</Grid>
</CardContent>
</Card>
);
}

export default function Balance({
amountBalance,
amountIncomes,
amountExpenses,
}) {
const classes = useStyles();
return (
<>
<Grid container spacing={3}>
<Grid item xs={12}>
<Card className={classes.root}>
<CardContent align="center">
<Typography variant="h4" gutterBottom>
{!isNaN(amountBalance) ? "$" + amountBalance.toFixed(2) : "..."}
</Typography>
<Typography
variant="subtitle2"
color="textSecondary"
style={{ fontWeight: 700 }}
>
Current balance
</Typography>
</CardContent>
</Card>
</Grid>
<Grid item xs={12} sm={6}>
<CardTotal title="Total incomes" isIncome amount={amountIncomes} />
</Grid>
<Grid item xs={12} sm={6}>
<CardTotal title="Total expenses" isExpense amount={amountExpenses} />
</Grid>
</Grid>
</>
);
}
Loading

0 comments on commit 1af4c9c

Please sign in to comment.