From 54994f5c31cce5785592a66eeec35aabbf498f1d Mon Sep 17 00:00:00 2001 From: storch7 Date: Thu, 29 Aug 2024 22:11:34 -0300 Subject: [PATCH 1/3] =?UTF-8?q?[fix]=20modifica=C3=A7=C3=B5es=20da=20us105?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 15 ------- src/Pages/Public/MemberShip/index.jsx | 62 ++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index d74067f4..82e20ab1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3947,21 +3947,6 @@ "node": ">=16.17.0" } }, - "node_modules/husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", - "dev": true, - "bin": { - "husky": "lib/bin.js" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", diff --git a/src/Pages/Public/MemberShip/index.jsx b/src/Pages/Public/MemberShip/index.jsx index 06b7a871..285e80d9 100644 --- a/src/Pages/Public/MemberShip/index.jsx +++ b/src/Pages/Public/MemberShip/index.jsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import "./index.css"; import "../../../index.css"; import dayjs from "dayjs"; @@ -13,6 +13,7 @@ import Alert from "@mui/material/Alert"; import SecondaryButton from "../../../Components/SecondaryButton"; import Modal from "../../../Components/Modal"; import { useNavigate } from "react-router-dom"; +import { listOrgans } from "../../../Services/organService"; const MemberShip = () => { const [email, setEmail] = useState(""); @@ -54,6 +55,8 @@ const MemberShip = () => { const [errors, setErrors] = useState({}); const [touchedFields, setTouchedFields] = useState({}); const [unfilledDependent, setUnfilledDependent] = useState(false); + const [orgaosList, setOrgaosList] = useState([]); + const [lotacaoList, setLotacaoList] = useState([]); const navigate = useNavigate(); // Function to validate a field @@ -298,11 +301,46 @@ const MemberShip = () => { return emailRegex.test(email); }; + //FUNÇÕES UTILIZADAS + useEffect(() => { + const getOrgaos = async () => { + try { + const orgaos = await listOrgans(); // Presumindo que listOrgans faz a requisição ao backend + + if (Array.isArray(orgaos)) { + // Extraindo valores únicos de órgãos + const uniqueOrgaos = [...new Set(orgaos.map((orgao) => orgao.orgao))]; + + // Extraindo valores únicos de lotações + const uniqueLotacoes = [ + ...new Set( + orgaos.flatMap((orgao) => + orgao.lotacao.map((lotacao) => lotacao.nomeLotacao) + ) + ), + ]; + + setOrgaosList(uniqueOrgaos); + setLotacaoList(uniqueLotacoes); + + console.log("Lista de Órgãos:", uniqueOrgaos); + console.log("Lista de Lotações:", uniqueLotacoes); + } else { + console.error("Os dados recebidos não são um array."); + } + } catch (error) { + console.error("Erro ao buscar órgãos:", error); + } + }; + + getOrgaos(); + }, []); + const handleSubmit = () => { const erros = {}; if (!email) erros.email = 1; - //if (!sexo) erros.sexo = 1; + if (!sexo) erros.sexo = 1; //if (!estadoCivil) erros.estadoCivil = 1; //if (!tipoSanguineo) erros.tipoSanguineo = 1; //if (!uf_naturalidade) erros.uf_naturalidade = 1; @@ -313,12 +351,12 @@ const MemberShip = () => { //if (!dataDeNascimento) erros.dataDeNascimento = 1; //if (!dataExpedicao) erros.dataExpedicao = 1; //if (!cargo) erros.cargo = 1; - //if (!lotacao) erros.lotacao = 1; + if (!lotacao) erros.lotacao = 1; if (!matricula) erros.matricula = 1; if (!nomeCompleto) erros.nomeCompleto = 1; //if (!naturalidade) erros.naturalidade = 1; if (!rg) erros.rg = 1; - //if (!orgao) erros.orgao = 1; + if (!orgao) erros.orgao = 1; if (!cpf) erros.cpf = 1; //if (!nomeDaMae) erros.nomeDaMae = 1; //if (!nomeDoPai) erros.nomeDoPai = 1; @@ -441,7 +479,7 @@ const MemberShip = () => { /> { /> { onBlur={(e) => handleBlur(e, "dataContratacao")} erro={erro("dataContratacao")} /> - setlotacao(e.target.value)} + options={lotacaoList} onBlur={(e) => handleBlur(e, "lotacao")} erro={erro("lotacao")} /> - setOrgao(e.target.value)} + options={orgaosList} onBlur={(e) => handleBlur(e, "orgao")} erro={erro("orgao")} /> + Date: Sun, 1 Sep 2024 22:28:21 -0300 Subject: [PATCH 2/3] =?UTF-8?q?[ehn:02]=20ajuste=20do=20m=C3=A9todo=20de?= =?UTF-8?q?=20checkagem=20e=20coment=C3=A1rios=20de=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Pages/Public/MemberShip/index.jsx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Pages/Public/MemberShip/index.jsx b/src/Pages/Public/MemberShip/index.jsx index 285e80d9..927d2246 100644 --- a/src/Pages/Public/MemberShip/index.jsx +++ b/src/Pages/Public/MemberShip/index.jsx @@ -339,8 +339,18 @@ const MemberShip = () => { const handleSubmit = () => { const erros = {}; + //CAMPOS PBRIGATÓRIOS if (!email) erros.email = 1; if (!sexo) erros.sexo = 1; + if (!lotacao) erros.lotacao = 1; + if (!nomeCompleto) erros.nomeCompleto = 1; + if (!matricula) erros.matricula = 1; + if (!rg) erros.rg = 1; + if (!orgao) erros.orgao = 1; + if (!cpf) erros.cpf = 1; + if (!celular) erros.celular = 1; + + // CAMPOS NÃO OBRIGATÓRIOS //if (!estadoCivil) erros.estadoCivil = 1; //if (!tipoSanguineo) erros.tipoSanguineo = 1; //if (!uf_naturalidade) erros.uf_naturalidade = 1; @@ -351,13 +361,7 @@ const MemberShip = () => { //if (!dataDeNascimento) erros.dataDeNascimento = 1; //if (!dataExpedicao) erros.dataExpedicao = 1; //if (!cargo) erros.cargo = 1; - if (!lotacao) erros.lotacao = 1; - if (!matricula) erros.matricula = 1; - if (!nomeCompleto) erros.nomeCompleto = 1; //if (!naturalidade) erros.naturalidade = 1; - if (!rg) erros.rg = 1; - if (!orgao) erros.orgao = 1; - if (!cpf) erros.cpf = 1; //if (!nomeDaMae) erros.nomeDaMae = 1; //if (!nomeDoPai) erros.nomeDoPai = 1; //if (!cep) erros.cep = 1; @@ -365,15 +369,16 @@ const MemberShip = () => { //if (!logradouro) erros.logradouro = 1; //if (!complemento) erros.complemento = 1; //if (!telefone) erros.telefone = 1; - if (!celular) erros.celular = 1; //if (!postoDeTrabalho) erros.postoDeTrabalho = 1; //if (!orgaoExpedidor) erros.orgaoExpedidor = 1; //if (!religiao) erros.religiao = 1; + //if (telefone.length < 14) erros.telefone = 1; + //if (cep.length < 9) erros.cep = 1; + + //VALIDAÇÕES DE CAMPO if (isValidEmail(email) === false) erros.email = 1; if (cpf.length < 14) erros.cpf = 1; if (rg.length < 7) erros.rg = 1; - //if (cep.length < 9) erros.cep = 1; - //if (telefone.length < 14) erros.telefone = 1; if (celular.length < 15) erros.celular = 1; if (Object.keys(erros).length > 0) { From 5e1757186f6b1a7889257b685d15b83ba47f4c53 Mon Sep 17 00:00:00 2001 From: storch7 Date: Wed, 4 Sep 2024 22:49:53 -0300 Subject: [PATCH 3/3] =?UTF-8?q?[fix:105]=20modifica=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Pages/Public/MemberShip/index.jsx | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Pages/Public/MemberShip/index.jsx b/src/Pages/Public/MemberShip/index.jsx index 927d2246..1fd71aec 100644 --- a/src/Pages/Public/MemberShip/index.jsx +++ b/src/Pages/Public/MemberShip/index.jsx @@ -719,12 +719,7 @@ const MemberShip = () => { - handleDependentChange( - "nomeCompletoDependente", - e.target.value - ) - } + onChange={(e) => handleDependentChange("nomeCompletoDependente", e.target.value)} /> { - handleDependentChange( - "cpfDependente", - mascaraCPF(e.target.value) - ) - } + onChange={(e) => handleDependentChange("cpfDependente",mascaraCPF(e.target.value))} />