From 7f5127be9bbd6ac4c1f24be4f94cd6de17724f67 Mon Sep 17 00:00:00 2001 From: GustavoHaubert Date: Sun, 28 Jul 2024 09:04:03 -0300 Subject: [PATCH] =?UTF-8?q?feature:=20cria=20p=C3=A1gina=20de=20edi=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20contratos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: #5 --- src/components/containers/StatusButton.js | 36 ++++++ src/components/forms/EditContractForm.js | 138 ++++++++++++++++++---- src/style/components/editContractForm.css | 92 +++++++++++++++ 3 files changed, 246 insertions(+), 20 deletions(-) create mode 100644 src/components/containers/StatusButton.js create mode 100644 src/style/components/editContractForm.css diff --git a/src/components/containers/StatusButton.js b/src/components/containers/StatusButton.js new file mode 100644 index 00000000..0abbc112 --- /dev/null +++ b/src/components/containers/StatusButton.js @@ -0,0 +1,36 @@ +import React, { useState } from 'react'; + +function StatusButton() { + // Estado para armazenar se o status está "Ativo" ou "Inativo" + const [isActive, setIsActive] = useState(false); + + // Função para alternar o estado + const toggleStatus = () => { + setIsActive(!isActive); + }; + + return ( +
+ {/* Botão que chama a função toggleStatus ao ser clicado */} + +
+ ); +} + +export default StatusButton; diff --git a/src/components/forms/EditContractForm.js b/src/components/forms/EditContractForm.js index a9121a77..519ca3c3 100644 --- a/src/components/forms/EditContractForm.js +++ b/src/components/forms/EditContractForm.js @@ -1,31 +1,129 @@ -import React from "react"; +import React, { useState } from "react"; +import { toast } from "react-toastify"; import Navbar from "../navbar/Navbar"; -import { FontSizeIcon } from "@radix-ui/react-icons"; +import "../../style/components/editContractForm.css"; +import { createContract, getContract } from "../../services/contractService"; +import StatusButton from "../containers/StatusButton"; +export default function EditContractForm() { + const [numero, setNumero] = useState(''); + const [nomeGestor, setNomeGestor] = useState(''); + const [descricao, setDescricao] = useState(''); + const [dataInicio, setDataInicio] = useState(new Date(Date.now()).toISOString()); + const [dataFim, setDataFim] = useState(new Date(Date.now()).toISOString()); + const ativo = false + + + const handleSubmit = async (e) => { + e.preventDefault(); + const formData = { + numero, + nomeGestor, + descricao, + dataInicio: new Date(dataInicio).toISOString(), + dataFim: new Date(dataInicio).toISOString(), + ativo + + }; + console.log("Form data:", formData); + + const response = await createContract(formData); + + if(response.type === "success") { + toast.success("Contrato criado com sucesso!") + } else { + if(response.error.response.status === 400){ + toast.error("Este número de contrato ja existe!") + } + else{ + toast.error("Erro ao criar contrato!") + } + } + }; -export default function EditContractForm(){ return ( <> - -
-

Edição de Contratos

+
- - - - - - - - - - +

Edição de Contrato

+
+
+ + +
+ + +
+ + +
+
- - -
+ + +
- ); } diff --git a/src/style/components/editContractForm.css b/src/style/components/editContractForm.css new file mode 100644 index 00000000..3bbce96c --- /dev/null +++ b/src/style/components/editContractForm.css @@ -0,0 +1,92 @@ +#padraoPagina{ + color: #0D3D6D; + margin-left: 100px; + margin-top: 50px; +} + +#titulo{ + border-bottom: #0D3D6D; + border-bottom-style: solid; + width: fit-content; + padding-bottom: 15px; +} + +#label{ + display: flex; + flex-direction: column; + width: 400px; + margin-bottom: 40px; + font-size: 25px; +} + +.ContratoStatus{ + display: flex; + justify-content: space-between; + width: 61vw; + +} + + +#inputData{ + display: flex; +} + +#inputDescricao{ + width: 900px; + margin-top: 5px; + height: 35px; + border-radius: 10px; + border-color: #0D3D6D; + border-style: solid; + padding-left: 20px; +} + +#inputCampos{ + margin-top: 5px; + height: 35px; + border-radius: 10px; + border-color: #0D3D6D; + border-style: solid; + padding-inline: 20px; +} + +::placeholder{ + font-size: 18px; + opacity: 0.6; + font-family: Jost; +} + +.campoDataTermino{ + margin-left: 105px; +} + +.botaoSalvar{ + background-color: #006633; + height: 40px; + width: 20vw; + color: white; + font-size: 20px; + border-radius: 20px; + border-style: none; + font-family: Jost; + font-weight: 700; +} + +.botaoCancelar{ + background-color: red; + height: 40px; + width: 10vw; + margin-left: 100px; + font-size: 20px; + border-radius: 20px; + color: white; + border-style: none; + font-weight: 700; + font-family: Jost; +} + +.inputDataInicio{ + font-size: 18px; + opacity: 0.6; + font-family: Jost; +} \ No newline at end of file