new file: public/favicon.svg
deleted: src/assets/hero.png modified: src/components/AppShell.jsx modified: src/components/calendar/AgendaDailyView.jsx modified: src/components/calendar/AgendaMonthlyView.jsx modified: src/components/calendar/AgendaWeeklyView.jsx modified: src/hooks/useAgenda.js modified: src/index.css modified: src/mappers/appointmentMapper.js modified: src/mappers/reportMapper.js modified: src/pages/AgendaPage.jsx modified: src/pages/AuthPages.jsx modified: src/pages/HomePage.jsx modified: src/pages/MessagesPage.jsx modified: src/pages/PatientsPage.jsx modified: src/pages/ProfilePage.jsx modified: src/pages/ReportsPage.jsx modified: src/pages/SettingsPage.jsx modified: src/repositories/appointmentRepository.js modified: src/repositories/settingsRepository.js
This commit is contained in:
10
public/favicon.svg
Normal file
10
public/favicon.svg
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
|
||||||
|
<rect width="48" height="48" rx="8" fill="#3b82f6"/>
|
||||||
|
<g fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="4">
|
||||||
|
<path d="M22 7v5"/>
|
||||||
|
<path d="M12 7v5"/>
|
||||||
|
<path d="M12 9h-2a4 4 0 0 0-4 4v8a12 12 0 0 0 24 0v-8a4 4 0 0 0-4-4h-2"/>
|
||||||
|
<path d="M18 34a12 12 0 0 0 24 0v-6"/>
|
||||||
|
<circle cx="42" cy="24" r="4"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 431 B |
Binary file not shown.
|
Before Width: | Height: | Size: 44 KiB |
@@ -149,7 +149,7 @@ export function AppShell({ children, currentPath, navigate, role, routeTitle })
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<aside
|
<aside
|
||||||
className={`fixed inset-y-0 left-0 z-40 flex w-64 -translate-x-full flex-col border-r border-[#404040] bg-[#262626] transition-transform duration-200 lg:translate-x-0 ${
|
className={`fixed inset-y-0 left-0 z-40 flex w-56 -translate-x-full flex-col border-r border-[#404040] bg-[#262626] transition-transform duration-200 lg:translate-x-0 ${
|
||||||
menuOpen ? 'translate-x-0' : ''
|
menuOpen ? 'translate-x-0' : ''
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
@@ -195,7 +195,7 @@ export function AppShell({ children, currentPath, navigate, role, routeTitle })
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<div className="lg:pl-64">
|
<div className="lg:pl-56">
|
||||||
<header className="sticky top-0 z-20 h-auto border-b border-[#404040] bg-[#262626] px-4 py-3 md:px-8 lg:h-16 lg:py-0">
|
<header className="sticky top-0 z-20 h-auto border-b border-[#404040] bg-[#262626] px-4 py-3 md:px-8 lg:h-16 lg:py-0">
|
||||||
<div className="flex h-full flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
<div className="flex h-full flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
||||||
<div className="flex min-w-0 items-center gap-3">
|
<div className="flex min-w-0 items-center gap-3">
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
import React from 'react'
|
|
||||||
import { format, isToday } from 'date-fns'
|
import { format, isToday } from 'date-fns'
|
||||||
import { ptBR } from 'date-fns/locale'
|
import { ptBR } from 'date-fns/locale'
|
||||||
|
|
||||||
import { sortAppointmentsByTime } from '../../utils/agendaDate.js'
|
import { sortAppointmentsByTime } from '../../utils/agendaDate.js'
|
||||||
|
|
||||||
export function AgendaDailyView({ baseDate, appointments, onAppointmentClick }) {
|
const DAY_START = '07:00'
|
||||||
|
const DAY_END = '19:00'
|
||||||
|
const SLOT_MINUTES = 30
|
||||||
|
|
||||||
|
export function AgendaDailyView({ baseDate, appointments, canCreateAppointment = true, onAppointmentClick, onSlotCreate }) {
|
||||||
const dailyAppointments = sortAppointmentsByTime(appointments)
|
const dailyAppointments = sortAppointmentsByTime(appointments)
|
||||||
|
const appointmentsByTime = groupAppointmentsByTime(dailyAppointments)
|
||||||
|
const slots = mergeSlotsWithAppointmentTimes(generateSlots(DAY_START, DAY_END, SLOT_MINUTES), dailyAppointments)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-2xl border border-[#404040] bg-[#262626] p-5">
|
<div className="agenda-calendar-shell rounded-2xl border border-[#404040] bg-[#262626] p-5">
|
||||||
<div className="flex flex-col gap-3 border-b border-[#404040] pb-4 md:flex-row md:items-end md:justify-between">
|
<div className="agenda-calendar-header flex flex-col gap-3 border-b border-[#404040] pb-4 md:flex-row md:items-end md:justify-between">
|
||||||
<div>
|
<div>
|
||||||
<span className="text-xs font-semibold uppercase tracking-[0.16em] text-[#737373]">
|
<span className="text-xs font-semibold uppercase tracking-[0.16em] text-[#737373]">
|
||||||
Vista ampliada do dia
|
Grade de horários do dia
|
||||||
</span>
|
</span>
|
||||||
<h3 className="mt-2 text-xl font-bold text-[#e5e5e5]">
|
<h3 className="mt-2 text-xl font-bold text-[#e5e5e5]">
|
||||||
{format(baseDate, "EEEE, dd 'de' MMMM", { locale: ptBR })}
|
{format(baseDate, "EEEE, dd 'de' MMMM", { locale: ptBR })}
|
||||||
@@ -20,9 +25,15 @@ export function AgendaDailyView({ baseDate, appointments, onAppointmentClick })
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
<span className="rounded-full border border-[#404040] bg-[#1f1f1f] px-3 py-1 text-xs font-semibold text-[#a3a3a3]">
|
<span className="agenda-legend-pill rounded-full border border-[#404040] bg-[#1f1f1f] px-3 py-1 text-xs font-semibold text-[#a3a3a3]">
|
||||||
{dailyAppointments.length} {dailyAppointments.length === 1 ? 'agendamento' : 'agendamentos'}
|
{dailyAppointments.length} {dailyAppointments.length === 1 ? 'agendamento' : 'agendamentos'}
|
||||||
</span>
|
</span>
|
||||||
|
<span className="agenda-legend-pill agenda-legend-free rounded-full border border-emerald-700/40 bg-emerald-950/30 px-3 py-1 text-xs font-semibold text-emerald-200 shadow-sm">
|
||||||
|
Livre
|
||||||
|
</span>
|
||||||
|
<span className="agenda-legend-pill agenda-legend-booked rounded-full border border-red-700/40 bg-red-950/30 px-3 py-1 text-xs font-semibold text-red-200 shadow-sm">
|
||||||
|
Agendado
|
||||||
|
</span>
|
||||||
{isToday(baseDate) && (
|
{isToday(baseDate) && (
|
||||||
<span className="rounded-full border border-[#3b82f6]/30 bg-[#3b82f6]/10 px-3 py-1 text-xs font-semibold text-[#93c5fd]">
|
<span className="rounded-full border border-[#3b82f6]/30 bg-[#3b82f6]/10 px-3 py-1 text-xs font-semibold text-[#93c5fd]">
|
||||||
Hoje
|
Hoje
|
||||||
@@ -31,70 +42,134 @@ export function AgendaDailyView({ baseDate, appointments, onAppointmentClick })
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{dailyAppointments.length === 0 ? (
|
<div className="agenda-day-grid mt-4 grid gap-2">
|
||||||
<div className="mt-4 rounded-xl border border-dashed border-[#404040] bg-[#1f1f1f] p-8 text-center">
|
{slots.map((time) => {
|
||||||
<h3 className="text-base font-bold text-[#e5e5e5]">Nenhum horário encontrado</h3>
|
const slotAppointments = appointmentsByTime.get(time) || []
|
||||||
<p className="mt-2 text-sm leading-6 text-[#a3a3a3]">
|
const primaryAppointment = slotAppointments[0]
|
||||||
Ajuste o filtro ou altere o período no calendário.
|
const isBooked = Boolean(primaryAppointment)
|
||||||
</p>
|
|
||||||
</div>
|
return (
|
||||||
) : (
|
|
||||||
<div className="mt-4 grid gap-3">
|
|
||||||
{dailyAppointments.map((appointment) => (
|
|
||||||
<article
|
<article
|
||||||
key={appointment.id}
|
className={`agenda-slot ${isBooked ? getDailyToneClass(primaryAppointment.status) : 'agenda-slot-free'} grid gap-3 rounded-xl border px-4 py-3 shadow-[0_8px_18px_rgba(0,0,0,0.16)] md:grid-cols-[84px_1fr_auto] ${
|
||||||
className={`grid gap-4 rounded-xl border p-4 md:grid-cols-[96px_1fr_auto] ${getStatusColors(appointment.status)}`}
|
isBooked
|
||||||
|
? 'border-red-700/50 bg-red-950/35 text-red-50'
|
||||||
|
: 'border-emerald-700/50 bg-emerald-950/35 text-emerald-50'
|
||||||
|
}`}
|
||||||
|
key={time}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-2xl font-bold leading-none">{appointment.time || '--:--'}</p>
|
<p className="text-xl font-bold leading-none">{time}</p>
|
||||||
<p className="mt-2 text-[11px] font-semibold uppercase tracking-[0.14em] opacity-80">
|
<p className="mt-1 text-[11px] font-semibold uppercase tracking-[0.12em] opacity-80">
|
||||||
{appointment.mode}
|
{isBooked ? 'Agendado' : 'Disponível'}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
{isBooked ? (
|
||||||
<button
|
<div>
|
||||||
className="text-left text-base font-bold transition hover:opacity-85"
|
<button
|
||||||
onClick={() => onAppointmentClick && onAppointmentClick(appointment)}
|
className="text-left text-sm font-bold transition hover:opacity-85"
|
||||||
type="button"
|
onClick={() => onAppointmentClick?.(primaryAppointment)}
|
||||||
>
|
type="button"
|
||||||
{appointment.patient}
|
>
|
||||||
</button>
|
{primaryAppointment.patient}
|
||||||
<p className="mt-1 text-sm opacity-90">
|
</button>
|
||||||
{appointment.type} com {appointment.professional}
|
<p className="mt-1 text-sm opacity-90">
|
||||||
</p>
|
{primaryAppointment.type} com {primaryAppointment.professional}
|
||||||
<div className="mt-3 flex flex-wrap gap-2 text-xs font-medium opacity-80">
|
</p>
|
||||||
<span className="rounded-full bg-black/15 px-2.5 py-1">{appointment.room}</span>
|
<div className="mt-2 flex flex-wrap gap-2 text-xs font-medium opacity-80">
|
||||||
<span className="rounded-full bg-black/15 px-2.5 py-1">{appointment.type}</span>
|
{primaryAppointment.room ? <span className="agenda-slot-chip rounded-full bg-black/25 px-2.5 py-1 shadow-sm">{primaryAppointment.room}</span> : null}
|
||||||
|
{primaryAppointment.mode ? <span className="agenda-slot-chip rounded-full bg-black/25 px-2.5 py-1 shadow-sm">{primaryAppointment.mode}</span> : null}
|
||||||
|
{slotAppointments.length > 1 ? <span className="agenda-slot-chip rounded-full bg-black/25 px-2.5 py-1 shadow-sm">+{slotAppointments.length - 1}</span> : null}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
) : (
|
||||||
|
<div className="flex items-center text-sm font-medium opacity-90">
|
||||||
|
Horário disponível para novo agendamento.
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="flex items-start justify-start md:justify-end">
|
<div className="flex flex-wrap items-start justify-start gap-2 md:justify-end">
|
||||||
<span className="rounded-full border border-current/20 bg-black/10 px-3 py-1 text-xs font-bold">
|
<span className="agenda-slot-status rounded-full border border-current/30 bg-black/25 px-3 py-1 text-xs font-bold shadow-sm">
|
||||||
{appointment.status}
|
{isBooked ? primaryAppointment.status : 'Livre'}
|
||||||
</span>
|
</span>
|
||||||
|
{canCreateAppointment ? (
|
||||||
|
<button
|
||||||
|
aria-label={`Criar agendamento às ${time}`}
|
||||||
|
className="agenda-slot-add grid size-8 place-items-center rounded-full border border-current/30 bg-black/30 text-base font-bold leading-none shadow-sm transition hover:bg-black/45"
|
||||||
|
onClick={() => onSlotCreate?.(time)}
|
||||||
|
title={`Novo agendamento às ${time}`}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
+
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
))}
|
)
|
||||||
</div>
|
})}
|
||||||
)}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatusColors(status) {
|
function getDailyToneClass(status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 'Confirmada':
|
case 'Confirmada':
|
||||||
return 'border-[#14532d] bg-[#052e1a] text-[#a7f3d0]'
|
return 'agenda-slot-confirmed'
|
||||||
case 'Em triagem':
|
case 'Em triagem':
|
||||||
return 'border-[#78350f] bg-[#2d1e05] text-[#fde68a]'
|
return 'agenda-slot-triage'
|
||||||
case 'Concluida':
|
|
||||||
case 'Concluída':
|
|
||||||
return 'border-[#1e3a8a] bg-[#172554] text-[#bfdbfe]'
|
|
||||||
case 'Cancelada':
|
case 'Cancelada':
|
||||||
return 'border-[#7f1d1d] bg-[#450a0a] text-[#fecaca]'
|
return 'agenda-slot-cancelled'
|
||||||
|
case 'Bloqueado':
|
||||||
|
return 'agenda-slot-blocked'
|
||||||
case 'Aguardando':
|
case 'Aguardando':
|
||||||
default:
|
default:
|
||||||
return 'border-[#404040] bg-[#1f1f1f] text-[#e5e5e5]'
|
return 'agenda-slot-waiting'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateSlots(start, end, intervalMinutes) {
|
||||||
|
const [startHour, startMinute] = start.split(':').map(Number)
|
||||||
|
const [endHour, endMinute] = end.split(':').map(Number)
|
||||||
|
const slots = []
|
||||||
|
let cursor = startHour * 60 + startMinute
|
||||||
|
const last = endHour * 60 + endMinute
|
||||||
|
|
||||||
|
while (cursor < last) {
|
||||||
|
slots.push(formatMinutes(cursor))
|
||||||
|
cursor += intervalMinutes
|
||||||
|
}
|
||||||
|
|
||||||
|
return slots
|
||||||
|
}
|
||||||
|
|
||||||
|
function groupAppointmentsByTime(appointments) {
|
||||||
|
return appointments.reduce((map, appointment) => {
|
||||||
|
const time = normalizeTime(appointment.time)
|
||||||
|
if (!time) return map
|
||||||
|
map.set(time, [...(map.get(time) || []), appointment])
|
||||||
|
return map
|
||||||
|
}, new Map())
|
||||||
|
}
|
||||||
|
|
||||||
|
function mergeSlotsWithAppointmentTimes(slots, appointments) {
|
||||||
|
return [...new Set([...slots, ...appointments.map((appointment) => normalizeTime(appointment.time)).filter(Boolean)])]
|
||||||
|
.sort((first, second) => minutesFromTime(first) - minutesFromTime(second))
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeTime(value) {
|
||||||
|
const match = String(value || '').match(/^(\d{1,2}):(\d{2})/)
|
||||||
|
if (!match) return ''
|
||||||
|
return `${match[1].padStart(2, '0')}:${match[2]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function minutesFromTime(value) {
|
||||||
|
const [hours, minutes] = normalizeTime(value).split(':').map(Number)
|
||||||
|
return hours * 60 + minutes
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatMinutes(totalMinutes) {
|
||||||
|
const hours = String(Math.floor(totalMinutes / 60)).padStart(2, '0')
|
||||||
|
const minutes = String(totalMinutes % 60).padStart(2, '0')
|
||||||
|
return `${hours}:${minutes}`
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ export function AgendaMonthlyView({ baseDate, appointments, onDayClick }) {
|
|||||||
const weekDays = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb']
|
const weekDays = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb']
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-2xl border border-[#404040] bg-[#262626] p-5">
|
<div className="agenda-calendar-shell rounded-2xl border border-[#404040] bg-[#262626] p-5">
|
||||||
<div className="grid grid-cols-7 gap-px border-b border-[#404040] pb-4">
|
<div className="agenda-calendar-header grid grid-cols-7 gap-px border-b border-[#404040] pb-4">
|
||||||
{weekDays.map((day) => (
|
{weekDays.map((day) => (
|
||||||
<div key={day} className="text-center text-xs font-semibold uppercase tracking-widest text-[#a3a3a3]">
|
<div key={day} className="text-center text-xs font-semibold uppercase tracking-widest text-[#a3a3a3]">
|
||||||
{day}
|
{day}
|
||||||
@@ -49,7 +49,7 @@ export function AgendaMonthlyView({ baseDate, appointments, onDayClick }) {
|
|||||||
<button
|
<button
|
||||||
key={day.toISOString()}
|
key={day.toISOString()}
|
||||||
onClick={() => onDayClick && onDayClick(day)}
|
onClick={() => onDayClick && onDayClick(day)}
|
||||||
className={`flex min-h-[100px] flex-col rounded-xl border p-2 text-left transition hover:border-[#525252] ${
|
className={`agenda-month-day flex min-h-[100px] flex-col rounded-xl border p-2 text-left transition hover:border-[#525252] ${
|
||||||
isCurrentMonth
|
isCurrentMonth
|
||||||
? 'border-[#404040] bg-[#1f1f1f]'
|
? 'border-[#404040] bg-[#1f1f1f]'
|
||||||
: 'border-transparent bg-transparent opacity-40 hover:opacity-80'
|
: 'border-transparent bg-transparent opacity-40 hover:opacity-80'
|
||||||
@@ -69,7 +69,7 @@ export function AgendaMonthlyView({ baseDate, appointments, onDayClick }) {
|
|||||||
{dayAppointments.slice(0, 3).map((appointment) => (
|
{dayAppointments.slice(0, 3).map((appointment) => (
|
||||||
<div
|
<div
|
||||||
key={appointment.id}
|
key={appointment.id}
|
||||||
className="flex items-center gap-1.5 truncate rounded bg-[#303030] px-1.5 py-1 text-[10px] font-semibold text-[#a3a3a3]"
|
className={`agenda-month-event ${getStatusToneClass(appointment.status)} flex items-center gap-1.5 truncate rounded bg-[#303030] px-1.5 py-1 text-[10px] font-semibold text-[#a3a3a3]`}
|
||||||
>
|
>
|
||||||
<span className={`h-1.5 w-1.5 shrink-0 rounded-full ${getDotColor(appointment.status)}`} />
|
<span className={`h-1.5 w-1.5 shrink-0 rounded-full ${getDotColor(appointment.status)}`} />
|
||||||
<span className="truncate">
|
<span className="truncate">
|
||||||
@@ -91,6 +91,22 @@ export function AgendaMonthlyView({ baseDate, appointments, onDayClick }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStatusToneClass(status) {
|
||||||
|
switch (status) {
|
||||||
|
case 'Confirmada':
|
||||||
|
return 'agenda-event-confirmed'
|
||||||
|
case 'Em triagem':
|
||||||
|
return 'agenda-event-triage'
|
||||||
|
case 'Cancelada':
|
||||||
|
return 'agenda-event-cancelled'
|
||||||
|
case 'Bloqueado':
|
||||||
|
return 'agenda-event-blocked'
|
||||||
|
case 'Aguardando':
|
||||||
|
default:
|
||||||
|
return 'agenda-event-waiting'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getDotColor(status) {
|
function getDotColor(status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 'Confirmada':
|
case 'Confirmada':
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ export function AgendaWeeklyView({ baseDate, appointments, onAppointmentClick })
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-2xl border border-[#404040] bg-[#262626] p-5">
|
<div className="agenda-calendar-shell rounded-2xl border border-[#404040] bg-[#262626] p-5">
|
||||||
<div className="grid grid-cols-7 gap-4 border-b border-[#404040] pb-4">
|
<div className="agenda-calendar-header grid grid-cols-7 gap-4 border-b border-[#404040] pb-4">
|
||||||
{days.map((day) => {
|
{days.map((day) => {
|
||||||
const isWeekend = day.getDay() === 0
|
const isWeekend = day.getDay() === 0
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ export function AgendaWeeklyView({ baseDate, appointments, onAppointmentClick })
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={day.toISOString()}
|
key={day.toISOString()}
|
||||||
className="flex h-full flex-col gap-2 rounded-lg border border-[#404040]/50 bg-[#1f1f1f] p-2"
|
className="agenda-week-day flex h-full min-w-0 flex-col gap-2 rounded-lg border border-[#404040]/50 bg-[#1f1f1f] p-2"
|
||||||
>
|
>
|
||||||
{dayAppointments.length === 0 ? (
|
{dayAppointments.length === 0 ? (
|
||||||
<div className="flex h-full items-center justify-center p-4">
|
<div className="flex h-full items-center justify-center p-4">
|
||||||
@@ -71,21 +71,21 @@ export function AgendaWeeklyView({ baseDate, appointments, onAppointmentClick })
|
|||||||
<button
|
<button
|
||||||
key={appointment.id}
|
key={appointment.id}
|
||||||
onClick={() => onAppointmentClick && onAppointmentClick(appointment)}
|
onClick={() => onAppointmentClick && onAppointmentClick(appointment)}
|
||||||
className={`flex w-full flex-col items-start rounded-md border p-2 text-left shadow-sm transition hover:brightness-110 ${getStatusColors(appointment.status)}`}
|
className={`agenda-event ${getStatusToneClass(appointment.status)} flex w-full min-w-0 flex-col items-start overflow-hidden rounded-md border p-2 text-left shadow-sm transition hover:brightness-110 ${getStatusColors(appointment.status)}`}
|
||||||
>
|
>
|
||||||
<div className="mb-1 flex items-center gap-2">
|
<div className="mb-1 flex w-full min-w-0 items-center gap-1.5 overflow-hidden">
|
||||||
<span className="rounded bg-black/20 px-1.5 py-0.5 text-xs font-bold leading-none">
|
<span className="shrink-0 rounded bg-black/20 px-1.5 py-0.5 text-[10px] font-bold leading-none">
|
||||||
{appointment.time}
|
{appointment.time}
|
||||||
</span>
|
</span>
|
||||||
<span className="truncate text-[10px] font-semibold uppercase tracking-wider opacity-80">
|
<span className="min-w-0 flex-1 truncate text-[9px] font-semibold uppercase tracking-normal opacity-80">
|
||||||
{appointment.mode}
|
{appointment.mode}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<span className="w-full truncate text-xs font-bold leading-tight" title={appointment.patient}>
|
<span className="block w-full min-w-0 truncate text-xs font-bold leading-tight" title={appointment.patient}>
|
||||||
{appointment.patient}
|
{appointment.patient}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
className="mt-0.5 w-full truncate text-[10px] font-medium opacity-80"
|
className="mt-0.5 block w-full min-w-0 truncate text-[10px] font-medium opacity-80"
|
||||||
title={appointment.professional}
|
title={appointment.professional}
|
||||||
>
|
>
|
||||||
Dr(a). {appointment.professional?.split(' ')[0]}
|
Dr(a). {appointment.professional?.split(' ')[0]}
|
||||||
@@ -101,6 +101,25 @@ export function AgendaWeeklyView({ baseDate, appointments, onAppointmentClick })
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStatusToneClass(status) {
|
||||||
|
switch (status) {
|
||||||
|
case 'Confirmada':
|
||||||
|
return 'agenda-event-confirmed'
|
||||||
|
case 'Em triagem':
|
||||||
|
return 'agenda-event-triage'
|
||||||
|
case 'Concluida':
|
||||||
|
case 'Concluída':
|
||||||
|
return 'agenda-event-finished'
|
||||||
|
case 'Cancelada':
|
||||||
|
return 'agenda-event-cancelled'
|
||||||
|
case 'Bloqueado':
|
||||||
|
return 'agenda-event-blocked'
|
||||||
|
case 'Aguardando':
|
||||||
|
default:
|
||||||
|
return 'agenda-event-waiting'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getStatusColors(status) {
|
function getStatusColors(status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 'Confirmada':
|
case 'Confirmada':
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect, useMemo } from 'react'
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
import { isSameDay } from 'date-fns'
|
import { isSameDay } from 'date-fns'
|
||||||
|
|
||||||
import { appointmentRepository } from '../repositories/appointmentRepository.js'
|
import { appointmentRepository } from '../repositories/appointmentRepository.js'
|
||||||
@@ -8,6 +8,16 @@ import { professionalRepository } from '../repositories/professionalRepository.j
|
|||||||
import { profileRepository } from '../repositories/profileRepository.js'
|
import { profileRepository } from '../repositories/profileRepository.js'
|
||||||
import { formatLocalDateInput, parseLocalDate, sortAppointmentsByTime } from '../utils/agendaDate.js'
|
import { formatLocalDateInput, parseLocalDate, sortAppointmentsByTime } from '../utils/agendaDate.js'
|
||||||
|
|
||||||
|
const initialForm = {
|
||||||
|
patientId: '',
|
||||||
|
professionalId: '',
|
||||||
|
type: 'Retorno',
|
||||||
|
time: '15:30',
|
||||||
|
mode: 'Teleconsulta',
|
||||||
|
status: 'Aguardando',
|
||||||
|
notes: '',
|
||||||
|
}
|
||||||
|
|
||||||
export function useAgenda() {
|
export function useAgenda() {
|
||||||
const [patients, setPatients] = useState([])
|
const [patients, setPatients] = useState([])
|
||||||
const [professionals, setProfessionals] = useState([])
|
const [professionals, setProfessionals] = useState([])
|
||||||
@@ -27,14 +37,9 @@ export function useAgenda() {
|
|||||||
const [doctorSearch, setDoctorSearch] = useState('')
|
const [doctorSearch, setDoctorSearch] = useState('')
|
||||||
const [unitFilter, setUnitFilter] = useState('')
|
const [unitFilter, setUnitFilter] = useState('')
|
||||||
const [modalOpen, setModalOpen] = useState(false)
|
const [modalOpen, setModalOpen] = useState(false)
|
||||||
|
const [editingAppointment, setEditingAppointment] = useState(null)
|
||||||
|
const [form, setForm] = useState(initialForm)
|
||||||
|
|
||||||
const [form, setForm] = useState({
|
|
||||||
patientId: '',
|
|
||||||
professionalId: '',
|
|
||||||
type: 'Retorno',
|
|
||||||
time: '15:30',
|
|
||||||
mode: 'Teleconsulta',
|
|
||||||
})
|
|
||||||
const agendaScope = viewerProfile?.isDoctor ? 'doctor' : 'global'
|
const agendaScope = viewerProfile?.isDoctor ? 'doctor' : 'global'
|
||||||
const canCreateAppointment = agendaScope === 'doctor'
|
const canCreateAppointment = agendaScope === 'doctor'
|
||||||
? Boolean(currentProfessional?.id)
|
? Boolean(currentProfessional?.id)
|
||||||
@@ -55,10 +60,10 @@ export function useAgenda() {
|
|||||||
|
|
||||||
if (!active) return
|
if (!active) return
|
||||||
|
|
||||||
const agendaScope = currentProfile?.isDoctor ? 'doctor' : 'global'
|
const currentScope = currentProfile?.isDoctor ? 'doctor' : 'global'
|
||||||
const resolvedProfessional = professionalRepository.resolveCurrentProfessional(currentProfile, professionalsData)
|
const resolvedProfessional = professionalRepository.resolveCurrentProfessional(currentProfile, professionalsData)
|
||||||
const initialProfessionalId =
|
const initialProfessionalId =
|
||||||
agendaScope === 'doctor'
|
currentScope === 'doctor'
|
||||||
? resolvedProfessional?.id || ''
|
? resolvedProfessional?.id || ''
|
||||||
: professionalsData?.[0]?.id || ''
|
: professionalsData?.[0]?.id || ''
|
||||||
|
|
||||||
@@ -72,20 +77,20 @@ export function useAgenda() {
|
|||||||
professionalId: initialProfessionalId,
|
professionalId: initialProfessionalId,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if (agendaScope === 'doctor' && !resolvedProfessional) {
|
if (currentScope === 'doctor' && !resolvedProfessional) {
|
||||||
setLocalAppointments([])
|
setLocalAppointments([])
|
||||||
setError('Não foi possível vincular o médico logado a um profissional da base.')
|
setError('Não foi possível vincular o médico logado a um profissional da base.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const appointmentsData = await appointmentRepository.getAll({
|
const appointmentsData = await appointmentRepository.getAll({
|
||||||
doctorId: agendaScope === 'doctor' ? resolvedProfessional?.id : undefined,
|
doctorId: currentScope === 'doctor' ? resolvedProfessional?.id : undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!active) return
|
if (!active) return
|
||||||
|
|
||||||
setLocalAppointments(
|
setLocalAppointments(
|
||||||
agendaScope === 'doctor' && resolvedProfessional
|
currentScope === 'doctor' && resolvedProfessional
|
||||||
? filterAppointmentsByProfessional(appointmentsData || [], resolvedProfessional.id)
|
? filterAppointmentsByProfessional(appointmentsData || [], resolvedProfessional.id)
|
||||||
: sortAppointmentsByTime(appointmentsData || []),
|
: sortAppointmentsByTime(appointmentsData || []),
|
||||||
)
|
)
|
||||||
@@ -95,9 +100,7 @@ export function useAgenda() {
|
|||||||
console.error(loadError)
|
console.error(loadError)
|
||||||
setError(loadError.message || 'Erro ao carregar agenda.')
|
setError(loadError.message || 'Erro ao carregar agenda.')
|
||||||
} finally {
|
} finally {
|
||||||
if (active) {
|
if (active) setLoading(false)
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +112,7 @@ export function useAgenda() {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!modalOpen) return
|
if (!modalOpen || editingAppointment) return
|
||||||
|
|
||||||
const targetProfessionalId = agendaScope === 'doctor'
|
const targetProfessionalId = agendaScope === 'doctor'
|
||||||
? currentProfessional?.id
|
? currentProfessional?.id
|
||||||
@@ -160,7 +163,7 @@ export function useAgenda() {
|
|||||||
return () => {
|
return () => {
|
||||||
active = false
|
active = false
|
||||||
}
|
}
|
||||||
}, [agendaScope, baseDate, currentProfessional?.id, form.mode, form.professionalId, modalOpen])
|
}, [agendaScope, baseDate, currentProfessional?.id, editingAppointment, form.mode, form.professionalId, modalOpen])
|
||||||
|
|
||||||
const visibleAppointments = useMemo(() => {
|
const visibleAppointments = useMemo(() => {
|
||||||
let filtered = localAppointments
|
let filtered = localAppointments
|
||||||
@@ -205,46 +208,154 @@ export function useAgenda() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return sortAppointmentsByTime(filtered)
|
return sortAppointmentsByTime(filtered)
|
||||||
}, [localAppointments, status, agendaScope, doctorFilter, doctorSearch, unitFilter, professionals, activeView, baseDate])
|
}, [activeView, agendaScope, baseDate, doctorFilter, doctorSearch, localAppointments, professionals, status, unitFilter])
|
||||||
|
|
||||||
function updateForm(field, value) {
|
function updateForm(field, value) {
|
||||||
setForm((current) => ({ ...current, [field]: value }))
|
setForm((current) => ({ ...current, [field]: value }))
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleCreate(event) {
|
function openCreateModal({ date, time } = {}) {
|
||||||
|
if (date) {
|
||||||
|
const parsedDate = parseLocalDate(date)
|
||||||
|
if (parsedDate) setBaseDate(parsedDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
setEditingAppointment(null)
|
||||||
|
setAvailableSlots([])
|
||||||
|
setSlotsError('')
|
||||||
|
setForm((current) => ({
|
||||||
|
...initialForm,
|
||||||
|
patientId: current.patientId || patients[0]?.id || '',
|
||||||
|
professionalId:
|
||||||
|
agendaScope === 'doctor'
|
||||||
|
? currentProfessional?.id || ''
|
||||||
|
: current.professionalId || professionals[0]?.id || '',
|
||||||
|
time: time || current.time || initialForm.time,
|
||||||
|
}))
|
||||||
|
setModalOpen(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function openAppointmentModal(appointment) {
|
||||||
|
const parsedDate = parseLocalDate(appointment.date)
|
||||||
|
if (parsedDate) setBaseDate(parsedDate)
|
||||||
|
|
||||||
|
setEditingAppointment(appointment)
|
||||||
|
setAvailableSlots([])
|
||||||
|
setSlotsError('')
|
||||||
|
setForm({
|
||||||
|
patientId: appointment.patientId || '',
|
||||||
|
professionalId: appointment.professionalId || '',
|
||||||
|
type: appointment.type || initialForm.type,
|
||||||
|
time: appointment.time || initialForm.time,
|
||||||
|
mode: appointment.mode || initialForm.mode,
|
||||||
|
status: appointment.status || initialForm.status,
|
||||||
|
notes: appointment.notes || '',
|
||||||
|
})
|
||||||
|
setModalOpen(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeAppointmentModal() {
|
||||||
|
setModalOpen(false)
|
||||||
|
setEditingAppointment(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmitAppointment(event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
if (!form.patientId) {
|
if (editingAppointment) {
|
||||||
alert('Selecione um paciente para criar o agendamento.')
|
await updateAppointment()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await createAppointment()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createAppointment() {
|
||||||
|
const payload = buildPayload()
|
||||||
|
if (!payload) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
const created = await appointmentRepository.create(payload)
|
||||||
|
setLocalAppointments((current) => sortAppointmentsByTime([...current, enrichAppointment(created, payload, patients, professionals)]))
|
||||||
|
closeAppointmentModal()
|
||||||
|
} catch (createError) {
|
||||||
|
alert(createError.message || 'Erro ao criar agendamento.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateAppointment() {
|
||||||
|
if (!editingAppointment) return
|
||||||
|
|
||||||
|
const payload = buildPayload()
|
||||||
|
if (!payload) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updated = await appointmentRepository.update(editingAppointment.id, payload)
|
||||||
|
setLocalAppointments((current) =>
|
||||||
|
sortAppointmentsByTime(
|
||||||
|
current.map((appointment) =>
|
||||||
|
appointment.id === editingAppointment.id
|
||||||
|
? enrichAppointment(updated, payload, patients, professionals)
|
||||||
|
: appointment,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
closeAppointmentModal()
|
||||||
|
} catch (updateError) {
|
||||||
|
alert(updateError.message || 'Erro ao atualizar agendamento.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleCancelAppointment() {
|
||||||
|
if (!editingAppointment) return
|
||||||
|
if (!window.confirm('Tem certeza que deseja cancelar este agendamento?')) return
|
||||||
|
|
||||||
|
const payload = buildPayload({ status: 'Cancelada' })
|
||||||
|
if (!payload) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cancelled = await appointmentRepository.cancel(editingAppointment.id, payload)
|
||||||
|
setLocalAppointments((current) =>
|
||||||
|
sortAppointmentsByTime(
|
||||||
|
current.map((appointment) =>
|
||||||
|
appointment.id === editingAppointment.id
|
||||||
|
? enrichAppointment(cancelled, payload, patients, professionals)
|
||||||
|
: appointment,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
closeAppointmentModal()
|
||||||
|
} catch (cancelError) {
|
||||||
|
alert(cancelError.message || 'Erro ao cancelar agendamento.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildPayload(overrides = {}) {
|
||||||
|
if (!form.patientId) {
|
||||||
|
alert('Selecione um paciente para salvar o agendamento.')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
const targetProfessionalId = agendaScope === 'doctor'
|
const targetProfessionalId = agendaScope === 'doctor'
|
||||||
? currentProfessional?.id
|
? currentProfessional?.id
|
||||||
: form.professionalId
|
: form.professionalId
|
||||||
|
|
||||||
if (!targetProfessionalId) {
|
if (!targetProfessionalId) {
|
||||||
alert('Não foi possível identificar o profissional da consulta.')
|
alert('Não foi possível identificar o profissional da consulta.')
|
||||||
return
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateStr = formatLocalDateInput(baseDate)
|
return {
|
||||||
|
patientId: form.patientId,
|
||||||
try {
|
date: formatLocalDateInput(baseDate),
|
||||||
const created = await appointmentRepository.create({
|
time: form.time,
|
||||||
patientId: form.patientId,
|
type: form.type,
|
||||||
date: dateStr,
|
mode: form.mode,
|
||||||
time: form.time,
|
status: form.status,
|
||||||
type: form.type,
|
notes: form.notes,
|
||||||
mode: form.mode,
|
room: form.mode === 'Teleconsulta' ? 'Virtual' : 'Consultório 1',
|
||||||
room: form.mode === 'Teleconsulta' ? 'Virtual' : 'Consultório 1',
|
professionalId: targetProfessionalId,
|
||||||
professionalId: targetProfessionalId,
|
...overrides,
|
||||||
})
|
|
||||||
|
|
||||||
setLocalAppointments((current) => sortAppointmentsByTime([...current, created]))
|
|
||||||
setModalOpen(false)
|
|
||||||
} catch (createError) {
|
|
||||||
alert(createError.message || 'Erro ao criar agendamento.')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,10 +381,14 @@ export function useAgenda() {
|
|||||||
unitFilter,
|
unitFilter,
|
||||||
setUnitFilter,
|
setUnitFilter,
|
||||||
modalOpen,
|
modalOpen,
|
||||||
setModalOpen,
|
editingAppointment,
|
||||||
form,
|
form,
|
||||||
updateForm,
|
updateForm,
|
||||||
handleCreate,
|
openCreateModal,
|
||||||
|
openAppointmentModal,
|
||||||
|
closeAppointmentModal,
|
||||||
|
handleSubmitAppointment,
|
||||||
|
handleCancelAppointment,
|
||||||
visibleAppointments,
|
visibleAppointments,
|
||||||
availableSlots,
|
availableSlots,
|
||||||
slotsLoading,
|
slotsLoading,
|
||||||
@@ -289,6 +404,26 @@ function filterAppointmentsByProfessional(appointments, professionalId) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enrichAppointment(appointment, payload, patients, professionals) {
|
||||||
|
const patient = patients.find((item) => String(item.id) === String(payload.patientId))
|
||||||
|
const professional = professionals.find((item) => String(item.id) === String(payload.professionalId))
|
||||||
|
|
||||||
|
return {
|
||||||
|
...appointment,
|
||||||
|
patientId: payload.patientId,
|
||||||
|
professionalId: payload.professionalId,
|
||||||
|
patient: patient?.name || patient?.full_name || patient?.nome || appointment.patient,
|
||||||
|
professional: professional?.name || professional?.full_name || professional?.nome || appointment.professional,
|
||||||
|
date: payload.date,
|
||||||
|
time: payload.time,
|
||||||
|
type: payload.type,
|
||||||
|
mode: payload.mode,
|
||||||
|
status: payload.status,
|
||||||
|
notes: payload.notes,
|
||||||
|
room: payload.room,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeValue(value) {
|
function normalizeValue(value) {
|
||||||
return String(value || '').trim().toLowerCase()
|
return String(value || '').trim().toLowerCase()
|
||||||
}
|
}
|
||||||
|
|||||||
373
src/index.css
373
src/index.css
@@ -46,12 +46,12 @@ button:disabled {
|
|||||||
|
|
||||||
:root[data-theme='light'] {
|
:root[data-theme='light'] {
|
||||||
color: #333333;
|
color: #333333;
|
||||||
background: #eef2f7;
|
background: #cfd7e0;
|
||||||
color-scheme: light;
|
color-scheme: light;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-theme='light'] body {
|
[data-theme='light'] body {
|
||||||
background: #eef2f7;
|
background: #cfd7e0;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ button:disabled {
|
|||||||
|
|
||||||
[data-theme='light'] .bg-\[\#0a0a0a\],
|
[data-theme='light'] .bg-\[\#0a0a0a\],
|
||||||
[data-theme='light'] .bg-\[\#171717\] {
|
[data-theme='light'] .bg-\[\#171717\] {
|
||||||
background-color: #eef2f7;
|
background-color: #cfd7e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-theme='light'] .bg-\[\#1a1a1a\] {
|
[data-theme='light'] .bg-\[\#1a1a1a\] {
|
||||||
@@ -106,7 +106,7 @@ button:disabled {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[data-theme='light'] .disabled\:bg-\[\#303030\]:disabled {
|
[data-theme='light'] .disabled\:bg-\[\#303030\]:disabled {
|
||||||
background-color: #eef2f7;
|
background-color: #cfd7e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-theme='light'] .border-\[\#404040\],
|
[data-theme='light'] .border-\[\#404040\],
|
||||||
@@ -173,3 +173,368 @@ button:disabled {
|
|||||||
[data-theme='light'] svg [fill='#171717'] {
|
[data-theme='light'] svg [fill='#171717'] {
|
||||||
fill: #f9fafb;
|
fill: #f9fafb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.auth-dark {
|
||||||
|
background: #0a0a0a;
|
||||||
|
color: #ffffff;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
.auth-dark .auth-input {
|
||||||
|
border-color: #404040;
|
||||||
|
background: #171717;
|
||||||
|
color: #e5e5e5;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
.auth-dark .auth-input::placeholder {
|
||||||
|
color: #737373;
|
||||||
|
}
|
||||||
|
|
||||||
|
.auth-dark .auth-menu {
|
||||||
|
border-color: #404040;
|
||||||
|
background: #171717;
|
||||||
|
color: #a3a3a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.auth-dark .auth-menu:hover {
|
||||||
|
color: #e5e5e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .auth-dark {
|
||||||
|
background: #0a0a0a;
|
||||||
|
color: #ffffff;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .auth-dark .auth-input {
|
||||||
|
border-color: #404040;
|
||||||
|
background: #171717;
|
||||||
|
color: #e5e5e5;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .auth-dark .auth-input::placeholder {
|
||||||
|
color: #737373;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .auth-dark .auth-menu {
|
||||||
|
border-color: #404040;
|
||||||
|
background: #171717;
|
||||||
|
color: #a3a3a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .auth-dark .auth-menu:hover {
|
||||||
|
color: #e5e5e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .settings-theme-preview-dark {
|
||||||
|
border-color: #525252;
|
||||||
|
background: #0a0a0a;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .settings-theme-preview-dark .settings-theme-preview-bar {
|
||||||
|
background: #262626;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .settings-theme-preview-dark .settings-theme-preview-side {
|
||||||
|
background: #171717;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .settings-theme-preview-dark .settings-theme-preview-line {
|
||||||
|
background: #525252;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .settings-theme-preview-light {
|
||||||
|
border-color: #d6dee8;
|
||||||
|
background: #f4f7fb;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] button:has(.settings-theme-preview-dark) .bg-\[\#3b82f6\] {
|
||||||
|
background-color: #404040;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-calendar-shell {
|
||||||
|
border-color: #3b3b3b;
|
||||||
|
background: #202020;
|
||||||
|
box-shadow: 0 16px 32px rgba(0, 0, 0, 0.32);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-calendar-header {
|
||||||
|
border-color: #3b3b3b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-legend-pill {
|
||||||
|
border-color: #404040;
|
||||||
|
background: #171717;
|
||||||
|
color: #a3a3a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-legend-free {
|
||||||
|
border-color: #166534;
|
||||||
|
background: #052e1a;
|
||||||
|
color: #86efac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-legend-booked {
|
||||||
|
border-color: #a16207;
|
||||||
|
background: #422006;
|
||||||
|
color: #fde68a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-day-grid {
|
||||||
|
gap: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid #3b3b3b;
|
||||||
|
border-radius: 14px;
|
||||||
|
background:
|
||||||
|
repeating-linear-gradient(
|
||||||
|
to bottom,
|
||||||
|
#1f2933 0,
|
||||||
|
#1f2933 39px,
|
||||||
|
#334155 40px
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot {
|
||||||
|
margin: 0;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 0;
|
||||||
|
color: #e5e5e5;
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 14px rgba(0, 0, 0, 0.28);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot + .agenda-slot {
|
||||||
|
border-top-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot-free {
|
||||||
|
border-color: #15803d;
|
||||||
|
background: linear-gradient(180deg, #083d22 0%, #052e1a 100%);
|
||||||
|
color: #bbf7d0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot-waiting,
|
||||||
|
.agenda-event-waiting {
|
||||||
|
border-color: #b7791f;
|
||||||
|
background: linear-gradient(180deg, #53350a 0%, #3f2a09 100%);
|
||||||
|
color: #fde68a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot-confirmed,
|
||||||
|
.agenda-event-confirmed {
|
||||||
|
border-color: #0891b2;
|
||||||
|
background: linear-gradient(180deg, #083344 0%, #0c2636 100%);
|
||||||
|
color: #a5f3fc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot-triage,
|
||||||
|
.agenda-event-triage {
|
||||||
|
border-color: #9333ea;
|
||||||
|
background: linear-gradient(180deg, #3b0764 0%, #2e0a4f 100%);
|
||||||
|
color: #e9d5ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-event-finished {
|
||||||
|
border-color: #2563eb;
|
||||||
|
background: linear-gradient(180deg, #172554 0%, #111c3d 100%);
|
||||||
|
color: #bfdbfe;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot-cancelled,
|
||||||
|
.agenda-event-cancelled {
|
||||||
|
border-color: #b91c1c;
|
||||||
|
background: linear-gradient(180deg, #4c0519 0%, #3b0713 100%);
|
||||||
|
color: #fecdd3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot-blocked,
|
||||||
|
.agenda-event-blocked {
|
||||||
|
border-color: #525252;
|
||||||
|
background: linear-gradient(180deg, #262626 0%, #1f1f1f 100%);
|
||||||
|
color: #a3a3a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot-chip,
|
||||||
|
.agenda-slot-status {
|
||||||
|
border-color: rgba(229, 229, 229, 0.12);
|
||||||
|
background: rgba(0, 0, 0, 0.26);
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot-add {
|
||||||
|
border-color: rgba(229, 229, 229, 0.18);
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-slot-add:hover {
|
||||||
|
background: rgba(0, 0, 0, 0.46);
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-week-day,
|
||||||
|
.agenda-month-day {
|
||||||
|
border-color: #3b3b3b;
|
||||||
|
background: #1f1f1f;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-month-day:nth-child(7n + 1),
|
||||||
|
.agenda-month-day:nth-child(7n) {
|
||||||
|
background: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-event,
|
||||||
|
.agenda-month-event {
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agenda-event span,
|
||||||
|
.agenda-month-event span {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-calendar-shell {
|
||||||
|
border-color: #d7e2ec;
|
||||||
|
background: #f8fbfd;
|
||||||
|
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-calendar-header {
|
||||||
|
border-color: #dbe7f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-legend-pill {
|
||||||
|
border-color: #d7e2ec;
|
||||||
|
background: #ffffff;
|
||||||
|
color: #475569;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-legend-free {
|
||||||
|
border-color: #86c98a;
|
||||||
|
background: #eaf9ea;
|
||||||
|
color: #166534;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-legend-booked {
|
||||||
|
border-color: #f0b23d;
|
||||||
|
background: #fff5cf;
|
||||||
|
color: #7a4a05;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-day-grid {
|
||||||
|
gap: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid #d7e2ec;
|
||||||
|
border-radius: 14px;
|
||||||
|
background:
|
||||||
|
repeating-linear-gradient(
|
||||||
|
to bottom,
|
||||||
|
#eef4f8 0,
|
||||||
|
#eef4f8 39px,
|
||||||
|
#dbe7f1 40px
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot {
|
||||||
|
margin: 0;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 0;
|
||||||
|
color: #334155;
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 2px 8px rgba(15, 23, 42, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot + .agenda-slot {
|
||||||
|
border-top-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot-free {
|
||||||
|
border-color: #97d39b;
|
||||||
|
background: linear-gradient(180deg, #f2fff2 0%, #e6f7e7 100%);
|
||||||
|
color: #14532d;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot-waiting,
|
||||||
|
[data-theme='light'] .agenda-event-waiting {
|
||||||
|
border-color: #f0b23d;
|
||||||
|
background: linear-gradient(180deg, #fff8d7 0%, #fff2b7 100%);
|
||||||
|
color: #6f4700;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot-confirmed,
|
||||||
|
[data-theme='light'] .agenda-event-confirmed {
|
||||||
|
border-color: #26b8ec;
|
||||||
|
background: linear-gradient(180deg, #e5faff 0%, #cef3ff 100%);
|
||||||
|
color: #075985;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot-triage,
|
||||||
|
[data-theme='light'] .agenda-event-triage {
|
||||||
|
border-color: #b35cff;
|
||||||
|
background: linear-gradient(180deg, #f8ddff 0%, #edc4ff 100%);
|
||||||
|
color: #5b217f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-event-finished {
|
||||||
|
border-color: #60a5fa;
|
||||||
|
background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
|
||||||
|
color: #1e3a8a;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot-cancelled,
|
||||||
|
[data-theme='light'] .agenda-event-cancelled {
|
||||||
|
border-color: #fb7185;
|
||||||
|
background: linear-gradient(180deg, #ffe4e6 0%, #fecdd3 100%);
|
||||||
|
color: #991b1b;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot-blocked,
|
||||||
|
[data-theme='light'] .agenda-event-blocked {
|
||||||
|
border-color: #cbd5e1;
|
||||||
|
background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
|
||||||
|
color: #475569;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot-chip,
|
||||||
|
[data-theme='light'] .agenda-slot-status {
|
||||||
|
border-color: rgba(51, 65, 85, 0.18);
|
||||||
|
background: rgba(255, 255, 255, 0.58);
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot-add {
|
||||||
|
border-color: rgba(30, 64, 175, 0.28);
|
||||||
|
background: rgba(255, 255, 255, 0.76);
|
||||||
|
color: #1d4ed8;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-slot-add:hover {
|
||||||
|
background: #ffffff;
|
||||||
|
box-shadow: 0 2px 8px rgba(37, 99, 235, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-week-day,
|
||||||
|
[data-theme='light'] .agenda-month-day {
|
||||||
|
border-color: #d7e2ec;
|
||||||
|
background: #eef4f8;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-month-day:nth-child(7n + 1),
|
||||||
|
[data-theme='light'] .agenda-month-day:nth-child(7n) {
|
||||||
|
background: #e8f0f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-event,
|
||||||
|
[data-theme='light'] .agenda-month-event {
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78), 0 1px 4px rgba(15, 23, 42, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='light'] .agenda-event span,
|
||||||
|
[data-theme='light'] .agenda-month-event span {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const appointmentMapper = {
|
|||||||
cancelled: 'Cancelada',
|
cancelled: 'Cancelada',
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawStatus = (apiData.status || '').toLowerCase()
|
const rawStatus = String(apiData.status || '').toLowerCase()
|
||||||
const mappedStatus = statusMap[rawStatus] || apiData.situacao || 'Aguardando'
|
const mappedStatus = statusMap[rawStatus] || apiData.situacao || 'Aguardando'
|
||||||
|
|
||||||
// Modalidade
|
// Modalidade
|
||||||
@@ -66,6 +66,7 @@ export const appointmentMapper = {
|
|||||||
type: apiData.type || apiData.tipo || apiData.tipo_consulta || 'Consulta',
|
type: apiData.type || apiData.tipo || apiData.tipo_consulta || 'Consulta',
|
||||||
mode: mode,
|
mode: mode,
|
||||||
status: mappedStatus,
|
status: mappedStatus,
|
||||||
|
notes: apiData.notes || apiData.observations || apiData.observacoes || apiData.observacao || apiData.description || '',
|
||||||
room: apiData.room || apiData.sala || apiData.local || 'Consultório 1',
|
room: apiData.room || apiData.sala || apiData.local || 'Consultório 1',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -80,7 +81,9 @@ export const appointmentMapper = {
|
|||||||
doctor_id: uiData.professionalId || null,
|
doctor_id: uiData.professionalId || null,
|
||||||
scheduled_at: scheduledAt,
|
scheduled_at: scheduledAt,
|
||||||
appointment_type: uiData.mode === 'Teleconsulta' ? 'telemedicina' : 'presencial',
|
appointment_type: uiData.mode === 'Teleconsulta' ? 'telemedicina' : 'presencial',
|
||||||
status: uiData.status === 'Confirmada' ? 'confirmed' : 'requested',
|
status: toApiStatus(uiData.status),
|
||||||
|
notes: emptyToUndefined(uiData.notes),
|
||||||
|
observations: emptyToUndefined(uiData.notes),
|
||||||
duration_minutes: 30, // Padrao
|
duration_minutes: 30, // Padrao
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,6 +97,37 @@ export const appointmentMapper = {
|
|||||||
mode: uiData.mode,
|
mode: uiData.mode,
|
||||||
status: uiData.status || 'Confirmada',
|
status: uiData.status || 'Confirmada',
|
||||||
room: uiData.room,
|
room: uiData.room,
|
||||||
|
notes: uiData.notes,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function emptyToUndefined(value) {
|
||||||
|
return value === '' || value === null ? undefined : value
|
||||||
|
}
|
||||||
|
|
||||||
|
function toApiStatus(status) {
|
||||||
|
const normalized = String(status || '')
|
||||||
|
.normalize('NFD')
|
||||||
|
.replace(/[\u0300-\u036f]/g, '')
|
||||||
|
.trim()
|
||||||
|
.toLowerCase()
|
||||||
|
|
||||||
|
const statusMap = {
|
||||||
|
confirmada: 'confirmed',
|
||||||
|
confirmado: 'confirmed',
|
||||||
|
em_triagem: 'checked_in',
|
||||||
|
triagem: 'checked_in',
|
||||||
|
aguardando: 'requested',
|
||||||
|
solicitada: 'requested',
|
||||||
|
solicitacao: 'requested',
|
||||||
|
cancelada: 'cancelled',
|
||||||
|
cancelado: 'cancelled',
|
||||||
|
concluida: 'completed',
|
||||||
|
concluido: 'completed',
|
||||||
|
finalizada: 'completed',
|
||||||
|
finalizado: 'completed',
|
||||||
|
}
|
||||||
|
|
||||||
|
return statusMap[normalized.replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '')] || 'requested'
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ export const reportMapper = {
|
|||||||
conclusion: emptyToUndefined(uiData.conclusion),
|
conclusion: emptyToUndefined(uiData.conclusion),
|
||||||
content_html: emptyToUndefined(uiData.contentHtml),
|
content_html: emptyToUndefined(uiData.contentHtml),
|
||||||
content_json: uiData.contentJson === undefined ? undefined : uiData.contentJson,
|
content_json: uiData.contentJson === undefined ? undefined : uiData.contentJson,
|
||||||
hide_date: Boolean(uiData.hideDate),
|
|
||||||
hide_signature: Boolean(uiData.hideSignature),
|
|
||||||
due_at: emptyToUndefined(uiData.dueAt),
|
due_at: emptyToUndefined(uiData.dueAt),
|
||||||
created_by: emptyToUndefined(uiData.createdBy),
|
created_by: emptyToUndefined(uiData.createdBy),
|
||||||
updated_by: emptyToUndefined(uiData.updatedBy),
|
updated_by: emptyToUndefined(uiData.updatedBy),
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import {
|
import {
|
||||||
addDays,
|
addDays,
|
||||||
subDays,
|
|
||||||
addWeeks,
|
|
||||||
subWeeks,
|
|
||||||
addMonths,
|
addMonths,
|
||||||
subMonths,
|
addWeeks,
|
||||||
endOfWeek,
|
endOfWeek,
|
||||||
format,
|
format,
|
||||||
startOfWeek,
|
startOfWeek,
|
||||||
|
subDays,
|
||||||
|
subMonths,
|
||||||
|
subWeeks,
|
||||||
} from 'date-fns'
|
} from 'date-fns'
|
||||||
import { ptBR } from 'date-fns/locale'
|
import { ptBR } from 'date-fns/locale'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
import { AgendaDailyView } from '../components/calendar/AgendaDailyView.jsx'
|
import { AgendaDailyView } from '../components/calendar/AgendaDailyView.jsx'
|
||||||
import { AgendaWeeklyView } from '../components/calendar/AgendaWeeklyView.jsx'
|
|
||||||
import { AgendaMonthlyView } from '../components/calendar/AgendaMonthlyView.jsx'
|
import { AgendaMonthlyView } from '../components/calendar/AgendaMonthlyView.jsx'
|
||||||
|
import { AgendaWeeklyView } from '../components/calendar/AgendaWeeklyView.jsx'
|
||||||
import { useAgenda } from '../hooks/useAgenda.js'
|
import { useAgenda } from '../hooks/useAgenda.js'
|
||||||
import { formatLocalDateInput, parseLocalDate } from '../utils/agendaDate.js'
|
import { formatLocalDateInput, parseLocalDate } from '../utils/agendaDate.js'
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@ const statusFilters = [
|
|||||||
{ label: 'Confirmadas', value: 'Confirmada' },
|
{ label: 'Confirmadas', value: 'Confirmada' },
|
||||||
{ label: 'Em triagem', value: 'Em triagem' },
|
{ label: 'Em triagem', value: 'Em triagem' },
|
||||||
{ label: 'Aguardando', value: 'Aguardando' },
|
{ label: 'Aguardando', value: 'Aguardando' },
|
||||||
|
{ label: 'Canceladas', value: 'Cancelada' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const viewFilters = [
|
const viewFilters = [
|
||||||
@@ -32,8 +33,9 @@ const viewFilters = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const appointmentTypeOptions = ['Retorno', 'Primeira consulta', 'Exame', 'Avaliação pre-op']
|
const appointmentTypeOptions = ['Retorno', 'Primeira consulta', 'Exame', 'Avaliação pre-op']
|
||||||
|
const appointmentStatusOptions = ['Confirmada', 'Em triagem', 'Aguardando']
|
||||||
|
|
||||||
export function AgendaPage({ navigate }) {
|
export function AgendaPage() {
|
||||||
const [modalPatientSearch, setModalPatientSearch] = useState('')
|
const [modalPatientSearch, setModalPatientSearch] = useState('')
|
||||||
const [modalDoctorSearch, setModalDoctorSearch] = useState('')
|
const [modalDoctorSearch, setModalDoctorSearch] = useState('')
|
||||||
const {
|
const {
|
||||||
@@ -57,10 +59,14 @@ export function AgendaPage({ navigate }) {
|
|||||||
unitFilter,
|
unitFilter,
|
||||||
setUnitFilter,
|
setUnitFilter,
|
||||||
modalOpen,
|
modalOpen,
|
||||||
setModalOpen,
|
editingAppointment,
|
||||||
form,
|
form,
|
||||||
updateForm,
|
updateForm,
|
||||||
handleCreate,
|
openCreateModal,
|
||||||
|
openAppointmentModal,
|
||||||
|
closeAppointmentModal,
|
||||||
|
handleSubmitAppointment,
|
||||||
|
handleCancelAppointment,
|
||||||
visibleAppointments,
|
visibleAppointments,
|
||||||
availableSlots,
|
availableSlots,
|
||||||
slotsLoading,
|
slotsLoading,
|
||||||
@@ -79,42 +85,41 @@ export function AgendaPage({ navigate }) {
|
|||||||
const weekEnd = endOfWeek(baseDate, { weekStartsOn: 0 })
|
const weekEnd = endOfWeek(baseDate, { weekStartsOn: 0 })
|
||||||
const isDoctorScope = agendaScope === 'doctor'
|
const isDoctorScope = agendaScope === 'doctor'
|
||||||
const unitOptions = [
|
const unitOptions = [
|
||||||
...new Set(
|
...new Set(professionals.map((professional) => professional.unit).filter(Boolean)),
|
||||||
professionals
|
|
||||||
.map((professional) => professional.unit)
|
|
||||||
.filter(Boolean),
|
|
||||||
),
|
|
||||||
].sort((a, b) => a.localeCompare(b, 'pt-BR'))
|
].sort((a, b) => a.localeCompare(b, 'pt-BR'))
|
||||||
const filteredPatients = (() => {
|
const filteredPatients = filterBySearch(patients, modalPatientSearch, (patient) => [
|
||||||
const query = normalizeSearch(modalPatientSearch)
|
patient.name,
|
||||||
if (!query) return patients
|
patient.full_name,
|
||||||
|
patient.nome,
|
||||||
return patients.filter((patient) =>
|
patient.cpf,
|
||||||
[patient.name, patient.full_name, patient.nome, patient.cpf, patient.email]
|
patient.email,
|
||||||
.filter(Boolean)
|
])
|
||||||
.join(' ')
|
const filteredProfessionals = filterBySearch(professionals, modalDoctorSearch, (professional) => [
|
||||||
.normalize('NFD')
|
professional.name,
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
professional.email,
|
||||||
.toLowerCase()
|
professional.unit,
|
||||||
.includes(query),
|
])
|
||||||
)
|
|
||||||
})()
|
|
||||||
const filteredProfessionals = (() => {
|
|
||||||
const query = normalizeSearch(modalDoctorSearch)
|
|
||||||
if (!query) return professionals
|
|
||||||
|
|
||||||
return professionals.filter((professional) =>
|
|
||||||
[professional.name, professional.email, professional.unit]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(' ')
|
|
||||||
.normalize('NFD')
|
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
|
||||||
.toLowerCase()
|
|
||||||
.includes(query),
|
|
||||||
)
|
|
||||||
})()
|
|
||||||
const selectedPatient = patients.find((patient) => String(patient.id) === String(form.patientId))
|
const selectedPatient = patients.find((patient) => String(patient.id) === String(form.patientId))
|
||||||
const selectedProfessional = professionals.find((professional) => String(professional.id) === String(form.professionalId))
|
const selectedProfessional = professionals.find((professional) => String(professional.id) === String(form.professionalId))
|
||||||
|
const timeOptions = getTimeOptions(form.time, availableSlots)
|
||||||
|
|
||||||
|
function openCreate(options = {}) {
|
||||||
|
setModalPatientSearch('')
|
||||||
|
setModalDoctorSearch('')
|
||||||
|
openCreateModal(options)
|
||||||
|
}
|
||||||
|
|
||||||
|
function openManage(appointment) {
|
||||||
|
setModalPatientSearch('')
|
||||||
|
setModalDoctorSearch('')
|
||||||
|
openAppointmentModal(appointment)
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
setModalPatientSearch('')
|
||||||
|
setModalDoctorSearch('')
|
||||||
|
closeAppointmentModal()
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto flex max-w-[1180px] flex-col gap-8 text-[#e5e5e5]">
|
<div className="mx-auto flex max-w-[1180px] flex-col gap-8 text-[#e5e5e5]">
|
||||||
@@ -169,7 +174,7 @@ export function AgendaPage({ navigate }) {
|
|||||||
<button
|
<button
|
||||||
className="h-9 rounded-sm border border-[#3b82f6] bg-[#3b82f6] px-4 text-sm font-semibold text-white shadow-[0_10px_15px_rgba(59,130,246,0.16)] transition hover:bg-[#3478ed] disabled:cursor-not-allowed disabled:border-[#404040] disabled:bg-[#303030] disabled:text-[#737373] disabled:shadow-none"
|
className="h-9 rounded-sm border border-[#3b82f6] bg-[#3b82f6] px-4 text-sm font-semibold text-white shadow-[0_10px_15px_rgba(59,130,246,0.16)] transition hover:bg-[#3478ed] disabled:cursor-not-allowed disabled:border-[#404040] disabled:bg-[#303030] disabled:text-[#737373] disabled:shadow-none"
|
||||||
disabled={!canCreateAppointment}
|
disabled={!canCreateAppointment}
|
||||||
onClick={() => setModalOpen(true)}
|
onClick={() => openCreate()}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
+ Novo agendamento
|
+ Novo agendamento
|
||||||
@@ -283,7 +288,7 @@ export function AgendaPage({ navigate }) {
|
|||||||
<AgendaWeeklyView
|
<AgendaWeeklyView
|
||||||
baseDate={baseDate}
|
baseDate={baseDate}
|
||||||
appointments={visibleAppointments}
|
appointments={visibleAppointments}
|
||||||
onAppointmentClick={(appointment) => navigate(`/pacientes/${appointment.patientId}`)}
|
onAppointmentClick={openManage}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -300,9 +305,11 @@ export function AgendaPage({ navigate }) {
|
|||||||
|
|
||||||
{activeView === 'Dia' && (
|
{activeView === 'Dia' && (
|
||||||
<AgendaDailyView
|
<AgendaDailyView
|
||||||
baseDate={baseDate}
|
|
||||||
appointments={visibleAppointments}
|
appointments={visibleAppointments}
|
||||||
onAppointmentClick={(appointment) => navigate(`/pacientes/${appointment.patientId}`)}
|
baseDate={baseDate}
|
||||||
|
canCreateAppointment={canCreateAppointment}
|
||||||
|
onAppointmentClick={openManage}
|
||||||
|
onSlotCreate={(time) => openCreate({ time })}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -310,54 +317,93 @@ export function AgendaPage({ navigate }) {
|
|||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DarkModal onClose={() => setModalOpen(false)} open={modalOpen} title="Novo agendamento">
|
<DarkModal onClose={closeModal} open={modalOpen} title={editingAppointment ? 'Gerenciar agendamento' : 'Novo agendamento'}>
|
||||||
<form className="grid gap-4" onSubmit={handleCreate}>
|
<form className="grid gap-4" onSubmit={handleSubmitAppointment}>
|
||||||
<DarkField label="Dia do agendamento">
|
<div className="grid gap-4 lg:grid-cols-2">
|
||||||
<input
|
<div className="grid content-start gap-4">
|
||||||
className="h-11 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none [color-scheme:dark] focus:border-[#3b82f6]"
|
<DarkField label="Paciente">
|
||||||
onChange={(event) => {
|
<input
|
||||||
const parsedDate = parseLocalDate(event.target.value)
|
className="h-10 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none transition placeholder:text-[#737373] focus:border-[#3b82f6]"
|
||||||
if (parsedDate) setBaseDate(parsedDate)
|
onChange={(event) => {
|
||||||
}}
|
setModalPatientSearch(event.target.value)
|
||||||
type="date"
|
updateForm('patientId', '')
|
||||||
value={formatLocalDateInput(baseDate)}
|
}}
|
||||||
/>
|
placeholder="Pesquisar paciente"
|
||||||
</DarkField>
|
type="search"
|
||||||
|
value={modalPatientSearch || getPatientLabel(selectedPatient)}
|
||||||
|
/>
|
||||||
|
<SearchResults
|
||||||
|
emptyText="Nenhum paciente encontrado."
|
||||||
|
getLabel={getPatientLabel}
|
||||||
|
items={filteredPatients.slice(0, 5)}
|
||||||
|
onSelect={(patient) => {
|
||||||
|
updateForm('patientId', patient.id)
|
||||||
|
setModalPatientSearch(getPatientLabel(patient))
|
||||||
|
}}
|
||||||
|
selectedId={form.patientId}
|
||||||
|
/>
|
||||||
|
</DarkField>
|
||||||
|
|
||||||
<DarkField label="Paciente">
|
<DarkField label="Profissional">
|
||||||
<input
|
{isDoctorScope ? (
|
||||||
className="h-10 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none transition placeholder:text-[#737373] focus:border-[#3b82f6]"
|
<input
|
||||||
onChange={(event) => {
|
className="h-11 rounded-md border border-[#404040] bg-[#262626] px-3 text-sm text-[#a3a3a3] outline-none"
|
||||||
setModalPatientSearch(event.target.value)
|
disabled
|
||||||
updateForm('patientId', '')
|
readOnly
|
||||||
}}
|
value={currentProfessional?.name || 'Médico não vinculado'}
|
||||||
placeholder="Pesquisar paciente"
|
/>
|
||||||
type="search"
|
) : (
|
||||||
value={modalPatientSearch || getPatientLabel(selectedPatient)}
|
<>
|
||||||
/>
|
<input
|
||||||
<SearchResults
|
className="h-10 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none transition placeholder:text-[#737373] focus:border-[#3b82f6]"
|
||||||
emptyText="Nenhum paciente encontrado."
|
onChange={(event) => {
|
||||||
getLabel={getPatientLabel}
|
setModalDoctorSearch(event.target.value)
|
||||||
items={filteredPatients.slice(0, 6)}
|
updateForm('professionalId', '')
|
||||||
onSelect={(patient) => {
|
}}
|
||||||
updateForm('patientId', patient.id)
|
placeholder="Pesquisar médico"
|
||||||
setModalPatientSearch(getPatientLabel(patient))
|
type="search"
|
||||||
}}
|
value={modalDoctorSearch || selectedProfessional?.name || ''}
|
||||||
selectedId={form.patientId}
|
/>
|
||||||
/>
|
<SearchResults
|
||||||
</DarkField>
|
emptyText="Nenhum médico encontrado."
|
||||||
|
getDescription={(professional) => professional.unit || professional.email}
|
||||||
|
getLabel={(professional) => professional.name}
|
||||||
|
items={filteredProfessionals.slice(0, 5)}
|
||||||
|
onSelect={(professional) => {
|
||||||
|
updateForm('professionalId', professional.id)
|
||||||
|
setModalDoctorSearch(professional.name)
|
||||||
|
}}
|
||||||
|
selectedId={form.professionalId}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</DarkField>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-4 sm:grid-cols-2">
|
<div className="grid content-start gap-4">
|
||||||
<DarkField label="Horário">
|
<div className="grid gap-4 sm:grid-cols-2">
|
||||||
{availableSlots.length ? (
|
<DarkField label="Dia">
|
||||||
|
<input
|
||||||
|
className="h-11 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none [color-scheme:dark] focus:border-[#3b82f6]"
|
||||||
|
onChange={(event) => {
|
||||||
|
const parsedDate = parseLocalDate(event.target.value)
|
||||||
|
if (parsedDate) setBaseDate(parsedDate)
|
||||||
|
}}
|
||||||
|
type="date"
|
||||||
|
value={formatLocalDateInput(baseDate)}
|
||||||
|
/>
|
||||||
|
</DarkField>
|
||||||
|
|
||||||
|
<DarkField label="Horário">
|
||||||
|
{timeOptions.length ? (
|
||||||
<select
|
<select
|
||||||
className="h-11 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none focus:border-[#3b82f6]"
|
className="h-11 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none focus:border-[#3b82f6]"
|
||||||
onChange={(event) => updateForm('time', event.target.value)}
|
onChange={(event) => updateForm('time', event.target.value)}
|
||||||
value={form.time}
|
value={form.time}
|
||||||
>
|
>
|
||||||
{availableSlots.map((slot) => (
|
{timeOptions.map((time) => (
|
||||||
<option key={slot.time} value={slot.time}>
|
<option key={time} value={time}>
|
||||||
{slot.time}
|
{time}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
@@ -369,88 +415,99 @@ export function AgendaPage({ navigate }) {
|
|||||||
value={form.time}
|
value={form.time}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{slotsLoading ? (
|
{slotsLoading ? <span className="text-xs font-normal text-[#a3a3a3]">Calculando horários...</span> : null}
|
||||||
<span className="text-xs font-normal text-[#a3a3a3]">Calculando horários...</span>
|
{slotsError ? <span className="text-xs font-normal text-amber-400">{slotsError}</span> : null}
|
||||||
) : null}
|
</DarkField>
|
||||||
{slotsError ? (
|
</div>
|
||||||
<span className="text-xs font-normal text-amber-400">{slotsError}</span>
|
|
||||||
) : null}
|
<div className="grid gap-4 sm:grid-cols-2">
|
||||||
</DarkField>
|
<DarkField label="Formato">
|
||||||
<DarkField label="Formato">
|
<select
|
||||||
<select
|
className="h-11 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none focus:border-[#3b82f6]"
|
||||||
className="h-11 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none focus:border-[#3b82f6]"
|
onChange={(event) => updateForm('mode', event.target.value)}
|
||||||
onChange={(event) => updateForm('mode', event.target.value)}
|
value={form.mode}
|
||||||
value={form.mode}
|
>
|
||||||
>
|
<option>Teleconsulta</option>
|
||||||
<option>Teleconsulta</option>
|
<option>Presencial</option>
|
||||||
<option>Presencial</option>
|
</select>
|
||||||
</select>
|
</DarkField>
|
||||||
</DarkField>
|
|
||||||
|
<DarkField label="Status">
|
||||||
|
<select
|
||||||
|
className="h-11 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none focus:border-[#3b82f6]"
|
||||||
|
onChange={(event) => updateForm('status', event.target.value)}
|
||||||
|
value={form.status}
|
||||||
|
>
|
||||||
|
{!appointmentStatusOptions.includes(form.status) && form.status ? (
|
||||||
|
<option value={form.status}>{form.status}</option>
|
||||||
|
) : null}
|
||||||
|
{appointmentStatusOptions.map((option) => (
|
||||||
|
<option key={option} value={option}>
|
||||||
|
{option}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</DarkField>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DarkField label="Tipo de consulta">
|
||||||
|
<select
|
||||||
|
className="h-11 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none focus:border-[#3b82f6]"
|
||||||
|
onChange={(event) => updateForm('type', event.target.value)}
|
||||||
|
value={form.type}
|
||||||
|
>
|
||||||
|
{appointmentTypeOptions.map((type) => (
|
||||||
|
<option key={type} value={type}>
|
||||||
|
{type}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</DarkField>
|
||||||
|
|
||||||
|
<DarkField label="Observações">
|
||||||
|
<textarea
|
||||||
|
className="min-h-24 resize-y rounded-md border border-[#404040] bg-[#303030] px-3 py-2 text-sm leading-5 text-[#e5e5e5] outline-none transition placeholder:text-[#737373] focus:border-[#3b82f6]"
|
||||||
|
onChange={(event) => updateForm('notes', event.target.value)}
|
||||||
|
placeholder="Observações sobre o agendamento"
|
||||||
|
value={form.notes}
|
||||||
|
/>
|
||||||
|
</DarkField>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DarkField label="Profissional">
|
{editingAppointment ? (
|
||||||
{isDoctorScope ? (
|
<div className="rounded-xl border border-[#404040] bg-[#1f1f1f] px-4 py-3 text-sm text-[#a3a3a3]">
|
||||||
<input
|
<p>
|
||||||
className="h-11 rounded-md border border-[#404040] bg-[#262626] px-3 text-sm text-[#a3a3a3] outline-none"
|
Agendamento de {selectedPatient ? getPatientLabel(selectedPatient) : 'paciente não informado'} às {form.time}.
|
||||||
disabled
|
</p>
|
||||||
readOnly
|
<p className="mt-1">Status atual: {form.status}</p>
|
||||||
value={currentProfessional?.name || 'Médico não vinculado'}
|
{form.notes ? <p className="mt-1">Observações: {form.notes}</p> : null}
|
||||||
/>
|
</div>
|
||||||
) : (
|
) : null}
|
||||||
<>
|
|
||||||
<input
|
|
||||||
className="h-10 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none transition placeholder:text-[#737373] focus:border-[#3b82f6]"
|
|
||||||
onChange={(event) => {
|
|
||||||
setModalDoctorSearch(event.target.value)
|
|
||||||
updateForm('professionalId', '')
|
|
||||||
}}
|
|
||||||
placeholder="Pesquisar médico"
|
|
||||||
type="search"
|
|
||||||
value={modalDoctorSearch || selectedProfessional?.name || ''}
|
|
||||||
/>
|
|
||||||
<SearchResults
|
|
||||||
emptyText="Nenhum médico encontrado."
|
|
||||||
getDescription={(professional) => professional.unit || professional.email}
|
|
||||||
getLabel={(professional) => professional.name}
|
|
||||||
items={filteredProfessionals.slice(0, 6)}
|
|
||||||
onSelect={(professional) => {
|
|
||||||
updateForm('professionalId', professional.id)
|
|
||||||
setModalDoctorSearch(professional.name)
|
|
||||||
}}
|
|
||||||
selectedId={form.professionalId}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</DarkField>
|
|
||||||
|
|
||||||
<DarkField label="Tipo de consulta">
|
|
||||||
<select
|
|
||||||
className="h-11 rounded-md border border-[#404040] bg-[#303030] px-3 text-sm text-[#e5e5e5] outline-none focus:border-[#3b82f6]"
|
|
||||||
onChange={(event) => updateForm('type', event.target.value)}
|
|
||||||
value={form.type}
|
|
||||||
>
|
|
||||||
{appointmentTypeOptions.map((type) => (
|
|
||||||
<option key={type} value={type}>
|
|
||||||
{type}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</DarkField>
|
|
||||||
|
|
||||||
<div className="flex flex-wrap justify-end gap-3 pt-2">
|
<div className="flex flex-wrap justify-end gap-3 pt-2">
|
||||||
|
{editingAppointment ? (
|
||||||
|
<button
|
||||||
|
className="mr-auto h-10 rounded-sm border border-red-500/40 bg-red-950/20 px-4 text-sm font-semibold text-red-200 transition hover:bg-red-950/35"
|
||||||
|
onClick={handleCancelAppointment}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Cancelar agendamento
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
<button
|
<button
|
||||||
className="h-10 rounded-sm border border-[#404040] bg-[#303030] px-4 text-sm font-semibold text-[#e5e5e5] transition hover:bg-[#333333]"
|
className="h-10 rounded-sm border border-[#404040] bg-[#303030] px-4 text-sm font-semibold text-[#e5e5e5] transition hover:bg-[#333333]"
|
||||||
onClick={() => setModalOpen(false)}
|
onClick={closeModal}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
Cancelar
|
Fechar
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="h-10 rounded-sm border border-[#3b82f6] bg-[#3b82f6] px-4 text-sm font-semibold text-white transition hover:bg-[#3478ed] disabled:cursor-not-allowed disabled:border-[#404040] disabled:bg-[#303030] disabled:text-[#737373]"
|
className="h-10 rounded-sm border border-[#3b82f6] bg-[#3b82f6] px-4 text-sm font-semibold text-white transition hover:bg-[#3478ed] disabled:cursor-not-allowed disabled:border-[#404040] disabled:bg-[#303030] disabled:text-[#737373]"
|
||||||
disabled={!canCreateAppointment}
|
disabled={!canCreateAppointment}
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
Salvar
|
{editingAppointment ? 'Salvar alterações' : 'Salvar'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -469,13 +526,11 @@ function DarkField({ children, label }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function DarkModal({ children, onClose, open, title }) {
|
function DarkModal({ children, onClose, open, title }) {
|
||||||
if (!open) {
|
if (!open) return null
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 z-50 flex items-end justify-center bg-black/60 p-4 sm:items-center">
|
<div className="fixed inset-0 z-50 flex items-end justify-center bg-black/60 p-4 sm:items-center">
|
||||||
<div className="w-full max-w-xl rounded-2xl border border-[#404040] bg-[#262626] shadow-2xl">
|
<div className="w-full max-w-4xl rounded-2xl border border-[#404040] bg-[#262626] shadow-2xl">
|
||||||
<div className="flex items-center justify-between gap-4 border-b border-[#404040] px-5 py-4">
|
<div className="flex items-center justify-between gap-4 border-b border-[#404040] px-5 py-4">
|
||||||
<h2 className="text-lg font-bold text-[#e5e5e5]">{title}</h2>
|
<h2 className="text-lg font-bold text-[#e5e5e5]">{title}</h2>
|
||||||
<button
|
<button
|
||||||
@@ -526,6 +581,30 @@ function getPatientLabel(patient) {
|
|||||||
return patient?.name || patient?.full_name || patient?.nome || ''
|
return patient?.name || patient?.full_name || patient?.nome || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterBySearch(items, search, getValues) {
|
||||||
|
const query = normalizeSearch(search)
|
||||||
|
if (!query) return items
|
||||||
|
|
||||||
|
return items.filter((item) =>
|
||||||
|
getValues(item)
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')
|
||||||
|
.normalize('NFD')
|
||||||
|
.replace(/[\u0300-\u036f]/g, '')
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(query),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTimeOptions(selectedTime, slots) {
|
||||||
|
return [
|
||||||
|
...new Set([
|
||||||
|
selectedTime,
|
||||||
|
...slots.map((slot) => slot.time),
|
||||||
|
].filter(Boolean)),
|
||||||
|
].sort()
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeSearch(value) {
|
function normalizeSearch(value) {
|
||||||
return String(value || '')
|
return String(value || '')
|
||||||
.normalize('NFD')
|
.normalize('NFD')
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export function LoginPage({ navigate }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="min-h-screen bg-[#0a1628] text-white">
|
<main className="auth-dark min-h-screen text-white">
|
||||||
<div className="grid min-h-screen lg:grid-cols-2">
|
<div className="grid min-h-screen lg:grid-cols-2">
|
||||||
<section className="relative hidden min-h-screen overflow-hidden lg:block">
|
<section className="relative hidden min-h-screen overflow-hidden lg:block">
|
||||||
<img
|
<img
|
||||||
@@ -56,7 +56,7 @@ export function LoginPage({ navigate }) {
|
|||||||
className="absolute inset-0"
|
className="absolute inset-0"
|
||||||
style={{
|
style={{
|
||||||
background:
|
background:
|
||||||
'linear-gradient(126.72deg, rgba(10, 22, 40, 0.9) 0%, rgba(10, 22, 40, 0.6) 50%, rgba(59, 130, 246, 0.3) 100%)',
|
'linear-gradient(126.72deg, rgba(10, 10, 10, 0.92) 0%, rgba(23, 23, 23, 0.72) 52%, rgba(59, 130, 246, 0.28) 100%)',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ export function LoginPage({ navigate }) {
|
|||||||
<LoginField htmlFor="login-email" label="E-mail">
|
<LoginField htmlFor="login-email" label="E-mail">
|
||||||
<input
|
<input
|
||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
className="h-11 w-full rounded-[6px] border border-white/10 bg-white/[0.05] px-4 text-sm text-white outline-none transition placeholder:text-white/30 focus:border-[#3b82f6] focus:ring-2 focus:ring-[#3b82f6]/20"
|
className={authInputClass}
|
||||||
id="login-email"
|
id="login-email"
|
||||||
onChange={(event) => updateField('email', event.target.value)}
|
onChange={(event) => updateField('email', event.target.value)}
|
||||||
placeholder="seu@email.com"
|
placeholder="seu@email.com"
|
||||||
@@ -132,7 +132,7 @@ export function LoginPage({ navigate }) {
|
|||||||
<div className="relative">
|
<div className="relative">
|
||||||
<input
|
<input
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
className="h-11 w-full rounded-[6px] border border-white/10 bg-white/[0.05] py-2 pl-4 pr-11 text-sm text-white outline-none transition placeholder:text-white/30 focus:border-[#3b82f6] focus:ring-2 focus:ring-[#3b82f6]/20"
|
className={authPasswordInputClass}
|
||||||
id="login-password"
|
id="login-password"
|
||||||
onChange={(event) => updateField('password', event.target.value)}
|
onChange={(event) => updateField('password', event.target.value)}
|
||||||
placeholder="••••••••"
|
placeholder="••••••••"
|
||||||
@@ -162,7 +162,7 @@ export function LoginPage({ navigate }) {
|
|||||||
|
|
||||||
<div className="absolute bottom-4 right-4">
|
<div className="absolute bottom-4 right-4">
|
||||||
{credentialsOpen ? (
|
{credentialsOpen ? (
|
||||||
<div className="mb-2 w-[292px] rounded-md border border-white/10 bg-[#0f1b2d] p-2 shadow-2xl">
|
<div className="auth-menu mb-2 w-[292px] rounded-md border p-2 shadow-2xl">
|
||||||
<p className="px-2 pb-1 text-[10px] font-semibold uppercase tracking-wide text-white/40">
|
<p className="px-2 pb-1 text-[10px] font-semibold uppercase tracking-wide text-white/40">
|
||||||
Credenciais de acesso
|
Credenciais de acesso
|
||||||
</p>
|
</p>
|
||||||
@@ -188,7 +188,7 @@ export function LoginPage({ navigate }) {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<button
|
<button
|
||||||
className="flex h-[29px] items-center gap-1.5 rounded-sm border border-white/10 bg-white/[0.05] px-3 font-mono text-[10px] font-medium leading-[15px] text-white/30 transition hover:text-white/50"
|
className="auth-menu flex h-[29px] items-center gap-1.5 rounded-sm border px-3 font-mono text-[10px] font-medium leading-[15px] transition"
|
||||||
onClick={() => setCredentialsOpen((current) => !current)}
|
onClick={() => setCredentialsOpen((current) => !current)}
|
||||||
title="Preencher credenciais de acesso"
|
title="Preencher credenciais de acesso"
|
||||||
type="button"
|
type="button"
|
||||||
@@ -321,7 +321,7 @@ export function ForgotPasswordPage({ navigate }) {
|
|||||||
|
|
||||||
function AuthLayout({ children, description, title }) {
|
function AuthLayout({ children, description, title }) {
|
||||||
return (
|
return (
|
||||||
<main className="min-h-screen bg-[#0a1628] text-white">
|
<main className="auth-dark min-h-screen text-white">
|
||||||
<div className="grid min-h-screen lg:grid-cols-2">
|
<div className="grid min-h-screen lg:grid-cols-2">
|
||||||
<section className="relative hidden min-h-screen overflow-hidden lg:block">
|
<section className="relative hidden min-h-screen overflow-hidden lg:block">
|
||||||
<img alt="" className="absolute inset-0 h-full w-full object-cover" src={loginClinicImage} />
|
<img alt="" className="absolute inset-0 h-full w-full object-cover" src={loginClinicImage} />
|
||||||
@@ -330,7 +330,7 @@ function AuthLayout({ children, description, title }) {
|
|||||||
className="absolute inset-0"
|
className="absolute inset-0"
|
||||||
style={{
|
style={{
|
||||||
background:
|
background:
|
||||||
'linear-gradient(126.72deg, rgba(10, 22, 40, 0.9) 0%, rgba(10, 22, 40, 0.6) 50%, rgba(59, 130, 246, 0.3) 100%)',
|
'linear-gradient(126.72deg, rgba(10, 10, 10, 0.92) 0%, rgba(23, 23, 23, 0.72) 52%, rgba(59, 130, 246, 0.28) 100%)',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="relative flex min-h-screen flex-col justify-between px-[43px] py-[43px] xl:px-12 xl:py-12">
|
<div className="relative flex min-h-screen flex-col justify-between px-[43px] py-[43px] xl:px-12 xl:py-12">
|
||||||
@@ -351,7 +351,7 @@ function AuthLayout({ children, description, title }) {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="flex min-h-screen items-center justify-center px-6 py-12 sm:px-10 lg:px-[60px] xl:px-[68px]">
|
<section className="flex min-h-screen items-center justify-center px-6 py-12 sm:px-10 lg:px-[60px] xl:px-[68px]">
|
||||||
<div className="w-full max-w-[448px]">
|
<div className="w-full max-w-[448px] lg:translate-y-3">
|
||||||
<div className="mb-12 lg:hidden">
|
<div className="mb-12 lg:hidden">
|
||||||
<LoginLogo />
|
<LoginLogo />
|
||||||
</div>
|
</div>
|
||||||
@@ -366,11 +366,13 @@ function AuthLayout({ children, description, title }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const authInputClass =
|
const authInputClass =
|
||||||
'h-11 w-full rounded-[6px] border border-white/10 bg-white/[0.05] px-4 text-sm text-white outline-none transition placeholder:text-white/30 focus:border-[#3b82f6] focus:ring-2 focus:ring-[#3b82f6]/20'
|
'auth-input h-11 w-full rounded-[6px] border px-4 text-sm outline-none transition focus:border-[#3b82f6] focus:ring-2 focus:ring-[#3b82f6]/20'
|
||||||
|
const authPasswordInputClass =
|
||||||
|
'auth-input h-11 w-full rounded-[6px] border py-2 pl-4 pr-11 text-sm outline-none transition focus:border-[#3b82f6] focus:ring-2 focus:ring-[#3b82f6]/20'
|
||||||
|
|
||||||
function AuthField({ children, label }) {
|
function AuthField({ children, label }) {
|
||||||
return (
|
return (
|
||||||
<label className="grid gap-1.5 text-xs font-medium leading-4 text-white/50">
|
<label className="grid gap-1.5 text-xs font-medium leading-4 text-[#a3a3a3]">
|
||||||
<span>{label}</span>
|
<span>{label}</span>
|
||||||
{children}
|
{children}
|
||||||
</label>
|
</label>
|
||||||
@@ -380,7 +382,7 @@ function AuthField({ children, label }) {
|
|||||||
function LoginField({ action, children, htmlFor, label }) {
|
function LoginField({ action, children, htmlFor, label }) {
|
||||||
return (
|
return (
|
||||||
<div className="grid gap-1.5">
|
<div className="grid gap-1.5">
|
||||||
<span className="flex min-h-4 items-center justify-between gap-4 text-xs font-medium leading-4 text-white/50">
|
<span className="flex min-h-4 items-center justify-between gap-4 text-xs font-medium leading-4 text-[#a3a3a3]">
|
||||||
<label htmlFor={htmlFor}>{label}</label>
|
<label htmlFor={htmlFor}>{label}</label>
|
||||||
{action}
|
{action}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -23,16 +23,6 @@ export function HomePage({ navigate }) {
|
|||||||
Bem-vindo, Dr. Henrique. Aqui está o resumo da sua clínica hoje.
|
Bem-vindo, Dr. Henrique. Aqui está o resumo da sua clínica hoje.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap gap-3">
|
|
||||||
<button
|
|
||||||
className="h-9 rounded-sm border border-[#404040] bg-[#262626] px-4 text-sm font-medium text-[#e5e5e5] transition hover:bg-[#303030]"
|
|
||||||
onClick={() => navigate('/relatorios')}
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
Exportar
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="grid gap-6 lg:grid-cols-3">
|
<section className="grid gap-6 lg:grid-cols-3">
|
||||||
|
|||||||
@@ -542,14 +542,16 @@ function TemplateCard({ onEdit, onUse, template }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function MessageComposer({ allowedChannelKeys, draft, onChange, onClose, onSubmit, patients, templates }) {
|
function MessageComposer({ allowedChannelKeys, draft, onChange, onClose, onSubmit, patients, templates }) {
|
||||||
const [patientSearch, setPatientSearch] = useState('')
|
const [patientSearch, setPatientSearch] = useState(draft.patient || '')
|
||||||
const filteredPatients = useMemo(() => {
|
const filteredPatients = useMemo(() => {
|
||||||
const query = patientSearch.trim().toLowerCase()
|
const query = normalizeSearch(patientSearch)
|
||||||
if (!query) return patients
|
if (!query) return patients
|
||||||
|
|
||||||
return patients.filter((patient) =>
|
return patients.filter((patient) =>
|
||||||
[patient.name, patient.phone, patient.document]
|
[patient.name, patient.phone, patient.document]
|
||||||
.join(' ')
|
.join(' ')
|
||||||
|
.normalize('NFD')
|
||||||
|
.replace(/[\u0300-\u036f]/g, '')
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.includes(query),
|
.includes(query),
|
||||||
)
|
)
|
||||||
@@ -559,15 +561,14 @@ function MessageComposer({ allowedChannelKeys, draft, onChange, onClose, onSubmi
|
|||||||
onChange((current) => ({ ...current, [field]: value }))
|
onChange((current) => ({ ...current, [field]: value }))
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectPatient(patientId) {
|
function selectPatient(patient) {
|
||||||
const patient = patients.find((item) => item.id === patientId)
|
|
||||||
|
|
||||||
onChange((current) => ({
|
onChange((current) => ({
|
||||||
...current,
|
...current,
|
||||||
patientId,
|
patientId: patient?.id || '',
|
||||||
patient: patient?.name || '',
|
patient: patient?.name || '',
|
||||||
phone: patient?.phone || current.phone,
|
phone: patient?.phone || current.phone,
|
||||||
}))
|
}))
|
||||||
|
setPatientSearch(patient?.name || '')
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTemplate(templateName) {
|
function applyTemplate(templateName) {
|
||||||
@@ -589,31 +590,44 @@ function MessageComposer({ allowedChannelKeys, draft, onChange, onClose, onSubmi
|
|||||||
return (
|
return (
|
||||||
<ModalFrame onClose={onClose} title="Nova Mensagem">
|
<ModalFrame onClose={onClose} title="Nova Mensagem">
|
||||||
<form className="space-y-4" onSubmit={onSubmit}>
|
<form className="space-y-4" onSubmit={onSubmit}>
|
||||||
<div className="grid gap-4 md:grid-cols-2">
|
<DarkField label="Paciente">
|
||||||
<DarkField label="Paciente">
|
<div className="space-y-2">
|
||||||
<input
|
<input
|
||||||
className={inputClass}
|
className={inputClass}
|
||||||
onChange={(event) => setPatientSearch(event.target.value)}
|
onChange={(event) => {
|
||||||
|
setPatientSearch(event.target.value)
|
||||||
|
onChange((current) => ({ ...current, patientId: '', patient: '' }))
|
||||||
|
}}
|
||||||
placeholder="Digite nome, CPF ou telefone"
|
placeholder="Digite nome, CPF ou telefone"
|
||||||
type="search"
|
type="search"
|
||||||
value={patientSearch}
|
value={patientSearch}
|
||||||
/>
|
/>
|
||||||
</DarkField>
|
<div className="max-h-44 overflow-y-auto rounded-md border border-[#404040] bg-[#1f1f1f]">
|
||||||
<DarkField label="Selecionar paciente">
|
{filteredPatients.length ? (
|
||||||
<select
|
filteredPatients.slice(0, 8).map((patient) => {
|
||||||
className={inputClass}
|
const isSelected = String(patient.id) === String(draft.patientId)
|
||||||
onChange={(event) => selectPatient(event.target.value)}
|
return (
|
||||||
value={draft.patientId}
|
<button
|
||||||
>
|
className={`block w-full px-3 py-2 text-left text-sm transition ${
|
||||||
<option value="">Selecione um paciente</option>
|
isSelected ? 'bg-[#3b82f6]/20 text-[#e5e5e5]' : 'text-[#a3a3a3] hover:bg-[#303030] hover:text-[#e5e5e5]'
|
||||||
{filteredPatients.map((patient) => (
|
}`}
|
||||||
<option key={patient.id} value={patient.id}>
|
key={patient.id}
|
||||||
{patient.name}
|
onClick={() => selectPatient(patient)}
|
||||||
</option>
|
type="button"
|
||||||
))}
|
>
|
||||||
</select>
|
<span className="block font-semibold">{patient.name}</span>
|
||||||
</DarkField>
|
<span className="mt-0.5 block text-xs text-[#737373]">
|
||||||
</div>
|
{[patient.document, patient.phone].filter(Boolean).join(' | ') || 'Sem documento informado'}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<p className="px-3 py-2 text-xs text-[#737373]">Nenhum paciente encontrado.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DarkField>
|
||||||
|
|
||||||
<div className="grid gap-4 md:grid-cols-2">
|
<div className="grid gap-4 md:grid-cols-2">
|
||||||
<DarkField label="Paciente selecionado">
|
<DarkField label="Paciente selecionado">
|
||||||
@@ -749,6 +763,14 @@ function DarkField({ children, label }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeSearch(value) {
|
||||||
|
return String(value || '')
|
||||||
|
.normalize('NFD')
|
||||||
|
.replace(/[\u0300-\u036f]/g, '')
|
||||||
|
.trim()
|
||||||
|
.toLowerCase()
|
||||||
|
}
|
||||||
|
|
||||||
function CommIcon({ className = 'size-4', name }) {
|
function CommIcon({ className = 'size-4', name }) {
|
||||||
const common = {
|
const common = {
|
||||||
className,
|
className,
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ export function PatientsPage({ navigate, role }) {
|
|||||||
<td className="px-6 py-4 align-top text-[#a3a3a3]">{patient.state || missingValue('Estado')}</td>
|
<td className="px-6 py-4 align-top text-[#a3a3a3]">{patient.state || missingValue('Estado')}</td>
|
||||||
<td className="px-6 py-4 align-top whitespace-normal break-words text-[#a3a3a3]">{patient.lastVisit || 'Ainda não houve atendimento'}</td>
|
<td className="px-6 py-4 align-top whitespace-normal break-words text-[#a3a3a3]">{patient.lastVisit || 'Ainda não houve atendimento'}</td>
|
||||||
<td className="px-6 py-4 align-top whitespace-normal break-words text-[#a3a3a3]">{patient.nextVisit || 'Nenhum atendimento agendado'}</td>
|
<td className="px-6 py-4 align-top whitespace-normal break-words text-[#a3a3a3]">{patient.nextVisit || 'Nenhum atendimento agendado'}</td>
|
||||||
<td className="relative sticky right-0 bg-[#262626] px-6 py-4 text-right shadow-[-10px_0_12px_-12px_rgba(0,0,0,0.75)]">
|
<td className="sticky right-0 bg-[#262626] px-4 py-4 text-right shadow-[-10px_0_12px_-12px_rgba(0,0,0,0.75)]">
|
||||||
<button
|
<button
|
||||||
aria-label={`Ações de ${patient.name}`}
|
aria-label={`Ações de ${patient.name}`}
|
||||||
className="rounded p-1 text-[#a3a3a3] transition hover:bg-[#333333] hover:text-[#e5e5e5]"
|
className="rounded p-1 text-[#a3a3a3] transition hover:bg-[#333333] hover:text-[#e5e5e5]"
|
||||||
@@ -396,7 +396,7 @@ export function PatientsPage({ navigate, role }) {
|
|||||||
onClick={() => setOpenMenuId(null)}
|
onClick={() => setOpenMenuId(null)}
|
||||||
type="button"
|
type="button"
|
||||||
/>
|
/>
|
||||||
<div className="absolute right-4 top-12 z-50 w-48 rounded-md border border-[#404040] bg-[#262626] p-1 text-left shadow-lg">
|
<div className="fixed right-8 z-50 w-48 rounded-md border border-[#404040] bg-[#262626] p-1 text-left shadow-lg">
|
||||||
<ActionItem icon="file" label="Ver detalhes" onClick={() => openDetail(patient)} />
|
<ActionItem icon="file" label="Ver detalhes" onClick={() => openDetail(patient)} />
|
||||||
{canEditPatients ? <ActionItem icon="edit" label="Editar" onClick={() => openForm(patient.id)} /> : null}
|
{canEditPatients ? <ActionItem icon="edit" label="Editar" onClick={() => openForm(patient.id)} /> : null}
|
||||||
<ActionItem
|
<ActionItem
|
||||||
@@ -1504,7 +1504,9 @@ function PatientIcon({ className = 'size-4', name }) {
|
|||||||
if (name === 'more') {
|
if (name === 'more') {
|
||||||
return (
|
return (
|
||||||
<svg {...common}>
|
<svg {...common}>
|
||||||
<path d="M12 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM19 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM5 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" />
|
<circle cx="5" cy="12" fill="currentColor" r="1.5" stroke="none" />
|
||||||
|
<circle cx="12" cy="12" fill="currentColor" r="1.5" stroke="none" />
|
||||||
|
<circle cx="19" cy="12" fill="currentColor" r="1.5" stroke="none" />
|
||||||
</svg>
|
</svg>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
import { useRef, useState, useEffect } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
|
|
||||||
import { FeatureCallout } from '../components/FeatureState.jsx'
|
import { FeatureCallout } from '../components/FeatureState.jsx'
|
||||||
import { featurePanelClass } from '../components/featureStateStyles.js'
|
import { featurePanelClass } from '../components/featureStateStyles.js'
|
||||||
import { profileRepository } from '../repositories/profileRepository.js'
|
import { normalizeRole } from '../config/permissions.js'
|
||||||
import { authRepository } from '../repositories/authRepository.js'
|
import { authRepository } from '../repositories/authRepository.js'
|
||||||
|
import { profileRepository } from '../repositories/profileRepository.js'
|
||||||
|
|
||||||
const cardClass = 'rounded-2xl border border-[#404040] bg-[#262626] shadow-sm'
|
const cardClass = 'rounded-2xl border border-[#404040] bg-[#262626] shadow-sm'
|
||||||
const inputClass =
|
const inputClass =
|
||||||
'h-10 rounded-sm border border-[#404040] bg-[#171717] px-3 text-sm text-[#e5e5e5] outline-none transition placeholder:text-[#a3a3a3] focus:border-[#3b82f6] focus:ring-2 focus:ring-[#3b82f6]/20'
|
'h-10 rounded-sm border border-[#404040] bg-[#171717] px-3 text-sm text-[#e5e5e5] outline-none transition placeholder:text-[#a3a3a3] focus:border-[#3b82f6] focus:ring-2 focus:ring-[#3b82f6]/20'
|
||||||
|
const readOnlyInputClass =
|
||||||
|
'h-10 rounded-sm border border-[#404040] bg-[#1f1f1f] px-3 text-sm text-[#a3a3a3] outline-none'
|
||||||
|
|
||||||
export function ProfilePage({ navigate }) {
|
export function ProfilePage({ navigate }) {
|
||||||
const [saved, setSaved] = useState(false)
|
const [saved, setSaved] = useState(false)
|
||||||
@@ -18,10 +21,13 @@ export function ProfilePage({ navigate }) {
|
|||||||
const fileInputRef = useRef(null)
|
const fileInputRef = useRef(null)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
profileRepository.getCurrentUserProfile().then(data => {
|
profileRepository
|
||||||
setProfile(data)
|
.getCurrentUserProfile()
|
||||||
setLoading(false)
|
.then((data) => {
|
||||||
}).catch(() => setLoading(false))
|
setProfile(data)
|
||||||
|
setLoading(false)
|
||||||
|
})
|
||||||
|
.catch(() => setLoading(false))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
function update(field, value) {
|
function update(field, value) {
|
||||||
@@ -56,31 +62,33 @@ export function ProfilePage({ navigate }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <div className="text-center pt-20 text-[#a3a3a3]">Localizando dados do paciente...</div>
|
return <div className="pt-20 text-center text-[#a3a3a3]">Localizando dados do perfil...</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const normalizedRole = normalizeRole(profile.role)
|
||||||
|
const canEditProfile = !['medico', 'secretaria'].includes(normalizedRole)
|
||||||
|
const currentInputClass = canEditProfile ? inputClass : readOnlyInputClass
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto max-w-6xl space-y-6">
|
<div className="mx-auto max-w-6xl space-y-6">
|
||||||
<FeatureCallout
|
{canEditProfile ? (
|
||||||
description="Carregar perfil, avatar e logout usam integração. O botão de salvar preferências desta tela ainda grava só localmente."
|
<FeatureCallout
|
||||||
status="partial"
|
description="Carregar perfil, avatar e logout usam integração. O botão de salvar preferências desta tela ainda grava só localmente."
|
||||||
title="Perfil com persistência parcial"
|
status="partial"
|
||||||
/>
|
title="Perfil com persistência parcial"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<h1 className="text-2xl font-bold tracking-tight text-[#f5f5f5]">Perfil</h1>
|
<h1 className="text-2xl font-bold tracking-tight text-[#f5f5f5]">Perfil</h1>
|
||||||
<p className="mt-1 text-sm text-[#b8b8b8]">Dados locais do usuário logado e preferências básicas do shell.</p>
|
<p className="mt-1 text-sm text-[#b8b8b8]">Dados do usuário logado e preferências básicas do shell.</p>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div className="grid gap-6 lg:grid-cols-[1fr_360px]">
|
<div className="grid gap-6 lg:grid-cols-[1fr_360px]">
|
||||||
<section className={`${cardClass} ${featurePanelClass('partial')} p-6`}>
|
<section className={`${cardClass} ${featurePanelClass(canEditProfile ? 'partial' : 'live')} p-6`}>
|
||||||
<div className="mb-6 flex items-center gap-4">
|
<div className="mb-6 flex items-center gap-4">
|
||||||
{profile.avatarUrl ? (
|
{profile.avatarUrl ? (
|
||||||
<img
|
<img alt="" className="size-16 rounded-full border border-[#3b82f6]/30 object-cover" src={profile.avatarUrl} />
|
||||||
alt=""
|
|
||||||
className="size-16 rounded-full border border-[#3b82f6]/30 object-cover"
|
|
||||||
src={profile.avatarUrl}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<div className="grid size-16 place-items-center rounded-full border border-[#3b82f6]/30 bg-[#3b82f6]/10 text-xl font-bold text-[#3b82f6]">
|
<div className="grid size-16 place-items-center rounded-full border border-[#3b82f6]/30 bg-[#3b82f6]/10 text-xl font-bold text-[#3b82f6]">
|
||||||
{initials(profile.name)}
|
{initials(profile.name)}
|
||||||
@@ -89,21 +97,25 @@ export function ProfilePage({ navigate }) {
|
|||||||
<div>
|
<div>
|
||||||
<h2 className="text-lg font-bold text-[#f5f5f5]">{profile.name}</h2>
|
<h2 className="text-lg font-bold text-[#f5f5f5]">{profile.name}</h2>
|
||||||
<p className="mt-1 text-sm text-[#a3a3a3]">{profile.role}</p>
|
<p className="mt-1 text-sm text-[#a3a3a3]">{profile.role}</p>
|
||||||
<button
|
{canEditProfile ? (
|
||||||
className="mt-1 text-xs font-semibold text-[#3b82f6] disabled:opacity-60"
|
<>
|
||||||
disabled={uploadingAvatar}
|
<button
|
||||||
onClick={() => fileInputRef.current?.click()}
|
className="mt-1 text-xs font-semibold text-[#3b82f6] disabled:opacity-60"
|
||||||
type="button"
|
disabled={uploadingAvatar}
|
||||||
>
|
onClick={() => fileInputRef.current?.click()}
|
||||||
{uploadingAvatar ? 'Enviando...' : 'Alterar foto'}
|
type="button"
|
||||||
</button>
|
>
|
||||||
<input
|
{uploadingAvatar ? 'Enviando...' : 'Alterar foto'}
|
||||||
accept="image/*"
|
</button>
|
||||||
className="hidden"
|
<input
|
||||||
onChange={handleAvatarChange}
|
accept="image/*"
|
||||||
ref={fileInputRef}
|
className="hidden"
|
||||||
type="file"
|
onChange={handleAvatarChange}
|
||||||
/>
|
ref={fileInputRef}
|
||||||
|
type="file"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
{avatarError ? <p className="mt-1 text-xs font-semibold text-red-400">{avatarError}</p> : null}
|
{avatarError ? <p className="mt-1 text-xs font-semibold text-red-400">{avatarError}</p> : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -112,38 +124,44 @@ export function ProfilePage({ navigate }) {
|
|||||||
className="grid gap-4"
|
className="grid gap-4"
|
||||||
onSubmit={(event) => {
|
onSubmit={(event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
setSaved(true)
|
if (canEditProfile) setSaved(true)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="grid gap-4 md:grid-cols-2">
|
<div className="grid gap-4 md:grid-cols-2">
|
||||||
<Field label="Nome">
|
<Field label="Nome">
|
||||||
<input className={inputClass} onChange={(event) => update('name', event.target.value)} value={profile.name} />
|
<input className={currentInputClass} onChange={(event) => update('name', event.target.value)} readOnly={!canEditProfile} value={profile.name} />
|
||||||
</Field>
|
</Field>
|
||||||
<Field label="Cargo">
|
<Field label="Cargo">
|
||||||
<input className={inputClass} onChange={(event) => update('role', event.target.value)} value={profile.role} />
|
<input className={currentInputClass} onChange={(event) => update('role', event.target.value)} readOnly={!canEditProfile} value={profile.role} />
|
||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid gap-4 md:grid-cols-2">
|
<div className="grid gap-4 md:grid-cols-2">
|
||||||
<Field label="E-mail">
|
<Field label="E-mail">
|
||||||
<input className={inputClass} onChange={(event) => update('email', event.target.value)} type="email" value={profile.email} />
|
<input className={currentInputClass} onChange={(event) => update('email', event.target.value)} readOnly={!canEditProfile} type="email" value={profile.email} />
|
||||||
</Field>
|
</Field>
|
||||||
<Field label="Telefone">
|
<Field label="Telefone">
|
||||||
<input className={inputClass} onChange={(event) => update('phone', event.target.value)} value={profile.phone} />
|
<input className={currentInputClass} onChange={(event) => update('phone', event.target.value)} readOnly={!canEditProfile} value={profile.phone} />
|
||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
<Field label="Unidade padrão">
|
<Field label="Unidade padrão">
|
||||||
<select className={inputClass} onChange={(event) => update('unit', event.target.value)} value={profile.unit}>
|
{canEditProfile ? (
|
||||||
<option>Clínica Boa Vista</option>
|
<select className={inputClass} onChange={(event) => update('unit', event.target.value)} value={profile.unit}>
|
||||||
<option>Unidade Centro</option>
|
<option>Clínica Boa Vista</option>
|
||||||
<option>Unidade Sul</option>
|
<option>Unidade Centro</option>
|
||||||
</select>
|
<option>Unidade Sul</option>
|
||||||
|
</select>
|
||||||
|
) : (
|
||||||
|
<input className={readOnlyInputClass} readOnly value={profile.unit} />
|
||||||
|
)}
|
||||||
</Field>
|
</Field>
|
||||||
<div className="flex flex-wrap items-center gap-3">
|
{canEditProfile ? (
|
||||||
<button className="h-10 rounded-sm bg-[#3b82f6] px-4 text-sm font-semibold text-white" type="submit">
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
Salvar alterações
|
<button className="h-10 rounded-sm bg-[#3b82f6] px-4 text-sm font-semibold text-white" type="submit">
|
||||||
</button>
|
Salvar alterações
|
||||||
{saved ? <span className="rounded bg-amber-500/20 px-2.5 py-1 text-xs font-bold text-amber-300">Preferências salvas localmente</span> : null}
|
</button>
|
||||||
</div>
|
{saved ? <span className="rounded bg-amber-500/20 px-2.5 py-1 text-xs font-bold text-amber-300">Preferências salvas localmente</span> : null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -156,8 +174,9 @@ export function ProfilePage({ navigate }) {
|
|||||||
</dl>
|
</dl>
|
||||||
<div className="mt-8 border-t border-[#404040] pt-6">
|
<div className="mt-8 border-t border-[#404040] pt-6">
|
||||||
<button
|
<button
|
||||||
className="w-full h-10 rounded-sm border border-red-500/30 text-red-500 font-semibold text-sm transition hover:bg-red-500/10"
|
className="h-10 w-full rounded-sm border border-red-500/30 text-sm font-semibold text-red-500 transition hover:bg-red-500/10"
|
||||||
onClick={handleLogout}
|
onClick={handleLogout}
|
||||||
|
type="button"
|
||||||
>
|
>
|
||||||
Sair da conta
|
Sair da conta
|
||||||
</button>
|
</button>
|
||||||
@@ -181,7 +200,7 @@ function Info({ label, value }) {
|
|||||||
return (
|
return (
|
||||||
<div className="rounded-xl border border-[#404040] bg-[#171717] p-4">
|
<div className="rounded-xl border border-[#404040] bg-[#171717] p-4">
|
||||||
<dt className="font-semibold text-[#a3a3a3]">{label}</dt>
|
<dt className="font-semibold text-[#a3a3a3]">{label}</dt>
|
||||||
<dd className="mt-1 text-[#e5e5e5]">{value}</dd>
|
<dd className="mt-1 text-[#e5e5e5]">{value || '-'}</dd>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ const emptyEditor = {
|
|||||||
conclusion: '',
|
conclusion: '',
|
||||||
contentHtml: '',
|
contentHtml: '',
|
||||||
contentJson: undefined,
|
contentJson: undefined,
|
||||||
hideDate: false,
|
|
||||||
hideSignature: false,
|
|
||||||
dueAt: '',
|
dueAt: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,15 +251,16 @@ export function ReportsPage({ role }) {
|
|||||||
conclusion: report.conclusion,
|
conclusion: report.conclusion,
|
||||||
contentHtml: report.contentHtml,
|
contentHtml: report.contentHtml,
|
||||||
contentJson: report.contentJson,
|
contentJson: report.contentJson,
|
||||||
hideDate: report.hideDate,
|
|
||||||
hideSignature: report.hideSignature,
|
|
||||||
dueAt: toDateTimeLocal(report.dueAt),
|
dueAt: toDateTimeLocal(report.dueAt),
|
||||||
})
|
})
|
||||||
setEditorOpen(true)
|
setEditorOpen(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSave() {
|
async function handleSave() {
|
||||||
if (!editor.patientId) return
|
if (!isReportEditorValid(editor)) {
|
||||||
|
alert('Preencha todos os campos obrigatórios antes de salvar o relatório.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
|
|
||||||
@@ -276,8 +275,6 @@ export function ReportsPage({ role }) {
|
|||||||
conclusion: editor.conclusion,
|
conclusion: editor.conclusion,
|
||||||
contentHtml: editor.contentHtml,
|
contentHtml: editor.contentHtml,
|
||||||
contentJson: editor.contentJson,
|
contentJson: editor.contentJson,
|
||||||
hideDate: editor.hideDate,
|
|
||||||
hideSignature: editor.hideSignature,
|
|
||||||
dueAt: editor.dueAt ? new Date(editor.dueAt).toISOString() : '',
|
dueAt: editor.dueAt ? new Date(editor.dueAt).toISOString() : '',
|
||||||
createdBy: editor.id ? undefined : viewerProfile?.id || currentProfessional?.userId || currentProfessional?.id || undefined,
|
createdBy: editor.id ? undefined : viewerProfile?.id || currentProfessional?.userId || currentProfessional?.id || undefined,
|
||||||
updatedBy: viewerProfile?.id || currentProfessional?.userId || currentProfessional?.id || undefined,
|
updatedBy: viewerProfile?.id || currentProfessional?.userId || currentProfessional?.id || undefined,
|
||||||
@@ -525,7 +522,7 @@ function ReportRow({ onEdit, onView, report }) {
|
|||||||
|
|
||||||
function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions, professionalOptions, saving }) {
|
function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions, professionalOptions, saving }) {
|
||||||
const [requesterSearch, setRequesterSearch] = useState(editor.requestedBy || '')
|
const [requesterSearch, setRequesterSearch] = useState(editor.requestedBy || '')
|
||||||
const isValid = Boolean(editor.patientId)
|
const isValid = isReportEditorValid(editor)
|
||||||
const filteredRequesterOptions = professionalOptions
|
const filteredRequesterOptions = professionalOptions
|
||||||
.filter((professional) => normalizeSearch(professional.name).includes(normalizeSearch(requesterSearch)))
|
.filter((professional) => normalizeSearch(professional.name).includes(normalizeSearch(requesterSearch)))
|
||||||
.slice(0, 6)
|
.slice(0, 6)
|
||||||
@@ -563,7 +560,7 @@ function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions,
|
|||||||
</select>
|
</select>
|
||||||
</DarkField>
|
</DarkField>
|
||||||
|
|
||||||
<DarkField label="Status">
|
<DarkField label="Status *">
|
||||||
<select className={inputClass} onChange={(event) => updateField('status', event.target.value)} value={editor.status}>
|
<select className={inputClass} onChange={(event) => updateField('status', event.target.value)} value={editor.status}>
|
||||||
<option value="draft">Rascunho</option>
|
<option value="draft">Rascunho</option>
|
||||||
<option value="finalized">Finalizado</option>
|
<option value="finalized">Finalizado</option>
|
||||||
@@ -572,7 +569,7 @@ function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions,
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-4 md:grid-cols-2">
|
<div className="grid gap-4 md:grid-cols-2">
|
||||||
<DarkField label="Exame">
|
<DarkField label="Exame *">
|
||||||
<input
|
<input
|
||||||
className={inputClass}
|
className={inputClass}
|
||||||
onChange={(event) => updateField('exam', event.target.value)}
|
onChange={(event) => updateField('exam', event.target.value)}
|
||||||
@@ -581,7 +578,7 @@ function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions,
|
|||||||
/>
|
/>
|
||||||
</DarkField>
|
</DarkField>
|
||||||
|
|
||||||
<DarkField label="Solicitante">
|
<DarkField label="Solicitante *">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<input
|
<input
|
||||||
className={inputClass}
|
className={inputClass}
|
||||||
@@ -620,7 +617,7 @@ function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions,
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-4 md:grid-cols-2">
|
<div className="grid gap-4 md:grid-cols-2">
|
||||||
<DarkField label="CID-10">
|
<DarkField label="CID-10 *">
|
||||||
<input
|
<input
|
||||||
className={inputClass}
|
className={inputClass}
|
||||||
onChange={(event) => updateField('cidCode', event.target.value)}
|
onChange={(event) => updateField('cidCode', event.target.value)}
|
||||||
@@ -629,7 +626,7 @@ function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions,
|
|||||||
/>
|
/>
|
||||||
</DarkField>
|
</DarkField>
|
||||||
|
|
||||||
<DarkField label="Prazo">
|
<DarkField label="Prazo *">
|
||||||
<input
|
<input
|
||||||
className={`${inputClass} [color-scheme:dark]`}
|
className={`${inputClass} [color-scheme:dark]`}
|
||||||
onChange={(event) => updateField('dueAt', event.target.value)}
|
onChange={(event) => updateField('dueAt', event.target.value)}
|
||||||
@@ -639,7 +636,7 @@ function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions,
|
|||||||
</DarkField>
|
</DarkField>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DarkField label="Diagnóstico">
|
<DarkField label="Diagnóstico *">
|
||||||
<textarea
|
<textarea
|
||||||
className={textareaClass}
|
className={textareaClass}
|
||||||
onChange={(event) => updateField('diagnosis', event.target.value)}
|
onChange={(event) => updateField('diagnosis', event.target.value)}
|
||||||
@@ -648,7 +645,7 @@ function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions,
|
|||||||
/>
|
/>
|
||||||
</DarkField>
|
</DarkField>
|
||||||
|
|
||||||
<DarkField label="Conclusão">
|
<DarkField label="Conclusão *">
|
||||||
<textarea
|
<textarea
|
||||||
className={textareaClass}
|
className={textareaClass}
|
||||||
onChange={(event) => updateField('conclusion', event.target.value)}
|
onChange={(event) => updateField('conclusion', event.target.value)}
|
||||||
@@ -664,28 +661,6 @@ function ReportEditorModal({ editor, onChange, onClose, onSave, patientOptions,
|
|||||||
value={editor.contentHtml}
|
value={editor.contentHtml}
|
||||||
/>
|
/>
|
||||||
</DarkField>
|
</DarkField>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-6">
|
|
||||||
<label className="flex cursor-pointer items-center gap-2 text-sm text-[#e5e5e5]">
|
|
||||||
<input
|
|
||||||
checked={editor.hideDate}
|
|
||||||
className="size-4 accent-[#3b82f6]"
|
|
||||||
onChange={(event) => updateField('hideDate', event.target.checked)}
|
|
||||||
type="checkbox"
|
|
||||||
/>
|
|
||||||
Ocultar data
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label className="flex cursor-pointer items-center gap-2 text-sm text-[#e5e5e5]">
|
|
||||||
<input
|
|
||||||
checked={editor.hideSignature}
|
|
||||||
className="size-4 accent-[#3b82f6]"
|
|
||||||
onChange={(event) => updateField('hideSignature', event.target.checked)}
|
|
||||||
type="checkbox"
|
|
||||||
/>
|
|
||||||
Ocultar assinatura
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -760,16 +735,6 @@ function ReportViewModal({ onClose, report }) {
|
|||||||
<DetailBlock label="Diagnóstico" value={report.diagnosis || '-'} />
|
<DetailBlock label="Diagnóstico" value={report.diagnosis || '-'} />
|
||||||
<DetailBlock label="Conclusão" value={report.conclusion || '-'} />
|
<DetailBlock label="Conclusão" value={report.conclusion || '-'} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-4 flex flex-wrap gap-3 text-xs text-[#a3a3a3]">
|
|
||||||
<span className="rounded-full border border-[#404040] px-3 py-1">
|
|
||||||
{report.hideDate ? 'Data oculta' : 'Data visivel'}
|
|
||||||
</span>
|
|
||||||
<span className="rounded-full border border-[#404040] px-3 py-1">
|
|
||||||
{report.hideSignature ? 'Assinatura oculta' : 'Assinatura visivel'}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-6 rounded-xl border border-[#404040] bg-[#1a1a1a] p-5">
|
<div className="mt-6 rounded-xl border border-[#404040] bg-[#1a1a1a] p-5">
|
||||||
<p className="mb-3 text-xs font-semibold uppercase tracking-wide text-[#a3a3a3]">Complemento</p>
|
<p className="mb-3 text-xs font-semibold uppercase tracking-wide text-[#a3a3a3]">Complemento</p>
|
||||||
{report.contentHtml ? (
|
{report.contentHtml ? (
|
||||||
@@ -884,6 +849,19 @@ function uniqueValues(values) {
|
|||||||
return [...new Set(values.map((value) => String(value || '').trim()).filter(Boolean))]
|
return [...new Set(values.map((value) => String(value || '').trim()).filter(Boolean))]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isReportEditorValid(editor) {
|
||||||
|
return [
|
||||||
|
editor.patientId,
|
||||||
|
editor.status,
|
||||||
|
editor.exam,
|
||||||
|
editor.requestedBy,
|
||||||
|
editor.cidCode,
|
||||||
|
editor.diagnosis,
|
||||||
|
editor.conclusion,
|
||||||
|
editor.dueAt,
|
||||||
|
].every((value) => String(value || '').trim())
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeSearch(value) {
|
function normalizeSearch(value) {
|
||||||
return String(value || '')
|
return String(value || '')
|
||||||
.normalize('NFD')
|
.normalize('NFD')
|
||||||
|
|||||||
@@ -54,10 +54,7 @@ export function SettingsPage() {
|
|||||||
|
|
||||||
<section className={`${cardClass} min-w-0 flex-1 p-6 lg:p-8`}>
|
<section className={`${cardClass} min-w-0 flex-1 p-6 lg:p-8`}>
|
||||||
{activeSection === 'aparencia' ? <AppearanceSection /> : null}
|
{activeSection === 'aparencia' ? <AppearanceSection /> : null}
|
||||||
{activeSection === 'notificacoes' ? <NotificationsSection /> : null}
|
|
||||||
{activeSection === 'privacidade' ? <PrivacySection /> : null}
|
{activeSection === 'privacidade' ? <PrivacySection /> : null}
|
||||||
{activeSection === 'conta' ? <AccountSection /> : null}
|
|
||||||
{activeSection === 'integracoes' ? <IntegrationsSection /> : null}
|
|
||||||
{activeSection === 'dados' ? <DataSection /> : null}
|
{activeSection === 'dados' ? <DataSection /> : null}
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
@@ -76,29 +73,33 @@ function AppearanceSection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SectionFrame description="Personalize a interface do MediConnect." title="Aparência">
|
<SectionFrame description="Personalize a interface do MediConnect." title="Aparência e Acessibilidade">
|
||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
<p className="mb-4 text-sm font-semibold text-[#e5e5e5]">Tema da Interface</p>
|
<p className="mb-4 text-sm font-semibold text-[#e5e5e5]">Tema da Interface</p>
|
||||||
<div className="grid max-w-xl gap-4 sm:grid-cols-2">
|
<div className="grid max-w-xl gap-4 sm:grid-cols-2">
|
||||||
{[
|
{[
|
||||||
{ id: 'dark', label: 'Escuro', preview: 'bg-[#0a1628]' },
|
{ id: 'dark', label: 'Escuro', preview: 'bg-[#0a0a0a]' },
|
||||||
{ id: 'light', label: 'Claro', preview: 'bg-[#f4f7fb]' },
|
{ id: 'light', label: 'Claro', preview: 'bg-[#f4f7fb]' },
|
||||||
].map((item) => (
|
].map((item) => (
|
||||||
<button
|
<button
|
||||||
className={`rounded-2xl border-2 p-4 text-left transition ${
|
className={`rounded-2xl border-2 p-4 text-left transition ${
|
||||||
theme === item.id ? 'border-[#3b82f6] bg-[#3b82f6]/5 shadow-md shadow-[#3b82f6]/20' : 'border-[#404040] bg-[#262626] hover:border-[#3b82f6]/40'
|
theme === item.id
|
||||||
|
? item.id === 'dark'
|
||||||
|
? 'border-[#737373] bg-[#171717] shadow-md shadow-black/30'
|
||||||
|
: 'border-[#3b82f6] bg-[#3b82f6]/5 shadow-md shadow-[#3b82f6]/20'
|
||||||
|
: 'border-[#404040] bg-[#262626] hover:border-[#737373]'
|
||||||
}`}
|
}`}
|
||||||
key={item.id}
|
key={item.id}
|
||||||
onClick={() => handleThemeChange(item.id)}
|
onClick={() => handleThemeChange(item.id)}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<span className={`mb-3 flex h-20 flex-col gap-1.5 overflow-hidden rounded-xl border border-[#404040] p-2 ${item.preview}`}>
|
<span className={`settings-theme-preview ${item.id === 'dark' ? 'settings-theme-preview-dark' : 'settings-theme-preview-light'} mb-3 flex h-20 flex-col gap-1.5 overflow-hidden rounded-xl border border-[#404040] p-2 ${item.preview}`}>
|
||||||
<span className={`h-2.5 rounded ${item.id === 'dark' ? 'bg-[#1a3050]' : 'bg-white'}`} />
|
<span className={`settings-theme-preview-bar h-2.5 rounded ${item.id === 'dark' ? 'bg-[#262626]' : 'bg-white'}`} />
|
||||||
<span className="flex flex-1 gap-1">
|
<span className="flex flex-1 gap-1">
|
||||||
<span className={`w-8 rounded ${item.id === 'dark' ? 'bg-[#0f1f36]' : 'bg-white'}`} />
|
<span className={`settings-theme-preview-side w-8 rounded ${item.id === 'dark' ? 'bg-[#171717]' : 'bg-white'}`} />
|
||||||
<span className="flex flex-1 flex-col justify-center gap-1">
|
<span className="flex flex-1 flex-col justify-center gap-1">
|
||||||
<span className={`h-1.5 w-3/4 rounded-full ${item.id === 'dark' ? 'bg-[#1e3a5f]' : 'bg-[#dde8f7]'}`} />
|
<span className={`settings-theme-preview-line h-1.5 w-3/4 rounded-full ${item.id === 'dark' ? 'bg-[#525252]' : 'bg-[#dde8f7]'}`} />
|
||||||
<span className={`h-1.5 w-1/2 rounded-full ${item.id === 'dark' ? 'bg-[#1e3a5f]' : 'bg-[#dde8f7]'}`} />
|
<span className={`settings-theme-preview-line h-1.5 w-1/2 rounded-full ${item.id === 'dark' ? 'bg-[#404040]' : 'bg-[#dde8f7]'}`} />
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { apiConfig, getAuthenticatedHeaders } from '../config/api.js'
|
import { apiConfig, getAuthenticatedHeaders } from '../config/api.js'
|
||||||
import { appointmentMapper } from '../mappers/appointmentMapper.js'
|
import { appointmentMapper } from '../mappers/appointmentMapper.js'
|
||||||
|
import { getResponseError, normalizeItem } from './repositoryUtils.js'
|
||||||
|
|
||||||
export const appointmentRepository = {
|
export const appointmentRepository = {
|
||||||
async getAll({ doctorId } = {}) {
|
async getAll({ doctorId } = {}) {
|
||||||
@@ -9,7 +10,7 @@ export const appointmentRepository = {
|
|||||||
headers: getAuthenticatedHeaders()
|
headers: getAuthenticatedHeaders()
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!response.ok) throw new Error('Erro ao buscar agendamentos.')
|
if (!response.ok) throw new Error(await getResponseError(response, 'Erro ao buscar agendamentos.'))
|
||||||
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
return (Array.isArray(data) ? data : []).map(appointmentMapper.toUi)
|
return (Array.isArray(data) ? data : []).map(appointmentMapper.toUi)
|
||||||
@@ -22,10 +23,26 @@ export const appointmentRepository = {
|
|||||||
body: JSON.stringify(appointmentMapper.toApi(uiData, 'supabase')),
|
body: JSON.stringify(appointmentMapper.toApi(uiData, 'supabase')),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!response.ok) throw new Error('Falha ao criar o agendamento.')
|
if (!response.ok) throw new Error(await getResponseError(response, 'Falha ao criar o agendamento.'))
|
||||||
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
const item = Array.isArray(data) ? data[0] : data
|
return appointmentMapper.toUi(normalizeItem(data))
|
||||||
return appointmentMapper.toUi(item)
|
},
|
||||||
}
|
|
||||||
|
async update(id, uiData) {
|
||||||
|
const response = await fetch(`${apiConfig.restUrl}/appointments?id=eq.${encodeURIComponent(id)}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: getAuthenticatedHeaders({ Prefer: 'return=representation' }),
|
||||||
|
body: JSON.stringify(appointmentMapper.toApi(uiData, 'supabase')),
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(await getResponseError(response, 'Falha ao atualizar o agendamento.'))
|
||||||
|
|
||||||
|
const data = await response.json()
|
||||||
|
return appointmentMapper.toUi(normalizeItem(data))
|
||||||
|
},
|
||||||
|
|
||||||
|
async cancel(id, uiData) {
|
||||||
|
return this.update(id, { ...uiData, status: 'Cancelada' })
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,18 @@ export const settingsRepository = {
|
|||||||
getIntegrations() {
|
getIntegrations() {
|
||||||
return [
|
return [
|
||||||
['WhatsApp Business', 'Envio automático de lembretes e confirmações', true, 'bg-[#3b82f6]'],
|
['WhatsApp Business', 'Envio automático de lembretes e confirmações', true, 'bg-[#3b82f6]'],
|
||||||
['Google Calendar', 'Sincronizacao bidirecional de agenda', false, 'bg-blue-500'],
|
['Google Calendar', 'Sincronização bidirecional de agenda', false, 'bg-blue-500'],
|
||||||
['Stripe / PagSeguro', 'Pagamentos online e links de cobranca', true, 'bg-violet-500'],
|
['Stripe / PagSeguro', 'Pagamentos online e links de cobrança', true, 'bg-violet-500'],
|
||||||
['CFM - Conselho Federal de Medicina', 'Validacao automatica de CRM', false, 'bg-amber-500'],
|
['CFM - Conselho Federal de Medicina', 'Validação automática de CRM', false, 'bg-amber-500'],
|
||||||
['ANS - Planos de Saude', 'Integracao com tabela TUSS e convenios', false, 'bg-rose-500'],
|
['ANS - Planos de Saúde', 'Integração com tabela TUSS e convênios', false, 'bg-rose-500'],
|
||||||
['API de IA Preditiva', 'Score de absenteísmo e predição de faltas', true, 'bg-[#3b82f6]'],
|
['API de IA Preditiva', 'Score de absenteísmo e predição de faltas', true, 'bg-[#3b82f6]'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
getSections() {
|
getSections() {
|
||||||
return [
|
return [
|
||||||
{ id: 'aparencia', label: 'Aparência', description: 'Tema, cores e exibição', icon: 'palette' },
|
{ id: 'aparencia', label: 'Aparência e Acessibilidade', description: 'Tema, cores e exibição', icon: 'palette' },
|
||||||
{ id: 'notificacoes', label: 'Notificações', description: 'Alertas e lembretes', icon: 'bell' },
|
|
||||||
{ id: 'privacidade', label: 'Privacidade & LGPD', description: 'Dados e conformidade', icon: 'shield' },
|
{ id: 'privacidade', label: 'Privacidade & LGPD', description: 'Dados e conformidade', icon: 'shield' },
|
||||||
{ id: 'conta', label: 'Conta & Perfil', description: 'Informações pessoais', icon: 'user' },
|
|
||||||
{ id: 'integracoes', label: 'Integrações', description: 'APIs e sistemas externos', icon: 'globe' },
|
|
||||||
{ id: 'dados', label: 'Dados & Backup', description: 'Exportação e backup', icon: 'database' },
|
{ id: 'dados', label: 'Dados & Backup', description: 'Exportação e backup', icon: 'database' },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user