Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparando review #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Preparando review #1

wants to merge 1 commit into from

Conversation

sidneyouteiro
Copy link

No description provided.

Copy link
Author

@sidneyouteiro sidneyouteiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Olá! Eu gostei bastante das soluções que você desenvolveu ao longo do projeto,
só tenho a acrescentar algumas coisas quanto a semântica.
Buscar por mensagens de commits mais descritivos e usar o .gitignore para ignorar o node_modules.
Bom trabalho!

<form onSubmit={addRegister}>
<Input type="number" value={amount} setValue={setAmount} disabled={loading} placeholder="Valor" />
<Input type="text" value={description} setValue={setDescription} disabled={loading} placeholder="Descrição" />
<Button type="submit">{loading ? <ThreeDots /> : "Salvar entrada"}</Button>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gostei bastante desse recurso visual. Bom trabalho! 👍🏽

Comment on lines -1 to -54
import Input from "./Input";
import Button from "./Button";
import {Container, Back} from "./Styles";
import { Link, useHistory } from "react-router-dom";
import UserContext from './contexts/UserContext';
import { useContext, useState } from "react";
import axios from "axios";
import ThreeDots from "./ThreeDots";

export default function CashOut() {
const { user } = useContext(UserContext);
const [amount, setAmount] = useState("");
const [description, setDescription] = useState("");
const [loading, setLoading] = useState(false);
const history = useHistory()

function addNewRegister(e) {
e.preventDefault();

const config = { headers: { Authorization: `Bearer ${user}` } };

if (amount >= 0) return alert("Você deve adicionar saídas com valores negativos!")

const number = amount?.replace(",", ".")
const value = Number(number).toFixed(2) * 100;
const body = { value, description };

const request = axios.post(`http://localhost:4000/cashout`, body, config);
setLoading(true);
request.then(() => {
setAmount("");
setDescription("");
history.push("/home")
setLoading(false);
})
request.catch(() => {
alert("Algo deu errado!")
setLoading(false);
})
}
return (
<>
<Container>
<p>Nova Saída</p>
<form onSubmit={addNewRegister}>
<Input type="number" value={amount} setValue={setAmount} disabled={loading} placeholder="Valor" />
<Input type="text" value={description} setValue={setDescription} disabled={loading} placeholder="Descrição" />
<Button type="submit">{loading ? <ThreeDots /> : "Salvar saída"}</Button>
</form>
</Container>
<Link to="/home"><Back>Voltar</Back></Link>
</>
)
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poderíamos ter um componente só para lidar com a entrada e saída e fazer o controle através de uma variável isso reduziria o código duplicado.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant