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

[WIP] 35 changes us20 #62

Merged
merged 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import DataSelect from "../../../../Components/DataSelect";
import FieldText from "../../../../Components/FieldText";
import { getFinancialMovements } from "../../../../Services/FinancialMovementsService";
import "./index.css";

//testes
export default function UserHistoric() {
const { state } = useLocation();
const { nomeCompleto } = state || {};
Expand Down Expand Up @@ -48,10 +48,15 @@ export default function UserHistoric() {
.toLowerCase()
.includes(search.toLowerCase());

const movementDate = new Date(movement.datadePagamento);
const movementDate = new Date(movement.datadeVencimento);
const startDate = dataInicio ? new Date(dataInicio) : null;
const finalDate = dataFinal ? new Date(dataFinal) : null;

const isDateInRange =
(!dataInicio || movementDate >= new Date(dataInicio)) &&
(!dataFinal || movementDate <= new Date(dataFinal));
(!startDate || movementDate >= startDate) &&
(!finalDate || movementDate <= finalDate);

console.log(dataInicio, dataFinal, movementDate, isDateInRange);

return isDocumentTypeMatch && isDateInRange;
});
Expand Down Expand Up @@ -117,9 +122,9 @@ export default function UserHistoric() {
className="pag-sind"
secondary={
<>
Data de pagamento: <br />
Data de vencimento: <br />
{new Date(
movement.datadePagamento
movement.datadeVencimento
).toLocaleDateString()}
</>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import UserHistoric from "./index";
import { getFinancialMovements } from "../../../../Services/FinancialMovementsService";

import "@testing-library/jest-dom";

//testes
vi.mock("react-router-dom", async (importOriginal) => {
const actual = await importOriginal();
return {
Expand Down
24 changes: 15 additions & 9 deletions src/Pages/Protected/FinancialMovements/FinancialCreate/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@media screen and (max-width: 1080px) {
.container {
display: flex;
display: grid;
flex-direction: row;
}

Expand All @@ -26,13 +26,13 @@
grid-template-columns: 0.5fr 0.3fr;
}

h1 {
.forms-container h1 {
font-weight: 800;
margin-bottom: 3rem;
color: #332117 !important;
}

h3 {
.forms-container h3 {
font-weight: 400;
margin-left: 1rem;
margin-top: 3rem;
Expand All @@ -42,11 +42,11 @@
#addDependentBttn {
cursor: pointer;
}
}

@media screen and (max-width: 500px) {
.container {
.descricao-fin {
display: grid;
justify-content: start;
grid-template-columns: 2.5fr;
margin: 0;
}
}

Expand Down Expand Up @@ -89,13 +89,13 @@
color: #332117 !important;
}

h1 {
.forms-container h1 {
font-weight: 800;
margin-bottom: 3rem;
color: #332117 !important;
}

h3 {
.forms-container h3 {
font-weight: 400;
margin-left: 1rem;
margin-top: 3rem;
Expand All @@ -110,4 +110,10 @@
#addDependentBttn {
cursor: pointer;
}
.descricao-fin {
display: grid;
justify-content: start;
grid-template-columns: 2.5fr;
margin: 0;
}
}
46 changes: 18 additions & 28 deletions src/Pages/Protected/FinancialMovements/FinancialCreate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import PrimaryButton from "../../../../Components/PrimaryButton";
import SecondaryButton from "../../../../Components/SecondaryButton";
import "./index.css";
import DataSelect from "../../../../Components/DataSelect";
import CheckField from "../../../../Components/Checkfield";
import { createFinancialMovements } from "../../../../Services/FinancialMovementsService";
import { getUsers } from "../../../../Services/userService";
import { getSupplierForm } from "../../../../Services/supplierService";
Expand All @@ -26,7 +25,6 @@ export default function FinancialCreate() {
const [pagamento, setPagamento] = useState("");
const [dataVencimento, setDataVencimento] = useState(null);
const [dataPagamento, setDataPagamento] = useState(null);
const [baixada, setBaixada] = useState(false);
const [descricao, setDescricao] = useState("");
const [showModal, setShowModal] = useState(false);
const [nomesOrigem, setNomesOrigem] = useState([]);
Expand Down Expand Up @@ -160,11 +158,6 @@ export default function FinancialCreate() {
setPagamento(event.target.value);
};

const handleChangeBaixada = (newChecked) => {
console.log("Baixada:", newChecked);
setBaixada(newChecked);
};

const handleChangeDescricao = (event) => {
const { value } = event.target;
if (value.length <= maxDescricaoLength) {
Expand Down Expand Up @@ -194,7 +187,6 @@ export default function FinancialCreate() {
formadePagamento: pagamento,
datadeVencimento: dataVencimento,
datadePagamento: dataPagamento,
baixada,
descricao,
};

Expand Down Expand Up @@ -336,7 +328,18 @@ export default function FinancialCreate() {
value={desconto}
onChange={(e) => setDesconto(handleCurrencyInput(e.target.value))}
/>

<DataSelect
label="Data de pagamento"
value={dataPagamento}
onChange={(newValue) => setDataPagamento(newValue)}
/>
<DataSelect
label="Data de vencimento *"
value={dataVencimento}
onChange={(newValue) => setDataVencimento(newValue)}
/>
</div>
<div className="descricao-fin">
<FieldSelect
label="Forma de Pagamento *"
value={pagamento}
Expand All @@ -351,28 +354,15 @@ export default function FinancialCreate() {
"Depósito",
]}
/>
<DataSelect
label="Data de vencimento *"
value={dataVencimento}
onChange={(newValue) => setDataVencimento(newValue)}
/>
<DataSelect
label="Data de pagamento *"
value={dataPagamento}
onChange={(newValue) => setDataPagamento(newValue)}
/>
<CheckField
label="Baixada"
value={baixada}
onChange={handleChangeBaixada}
</div>
<div className="descricao-fin">
<FieldText
label="Descrição"
onChange={handleChangeDescricao}
value={descricao}
/>
</div>

<FieldText
label="Descrição"
onChange={handleChangeDescricao}
value={descricao}
/>
<div>
<small>
{descricao.length}/{maxDescricaoLength} caracteres
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createFinancialMovements } from "../../../../Services/FinancialMovement
import "@testing-library/jest-dom";
import userEvent from "@testing-library/user-event";

// Função auxiliar para preencher campos obrigatórios
// Função auxiliar para preencher campos obrigatórioss
async function fillUpRequiredFields() {
const selects = screen.getAllByRole("combobox");

Expand All @@ -27,7 +27,7 @@ async function fillUpRequiredFields() {
(s) => s.id === "select-Forma de Pagamento *"
);
const dataVencimentoInput = screen.getByLabelText("Data de vencimento *");
const dataPagamentoInput = screen.getByLabelText("Data de pagamento *");
const dataPagamentoInput = screen.getByLabelText("Data de pagamento");

await userEvent.click(contaOrigemSelect);
await userEvent.click(screen.getByRole("option", { name: "Fornecedor" }));
Expand Down
14 changes: 9 additions & 5 deletions src/Pages/Protected/FinancialMovements/FinancialList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
};

fetchMovements();
}, []);

Check warning on line 46 in src/Pages/Protected/FinancialMovements/FinancialList/index.jsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'storagedUser.token'. Either include it or remove the dependency array

const handleSubmit = () => {
console.log("Navigating to create page");
Expand All @@ -62,10 +62,14 @@
.toLowerCase()
.includes(search.toLowerCase());

const movementDate = new Date(movement.datadePagamento);
const movementDate = new Date(movement.datadeVencimento);
const startDate = dataInicio ? new Date(dataInicio) : null;
const finalDate = dataFinal ? new Date(dataFinal) : null;

const isDateInRange =
(!dataInicio || movementDate >= new Date(dataInicio)) &&
(!dataInicio || movementDate <= new Date(dataFinal));
(!startDate || movementDate >= startDate) &&
(!finalDate || movementDate <= finalDate);

console.log(dataInicio, dataFinal, movementDate, isDateInRange);

return isDocumentTypeMatch && isDateInRange;
Expand Down Expand Up @@ -120,8 +124,8 @@
>
<ListItemText
primary={movement.tipoDocumento}
secondary={`Data de pagamento: ${new Date(
movement.datadePagamento
secondary={`Data de vencimento: ${new Date(
movement.datadeVencimento
).toLocaleDateString()}`}
/>
<ListItemText secondary={movement.descricao} />
Expand Down
Loading
Loading