Compare commits
2 Commits
84c14fdb06
...
c060fd7a4f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c060fd7a4f | ||
|
|
bdabcf9f60 |
@ -52,17 +52,7 @@ font-weight: 600;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Ajuste para a classe calendario, se for usada */
|
/* Ajuste para a classe calendario, se for usada */
|
||||||
/*
|
|
||||||
.calendario {
|
|
||||||
margin-top: 20px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
border-radius: 10px;
|
|
||||||
overflow: hidden;
|
|
||||||
box-shadow: 0 4px 12px rgb(255, 255, 255);
|
|
||||||
border: 10px solid #ffffffc5;
|
|
||||||
background-color: rgb(253, 253, 253);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
.mostrar-horario td, .mostrar-horario th {
|
.mostrar-horario td, .mostrar-horario th {
|
||||||
|
|||||||
44
src/components/Estilo/TrocardePerfis.css
Normal file
44
src/components/Estilo/TrocardePerfis.css
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
.perfil-button, .selecionado{
|
||||||
|
margin: 8px;
|
||||||
|
margin-left:0px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
font-size: 15px;
|
||||||
|
|
||||||
|
width:68%;
|
||||||
|
border: 2px solid #25396f;
|
||||||
|
border-radius: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 20px;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
background-color: transparent;
|
||||||
|
color: #25396f;
|
||||||
|
font-weight: bold;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-perfis{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 20px;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#primeiro-conjunto-botoes, #segundo-conjunto-botoes{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.perfil-button:hover{
|
||||||
|
background-color: #5d5dff;
|
||||||
|
border-color: #5d5dff;
|
||||||
|
color: white;
|
||||||
|
transition: 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selecionado{
|
||||||
|
background-color: #5d5dff;
|
||||||
|
border-color: #5d5dff;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/*import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
function ProfileCard() {
|
function ProfileCard() {
|
||||||
return (
|
return (
|
||||||
@ -18,4 +18,4 @@ function ProfileCard() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ProfileCard;*/
|
export default ProfileCard;
|
||||||
@ -1,6 +1,8 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import menuItems from "../data/sidebar-items-medico.json"; // Use "sidebar-items-secretaria.json" para secretaria e "sidebar-items-adm.json" para ADM
|
import menuItems from "../data/sidebar-items-medico.json"; // Use "sidebar-items-secretaria.json" para secretaria e "sidebar-items-adm.json" para ADM
|
||||||
|
import TrocardePerfis from "./TrocardePerfis";
|
||||||
|
|
||||||
|
|
||||||
// 1. Recebe 'menuItems' e 'onLogout' como props
|
// 1. Recebe 'menuItems' e 'onLogout' como props
|
||||||
function Sidebar({ menuItems, onLogout }) {
|
function Sidebar({ menuItems, onLogout }) {
|
||||||
@ -120,6 +122,8 @@ function Sidebar({ menuItems, onLogout }) {
|
|||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<TrocardePerfis />
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
80
src/components/TrocardePerfis.jsx
Normal file
80
src/components/TrocardePerfis.jsx
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import {React, useState, useEffect} from 'react'
|
||||||
|
import { useNavigate, useLocation } from 'react-router-dom'
|
||||||
|
import { UserInfos } from './utils/Functions-Endpoints/General';
|
||||||
|
import { useAuth } from './utils/AuthProvider';
|
||||||
|
import './Estilo/TrocardePerfis.css'
|
||||||
|
|
||||||
|
const TrocardePerfis = () => {
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
|
const [selectedProfile, setSelectedProfile] = useState('');
|
||||||
|
const { getAuthorizationHeader } = useAuth();
|
||||||
|
const [showProfiles, setShowProfiles] = useState([]);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
let authHeader = getAuthorizationHeader();
|
||||||
|
console.log('AUTH HEADER', authHeader)
|
||||||
|
|
||||||
|
const handleUserInfo = async () => {
|
||||||
|
const userInfo = await UserInfos(authHeader);
|
||||||
|
setShowProfiles(userInfo.roles)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleProfileClick = (profile, route) => {
|
||||||
|
setSelectedProfile(profile);
|
||||||
|
navigate(route);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setSelectedProfile(location.pathname)
|
||||||
|
|
||||||
|
handleUserInfo();
|
||||||
|
},[])
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
<div className='container-perfis'>
|
||||||
|
<div id='primeiro-conjunto-botoes'>
|
||||||
|
{(showProfiles.includes('secretaria') || showProfiles.includes('admin')) && (
|
||||||
|
<button
|
||||||
|
className={`perfil-button${selectedProfile === 'secretaria' ? 'selecionado' : ''}`}
|
||||||
|
onClick={() => handleProfileClick('secretaria', '/secretaria')}
|
||||||
|
>
|
||||||
|
Secretaria
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{(showProfiles.includes('medico') || showProfiles.includes('admin')) && (
|
||||||
|
<button
|
||||||
|
className={`perfil-button${selectedProfile === 'medico' ? 'selecionado' : ''}`}
|
||||||
|
onClick={() => handleProfileClick('medico', '/medico')}
|
||||||
|
>
|
||||||
|
Médico(a)
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id='segundo-conjunto-botoes'>
|
||||||
|
{(showProfiles.includes('financeiro') || showProfiles.includes('admin')) && (
|
||||||
|
<button
|
||||||
|
className={`perfil-button${selectedProfile === 'financeiro' ? 'selecionado' : ''}`}
|
||||||
|
onClick={() => handleProfileClick('financeiro', '/financeiro')}
|
||||||
|
>
|
||||||
|
Financeiro
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{showProfiles.includes('admin') && (
|
||||||
|
<button
|
||||||
|
className={`perfil-button${selectedProfile === 'admin' ? 'selecionado' : ''}`}
|
||||||
|
onClick={() => handleProfileClick('admin', '/admin')}
|
||||||
|
>
|
||||||
|
Administrador(a)
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TrocardePerfis
|
||||||
@ -105,7 +105,6 @@ function PatientForm({ onSave, onCancel, formData, setFormData }) {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!formData.full_name || !formData.cpf || !formData.sex || !formData.birth_date){
|
if (!formData.full_name || !formData.cpf || !formData.sex || !formData.birth_date){
|
||||||
console.log(formData.full_name, formData.cpf, formData.sex, formData.birth_date)
|
|
||||||
setErrorModalMsg('Por favor, preencha Nome, CPF, Gênero e data de nascimento.');
|
setErrorModalMsg('Por favor, preencha Nome, CPF, Gênero e data de nascimento.');
|
||||||
setShowModal404(true);
|
setShowModal404(true);
|
||||||
return
|
return
|
||||||
|
|||||||
27
src/components/utils/Functions-Endpoints/General.js
Normal file
27
src/components/utils/Functions-Endpoints/General.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import API_KEY from "../apiKeys";
|
||||||
|
|
||||||
|
const UserInfos = async (access_token) => {
|
||||||
|
|
||||||
|
let Token = access_token.replace('bearer', 'Bearer')
|
||||||
|
|
||||||
|
|
||||||
|
var myHeaders = new Headers();
|
||||||
|
myHeaders.append("apikey", API_KEY);
|
||||||
|
|
||||||
|
myHeaders.append("Authorization", Token);
|
||||||
|
|
||||||
|
var requestOptions = {
|
||||||
|
method: 'GET',
|
||||||
|
headers: myHeaders,
|
||||||
|
redirect: 'follow'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const userInfo = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/functions/v1/user-info`, requestOptions)
|
||||||
|
const userInfoData = await userInfo.json()
|
||||||
|
console.log(userInfoData, "Dados do usuário")
|
||||||
|
return userInfoData
|
||||||
|
}
|
||||||
|
|
||||||
|
export {UserInfos}
|
||||||
@ -5,7 +5,7 @@ import { useAuth } from '../components/utils/AuthProvider'
|
|||||||
import {useEffect, useState} from 'react'
|
import {useEffect, useState} from 'react'
|
||||||
import { useParams } from 'react-router-dom'
|
import { useParams } from 'react-router-dom'
|
||||||
import API_KEY from '../components/utils/apiKeys'
|
import API_KEY from '../components/utils/apiKeys'
|
||||||
const DoctorEditPage = ( {id, setCurrentPage}) => {
|
const DoctorEditPage = () => {
|
||||||
const {getAuthorizationHeader, isAuthenticated} = useAuth();
|
const {getAuthorizationHeader, isAuthenticated} = useAuth();
|
||||||
const [DoctorToPUT, setDoctorPUT] = useState({})
|
const [DoctorToPUT, setDoctorPUT] = useState({})
|
||||||
|
|
||||||
|
|||||||
@ -163,7 +163,7 @@ function TableDoctor({ setCurrentPage, setPatientID }) {
|
|||||||
<td>
|
<td>
|
||||||
<div className="d-flex gap-2">
|
<div className="d-flex gap-2">
|
||||||
{/* Ver Detalhes */}
|
{/* Ver Detalhes */}
|
||||||
<Link to={`/medicos/${medico.id}`}>
|
<Link to={`${medico.id}`}>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm"
|
className="btn btn-sm"
|
||||||
style={{
|
style={{
|
||||||
@ -181,7 +181,7 @@ function TableDoctor({ setCurrentPage, setPatientID }) {
|
|||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
{/* Editar */}
|
{/* Editar */}
|
||||||
<Link to={`/medicos/${medico.id}/edit`}>
|
<Link to={`${medico.id}/edit`}>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm"
|
className="btn btn-sm"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import React, { useState, useEffect, use } from 'react';
|
import React, { useState, useEffect, use } from 'react';
|
||||||
import { Link, useNavigate } from "react-router-dom";
|
import {Link, useNavigate } from "react-router-dom";
|
||||||
import { useAuth } from '../components/utils/AuthProvider';
|
import { useAuth } from '../components/utils/AuthProvider';
|
||||||
import API_KEY from '../components/utils/apiKeys';
|
import API_KEY from '../components/utils/apiKeys';
|
||||||
|
import { UserInfos } from '../components/utils/Functions-Endpoints/General';
|
||||||
|
|
||||||
function Login({ onEnterSystem }) {
|
function Login({ onEnterSystem }) {
|
||||||
const { authTokens, setAuthTokens } = useAuth();
|
const {setAuthTokens } = useAuth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
username: "",
|
username: "",
|
||||||
@ -11,15 +13,16 @@ function Login({ onEnterSystem }) {
|
|||||||
});
|
});
|
||||||
const [alert, setAlert] = useState("");
|
const [alert, setAlert] = useState("");
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
|
/*
|
||||||
|
useEffect(async () => {
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
var myHeaders = new Headers();
|
var myHeaders = new Headers();
|
||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append("apikey", API_KEY);
|
||||||
myHeaders.append("Content-Type", "application/json");
|
myHeaders.append("Content-Type", "application/json");
|
||||||
|
|
||||||
var raw = JSON.stringify({
|
var raw = JSON.stringify({
|
||||||
"email": "riseup@popcode.com.br",
|
"email": form.username,
|
||||||
"password": "riseup"
|
"password": form.password
|
||||||
});
|
});
|
||||||
|
|
||||||
var requestOptions = {
|
var requestOptions = {
|
||||||
@ -30,14 +33,52 @@ function Login({ onEnterSystem }) {
|
|||||||
redirect: 'follow'
|
redirect: 'follow'
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/auth/v1/token?grant_type=password", requestOptions)
|
const response = await fetch("https://yuanqfswhberkoevtmfr.supabase.co/auth/v1/token?grant_type=password", requestOptions);
|
||||||
.then(response => response.json())
|
const data = await response.json();
|
||||||
.then(data => {
|
|
||||||
setAuthTokens(data);
|
setAuthTokens(data);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
})
|
|
||||||
|
if(data.access_token){
|
||||||
|
console.log('jasja')
|
||||||
|
/*var myHeaders = new Headers();
|
||||||
|
myHeaders.append("Authorization", `Bearer ${data.access_token}`);
|
||||||
|
myHeaders.append("apikey", API_KEY);
|
||||||
|
|
||||||
|
var raw = JSON.stringify({
|
||||||
|
"email": "secretaria@squad23.com",
|
||||||
|
"password": "squad23!",
|
||||||
|
"full_name": "Secretaria",
|
||||||
|
"phone": "(11) 99999-9999",
|
||||||
|
"role": "secretaria"
|
||||||
|
});
|
||||||
|
|
||||||
|
var requestOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: myHeaders,
|
||||||
|
body: raw,
|
||||||
|
redirect: 'follow'
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch("https://yuanqfswhberkoevtmfr.supabase.co/functions/v1/create-user", requestOptions)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(result => console.log(result))
|
||||||
|
.catch(error => console.log('error', error));*/
|
||||||
|
|
||||||
|
/* var myHeaders = new Headers();
|
||||||
|
myHeaders.append("Authorization", `Bearer ${data.access_token}`);
|
||||||
|
myHeaders.append("apikey", API_KEY);
|
||||||
|
var requestOptions = {
|
||||||
|
method: 'GET',
|
||||||
|
headers: myHeaders,
|
||||||
|
redirect: 'follow'
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/user_roles", requestOptions)
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(result => console.log(result))
|
||||||
.catch(error => console.log('error', error));
|
.catch(error => console.log('error', error));
|
||||||
}, []);
|
}
|
||||||
|
}, []);*/
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
setForm({ ...form, [e.target.name]: e.target.value });
|
setForm({ ...form, [e.target.name]: e.target.value });
|
||||||
@ -47,31 +88,38 @@ function Login({ onEnterSystem }) {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("Tentando logar com:", form);
|
console.log("Tentando logar com:", form);
|
||||||
if (form.username && form.password) {
|
if (form.username && form.password) {
|
||||||
|
|
||||||
|
|
||||||
/* if (data.access_token) {
|
|
||||||
console.log("Login bem-sucedido!");
|
|
||||||
var myHeaders = new Headers();
|
var myHeaders = new Headers();
|
||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append("apikey", API_KEY);
|
||||||
myHeaders.append("Authorization", `Bearer ${data.access_token}`);
|
myHeaders.append("Content-Type", "application/json");
|
||||||
|
|
||||||
|
var raw = JSON.stringify({
|
||||||
|
"email": form.username,
|
||||||
|
"password": form.password
|
||||||
|
});
|
||||||
|
|
||||||
var requestOptions = {
|
var requestOptions = {
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
headers: myHeaders,
|
headers: myHeaders,
|
||||||
|
body: raw,
|
||||||
|
|
||||||
redirect: 'follow'
|
redirect: 'follow'
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(data.user.id)
|
const response = await fetch("https://yuanqfswhberkoevtmfr.supabase.co/auth/v1/token?grant_type=password", requestOptions);
|
||||||
|
const data = await response.json();
|
||||||
|
setAuthTokens(data);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
fetch(`https://yuanqfswhberkoevtmfr.supabase.co/functions/v1/user-info`, requestOptions)
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(result => console.log(result, "vamo ver se da certo"))
|
|
||||||
.catch(error => console.log('error', error));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
navigate(`/${form.username}/`);
|
if (data.access_token){
|
||||||
|
|
||||||
|
|
||||||
|
const UserData = await UserInfos(`bearer ${data.access_token}`);
|
||||||
|
console.log(UserData, 'Dados do usuário');
|
||||||
|
|
||||||
|
navigate(`/admin/`);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setAlert("Preencha todos os campos!");
|
setAlert("Preencha todos os campos!");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import API_KEY from '../components/utils/apiKeys';
|
|||||||
import { useAuth } from '../components/utils/AuthProvider';
|
import { useAuth } from '../components/utils/AuthProvider';
|
||||||
|
|
||||||
|
|
||||||
function PatientCadastroManager( {setCurrentPage} ) {
|
function PatientCadastroManager( {} ) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
const [infosModal, setInfosModal] = useState({title:'', message:''});
|
const [infosModal, setInfosModal] = useState({title:'', message:''});
|
||||||
|
|||||||
@ -115,7 +115,7 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
|||||||
|
|
||||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/patients", requestOptions)
|
fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/patients", requestOptions)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(result => setPacientes(result))
|
.then(result => console.log(result))
|
||||||
.catch(error => console.log('error', error));
|
.catch(error => console.log('error', error));
|
||||||
}, [isAuthenticated, getAuthorizationHeader]);
|
}, [isAuthenticated, getAuthorizationHeader]);
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div className="d-flex gap-2">
|
<div className="d-flex gap-2">
|
||||||
<Link to={`/pacientes/${paciente.id}`}>
|
<Link to={`${paciente.id}`}>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm"
|
className="btn btn-sm"
|
||||||
style={{
|
style={{
|
||||||
@ -281,7 +281,7 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
|||||||
</button>
|
</button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link to={`/pacientes/${paciente.id}/edit`}>
|
<Link to={`${paciente.id}/edit`}>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm"
|
className="btn btn-sm"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user