design: mudança no botão de alternar no agendamento e mudança na sidebar
This commit is contained in:
parent
bff5c42a4e
commit
b64b664621
@ -18,15 +18,23 @@ function Sidebar({ menuItems }) {
|
||||
const [isMobile, setIsMobile] = useState(false);
|
||||
const [showLogoutModal, setShowLogoutModal] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
||||
const [roleUser, setRoleUser] = useState([])
|
||||
|
||||
const {getAuthorizationHeader} = useAuth();
|
||||
|
||||
const authHeader = getAuthorizationHeader();
|
||||
|
||||
let pathname = window.location.pathname.split("/")[1]
|
||||
|
||||
|
||||
// useEffect para definir quais toggle da sidebar devem aparecer
|
||||
useEffect(() => {
|
||||
let teste = localStorage.getItem("roleUser")
|
||||
setRoleUser(teste)
|
||||
|
||||
}, [authHeader])
|
||||
|
||||
|
||||
|
||||
// Detecta se é mobile/tablet
|
||||
@ -37,14 +45,6 @@ function Sidebar({ menuItems }) {
|
||||
setIsActive(!mobile);
|
||||
};
|
||||
|
||||
const fetchInfoUser = async () => {
|
||||
const InfoUser = await UserInfos(authHeader);
|
||||
console.log(InfoUser.roles, "dados")
|
||||
|
||||
setRoleUser(InfoUser.roles)
|
||||
}
|
||||
|
||||
fetchInfoUser()
|
||||
|
||||
checkScreenSize();
|
||||
window.addEventListener("resize", checkScreenSize);
|
||||
@ -117,13 +117,6 @@ function Sidebar({ menuItems }) {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if(roleUser.includes("admin")){
|
||||
console.log("tem")
|
||||
}
|
||||
console.log(roleUser)
|
||||
}, [roleUser])
|
||||
|
||||
const handleLogoutCancel = () => setShowLogoutModal(false);
|
||||
|
||||
|
||||
@ -251,26 +244,26 @@ function Sidebar({ menuItems }) {
|
||||
<ul className="menu">
|
||||
|
||||
{roleUser.includes("admin") &&
|
||||
<ToggleSidebar perfil={"administrador"} items={admItems}/>
|
||||
<ToggleSidebar perfil={"administrador"} items={admItems} defaultOpen={pathname.includes("admin") } />
|
||||
}
|
||||
{roleUser.includes("admin") || roleUser.includes("secretaria") ?
|
||||
<ToggleSidebar perfil={"secretaria"} items={SecretariaItems}/>
|
||||
<ToggleSidebar perfil={"secretaria"} items={SecretariaItems} defaultOpen={pathname.includes("secretaria")} />
|
||||
:
|
||||
null
|
||||
}
|
||||
|
||||
{roleUser.includes("admin") || roleUser.includes("medico") ?
|
||||
<ToggleSidebar perfil={"medico"} items={DoctorItems}/>
|
||||
<ToggleSidebar perfil={"medico"} items={DoctorItems} defaultOpen={pathname.includes("medico") } />
|
||||
:null
|
||||
}
|
||||
|
||||
{roleUser.includes("admin") || roleUser.includes("financeiro") ?
|
||||
<ToggleSidebar perfil={"financeiro"} items={FinanceiroItems}/>
|
||||
<ToggleSidebar perfil={"financeiro"} items={FinanceiroItems} defaultOpen={pathname.includes("financeiro") } />
|
||||
:null
|
||||
}
|
||||
|
||||
{roleUser.includes("admin") || roleUser.includes("paciente") ?
|
||||
<ToggleSidebar perfil={"paciente"} items={PacienteItems}/>
|
||||
<ToggleSidebar perfil={"paciente"} items={PacienteItems} defaultOpen={pathname.includes("paciente") } />
|
||||
: null
|
||||
}
|
||||
|
||||
|
||||
@ -136,4 +136,4 @@ const ToggleSidebar = ({ perfil, items, defaultOpen = false }) => {
|
||||
)
|
||||
}
|
||||
|
||||
export default ToggleSidebar
|
||||
export default ToggleSidebar
|
||||
|
||||
@ -260,15 +260,24 @@ const Agendamento = ({ setDictInfo }) => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Agendar nova consulta</h1>
|
||||
<h1>Gerenciar consultas</h1>
|
||||
<div className="btns-gerenciamento-e-consulta" style={{ display: 'flex', gap: '10px', marginBottom: '20px' }}>
|
||||
{/* LIMPA O OBJETO DE EDIÇÃO AO CLICAR EM "ADICIONAR" */}
|
||||
<button className="btn btn-primary" onClick={() => {
|
||||
{!PageNovaConsulta ?
|
||||
<button className="btn btn-primary" onClick={() => {
|
||||
setPageConsulta(true);
|
||||
setEditingAppointmentId(null);
|
||||
setAppointmentToEdit(null); // <-- LIMPA O OBJETO AQUI PARA GARANTIR MODO CADASTRO
|
||||
}}><i className="bi bi-plus-circle"></i> Adicionar Consulta</button>
|
||||
<button className="manage-button btn" onClick={() => navigate("/secretaria/excecoes-disponibilidade")}><i className="bi bi-gear-fill me-1"></i> Gerenciar Exceções</button>
|
||||
:
|
||||
<button className={"btn btn-primary"} onClick={() => {
|
||||
setPageConsulta(false);
|
||||
}}>
|
||||
Ver consultas
|
||||
</button>
|
||||
|
||||
}
|
||||
<button className="manage-button btn" onClick={() => navigate("/secretaria/excecoes-disponibilidade")}><i className="bi bi-gear-fill me-1"></i> Gerenciar Exceções</button>
|
||||
<button className='manage-button btn' onClick={() => navigate('/secretaria/disponibilidade')}><i className="bi bi-gear-fill me-1"></i> Mudar Disponibilidade</button>
|
||||
</div>
|
||||
{!PageNovaConsulta ? (
|
||||
@ -443,4 +452,4 @@ const Agendamento = ({ setDictInfo }) => {
|
||||
)
|
||||
}
|
||||
|
||||
export default Agendamento;
|
||||
export default Agendamento;
|
||||
|
||||
@ -118,7 +118,8 @@ function Login({ onEnterSystem }) {
|
||||
if (data.access_token) {
|
||||
const UserData = await UserInfos(`bearer ${data.access_token}`);
|
||||
console.log(UserData, "Dados do usuário");
|
||||
|
||||
localStorage.setItem("roleUser", UserData.roles)
|
||||
|
||||
if (UserData?.roles?.includes("admin")) {
|
||||
navigate(`/admin/`);
|
||||
} else if (UserData?.roles?.includes("secretaria")) {
|
||||
@ -131,7 +132,7 @@ function Login({ onEnterSystem }) {
|
||||
navigate(`/paciente/`);
|
||||
}
|
||||
}else{
|
||||
console.log("ERROROROROROOR")
|
||||
console.log("Erro na tentativa de login")
|
||||
setShowCabecalho(true)
|
||||
}
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user