Começo da funcionalidade de CPF
This commit is contained in:
parent
f37865d251
commit
cdc6d39f77
@ -13,16 +13,27 @@ const FormNovaConsulta = ({ onCancel }) => {
|
|||||||
if(resultado === false){ setAcessibilidade({...acessibilidade, [id]:true}); console.log('mudou')}
|
if(resultado === false){ setAcessibilidade({...acessibilidade, [id]:true}); console.log('mudou')}
|
||||||
|
|
||||||
else if(resultado === true){ setAcessibilidade({...acessibilidade, [id]:false})}
|
else if(resultado === true){ setAcessibilidade({...acessibilidade, [id]:false})}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log(id)
|
console.log(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const FormatCPF = (valor) => {
|
||||||
|
|
||||||
|
|
||||||
|
console.log(valor)
|
||||||
|
|
||||||
|
const digits = String(valor).replace(/\D/g, '').slice(0, 11);
|
||||||
|
BuscarPacienteExistentePeloCPF(valor)
|
||||||
|
|
||||||
|
return digits
|
||||||
|
.replace(/(\d{3})(\d)/, '$1.$2')
|
||||||
|
.replace(/(\d{3})(\d)/, '$1.$2')
|
||||||
|
.replace(/(\d{3})(\d{1,2})$/, '$1-$2');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const BuscarCPFnoBancodeDados = (cpf) => {
|
|
||||||
|
const BuscarCPFnoBancodeDados = async (cpf) => {
|
||||||
|
|
||||||
var myHeaders = new Headers();
|
var myHeaders = new Headers();
|
||||||
myHeaders.append("Authorization", "Bearer <token>");
|
myHeaders.append("Authorization", "Bearer <token>");
|
||||||
@ -39,17 +50,41 @@ const FormNovaConsulta = ({ onCancel }) => {
|
|||||||
redirect: 'follow'
|
redirect: 'follow'
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requestOptions)
|
const response = await fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requestOptions);
|
||||||
.then(response => response.text())
|
const result = await response.json();
|
||||||
.then(result => console.log(result))
|
return result
|
||||||
.catch(error => console.log('error', error));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const BuscarPacienteExistentePeloCPF = (value) => {
|
const BuscarPacienteExistentePeloCPF = async (value) => {
|
||||||
|
|
||||||
if(isNaN(value[13]) === false){
|
if(isNaN(value[13]) === false && value.length === 14)try {
|
||||||
BuscarCPFnoBancodeDados(value)
|
const result = await BuscarCPFnoBancodeDados(value);
|
||||||
}
|
console.log("Resultado:", result);
|
||||||
|
|
||||||
|
if (result.data.existe === true){
|
||||||
|
|
||||||
|
var myHeaders = new Headers();
|
||||||
|
myHeaders.append("Authorization", "Bearer <token>");
|
||||||
|
|
||||||
|
var requestOptions = {
|
||||||
|
method: 'GET',
|
||||||
|
headers: myHeaders,
|
||||||
|
redirect: 'follow'
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/", requestOptions)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(result => console.log(result))
|
||||||
|
.catch(error => console.log('error', error));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error", error);
|
||||||
|
}
|
||||||
//BuscarCPFnoBancodeDados(value)
|
//BuscarCPFnoBancodeDados(value)
|
||||||
|
|
||||||
|
|
||||||
@ -75,9 +110,9 @@ fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requ
|
|||||||
|
|
||||||
<div className="campo-de-input">
|
<div className="campo-de-input">
|
||||||
<label>CPF do paciente</label>
|
<label>CPF do paciente</label>
|
||||||
<InputMask mask="999.999.999-99" placeholder="000.000.000-00" onChange={(e) => BuscarPacienteExistentePeloCPF(e.target.value)}>
|
|
||||||
{(inputProps) => <input {...inputProps} type="text" name="cpf" />}
|
<input type="text" name="cpf" placeholder="000.000.000-00" onChange={(e) => e.target.value = FormatCPF(e.target.value)} />
|
||||||
</InputMask>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="campo-de-input">
|
<div className="campo-de-input">
|
||||||
@ -133,29 +168,29 @@ fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requ
|
|||||||
|
|
||||||
<div className="icons-container">
|
<div className="icons-container">
|
||||||
|
|
||||||
<div className={`icons-div ${ acessibilidade.cadeirante === true ? 'acessibilidade-ativado' : ''} `} id='cadeirante' onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
<div className={`icons-div ${ acessibilidade.cadeirante === true ? 'acessibilidade-ativado' : ''} `} id='cadeirante' onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||||
|
|
||||||
<span className="material-symbols-outlined icon">accessible</span>
|
<span className="material-symbols-outlined icon">accessible</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={`icons-div ${acessibilidade.idoso === true ? 'acessibilidade-ativado' : ''}`} id="idoso" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
<div className={`icons-div ${acessibilidade.idoso === true ? 'acessibilidade-ativado' : ''}`} id="idoso" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||||
<span className="material-symbols-outlined icon">elderly</span>
|
<span className="material-symbols-outlined icon">elderly</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={`icons-div ${acessibilidade.gravida === true ? 'acessibilidade-ativado' : ''}`} id="gravida" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
<div className={`icons-div ${acessibilidade.gravida === true ? 'acessibilidade-ativado' : ''}`} id="gravida" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||||
<span className="material-symbols-outlined icon">pregnant_woman</span>
|
<span className="material-symbols-outlined icon">pregnant_woman</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={`icons-div ${acessibilidade.bebe === true ? 'acessibilidade-ativado' : ''}`} id="bebe" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
<div className={`icons-div ${acessibilidade.bebe === true ? 'acessibilidade-ativado' : ''}`} id="bebe" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-baby-icon lucide-baby"><path d="M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5"/><path d="M15 12h.01"/><path d="M19.38 6.813A9 9 0 0 1 20.8 10.2a2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1"/><path d="M9 12h.01"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-baby-icon lucide-baby"><path d="M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5"/><path d="M15 12h.01"/><path d="M19.38 6.813A9 9 0 0 1 20.8 10.2a2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1"/><path d="M9 12h.01"/></svg>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={`icons-div ${acessibilidade.autista === true ? 'acessibilidade-ativado' : ''}`} id="autista" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
<div className={`icons-div ${acessibilidade.autista === true ? 'acessibilidade-ativado' : ''}`} id="autista" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-puzzle-icon lucide-puzzle"><path d="M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-puzzle-icon lucide-puzzle"><path d="M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z"/></svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="campo-informacoes-atendimento">
|
<div className="campo-informacoes-atendimento">
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ function PatientCadastroManager( {setCurrentPage} ) {
|
|||||||
.then(result => console.log(result))
|
.then(result => console.log(result))
|
||||||
.catch(error => console.log('error', error));
|
.catch(error => console.log('error', error));
|
||||||
|
|
||||||
alert(`Paciente "${patientData.nome}" salvo com sucesso!`); //altere isso para integração com backend
|
alert(`Paciente "${patientData.nome}" !`); //altere isso para integração com backend
|
||||||
// Após salvar, voltamos para a tela de lista
|
// Após salvar, voltamos para a tela de lista
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -59,9 +59,6 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Função para excluir paciente
|
// Função para excluir paciente
|
||||||
const deletePatient = async (id) => {
|
const deletePatient = async (id) => {
|
||||||
DeleteAnexo(id)
|
DeleteAnexo(id)
|
||||||
@ -79,45 +76,7 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
|||||||
.catch((error) => console.log("Deu problema", error));
|
.catch((error) => console.log("Deu problema", error));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Função para marcar/desmarcar VIP
|
|
||||||
const toggleVIP = async (id, atual) => {
|
|
||||||
const novoStatus = atual === true ? false : true;
|
|
||||||
|
|
||||||
await fetch(
|
|
||||||
`https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`,
|
|
||||||
{
|
|
||||||
method: "PUT",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify({ vip: novoStatus }),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then(() => {
|
|
||||||
setPacientes((prev) =>
|
|
||||||
prev.map((p) => (p.id === id ? { ...p, vip: novoStatus } : p))
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((error) => console.log("Erro ao atualizar VIP:", error));
|
|
||||||
};
|
|
||||||
|
|
||||||
// Função para atualizar convênio/particular
|
|
||||||
const updateConvenio = async (id, convenio) => {
|
|
||||||
await fetch(
|
|
||||||
`https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`,
|
|
||||||
{
|
|
||||||
method: "PUT",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify({ convenio }),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then(() => {
|
|
||||||
setPacientes((prev) =>
|
|
||||||
prev.map((p) => (p.id === id ? { ...p, convenio } : p))
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((error) => console.log("Erro ao atualizar convênio:", error));
|
|
||||||
};
|
|
||||||
|
|
||||||
// Requisição inicial para buscar pacientes
|
// Requisição inicial para buscar pacientes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user