forked from RiseUP/riseup-squad20
fix-appoiments-confirm
This commit is contained in:
parent
5047ab75dc
commit
8fee2cf6e1
@ -74,6 +74,20 @@ const capitalize = (s: string) => {
|
|||||||
return s.charAt(0).toUpperCase() + s.slice(1);
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const translateStatus = (status: string) => {
|
||||||
|
const statusMap: { [key: string]: string } = {
|
||||||
|
'requested': 'Solicitado',
|
||||||
|
'confirmed': 'Confirmado',
|
||||||
|
'checked_in': 'Check-in',
|
||||||
|
'in_progress': 'Em Andamento',
|
||||||
|
'completed': 'Concluído',
|
||||||
|
'cancelled': 'Cancelado',
|
||||||
|
'no_show': 'Não Compareceu',
|
||||||
|
'pending': 'Pendente',
|
||||||
|
};
|
||||||
|
return statusMap[status?.toLowerCase()] || capitalize(status || '');
|
||||||
|
};
|
||||||
|
|
||||||
export default function ConsultasPage() {
|
export default function ConsultasPage() {
|
||||||
const [appointments, setAppointments] = useState<any[]>([]);
|
const [appointments, setAppointments] = useState<any[]>([]);
|
||||||
const [originalAppointments, setOriginalAppointments] = useState<any[]>([]);
|
const [originalAppointments, setOriginalAppointments] = useState<any[]>([]);
|
||||||
@ -197,7 +211,7 @@ export default function ConsultasPage() {
|
|||||||
const payload: any = {
|
const payload: any = {
|
||||||
scheduled_at,
|
scheduled_at,
|
||||||
duration_minutes,
|
duration_minutes,
|
||||||
status: formData.status || undefined,
|
status: 'confirmed',
|
||||||
notes: formData.notes ?? null,
|
notes: formData.notes ?? null,
|
||||||
chief_complaint: formData.chief_complaint ?? null,
|
chief_complaint: formData.chief_complaint ?? null,
|
||||||
patient_notes: formData.patient_notes ?? null,
|
patient_notes: formData.patient_notes ?? null,
|
||||||
@ -561,7 +575,7 @@ export default function ConsultasPage() {
|
|||||||
}
|
}
|
||||||
className={appointment.status === "confirmed" ? "bg-green-600" : ""}
|
className={appointment.status === "confirmed" ? "bg-green-600" : ""}
|
||||||
>
|
>
|
||||||
{capitalize(appointment.status)}
|
{translateStatus(appointment.status)}
|
||||||
</Badge>
|
</Badge>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="text-xs sm:text-sm">{formatDate(appointment.scheduled_at ?? appointment.time)}</TableCell>
|
<TableCell className="text-xs sm:text-sm">{formatDate(appointment.scheduled_at ?? appointment.time)}</TableCell>
|
||||||
@ -652,7 +666,7 @@ export default function ConsultasPage() {
|
|||||||
}
|
}
|
||||||
className={`text-[10px] sm:text-xs ${appointment.status === "confirmed" ? "bg-green-600" : ""}`}
|
className={`text-[10px] sm:text-xs ${appointment.status === "confirmed" ? "bg-green-600" : ""}`}
|
||||||
>
|
>
|
||||||
{capitalize(appointment.status)}
|
{translateStatus(appointment.status)}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-2">
|
<div className="col-span-2">
|
||||||
@ -771,7 +785,7 @@ export default function ConsultasPage() {
|
|||||||
}
|
}
|
||||||
className={viewingAppointment?.status === "confirmed" ? "bg-green-600" : ""}
|
className={viewingAppointment?.status === "confirmed" ? "bg-green-600" : ""}
|
||||||
>
|
>
|
||||||
{capitalize(viewingAppointment?.status || "")}
|
{translateStatus(viewingAppointment?.status || "")}
|
||||||
</Badge>
|
</Badge>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -812,7 +812,7 @@ export default function PacientePage() {
|
|||||||
<div className="flex items-start gap-3 sm:gap-4 min-w-0">
|
<div className="flex items-start gap-3 sm:gap-4 min-w-0">
|
||||||
<span
|
<span
|
||||||
className="mt-1 sm:mt-2 h-3 w-3 sm:h-4 sm:w-4 shrink-0 rounded-full shadow-sm"
|
className="mt-1 sm:mt-2 h-3 w-3 sm:h-4 sm:w-4 shrink-0 rounded-full shadow-sm"
|
||||||
style={{ backgroundColor: consulta.status === 'Confirmada' ? '#10b981' : consulta.status === 'Pendente' ? '#f59e0b' : '#ef4444' }}
|
style={{ backgroundColor: (consulta.status === 'Confirmada' || consulta.status === 'confirmed') ? '#10b981' : '#ef4444' }}
|
||||||
aria-hidden
|
aria-hidden
|
||||||
/>
|
/>
|
||||||
<div className="space-y-2 sm:space-y-3 min-w-0">
|
<div className="space-y-2 sm:space-y-3 min-w-0">
|
||||||
@ -837,10 +837,8 @@ export default function PacientePage() {
|
|||||||
{/* Status Badge */}
|
{/* Status Badge */}
|
||||||
<div className="flex items-center justify-start">
|
<div className="flex items-center justify-start">
|
||||||
<span className={`px-2 sm:px-3 md:px-4 py-1.5 sm:py-2 md:py-2.5 rounded-full text-xs font-bold text-white shadow-md transition-all ${
|
<span className={`px-2 sm:px-3 md:px-4 py-1.5 sm:py-2 md:py-2.5 rounded-full text-xs font-bold text-white shadow-md transition-all ${
|
||||||
consulta.status === 'Confirmada'
|
consulta.status === 'Confirmada' || consulta.status === 'confirmed'
|
||||||
? 'bg-linear-to-r from-emerald-500 to-emerald-600 shadow-emerald-500/20'
|
? 'bg-linear-to-r from-green-500 to-green-600 shadow-green-500/20'
|
||||||
: consulta.status === 'Pendente'
|
|
||||||
? 'bg-linear-to-r from-amber-500 to-amber-600 shadow-amber-500/20'
|
|
||||||
: 'bg-linear-to-r from-red-500 to-red-600 shadow-red-500/20'
|
: 'bg-linear-to-r from-red-500 to-red-600 shadow-red-500/20'
|
||||||
}`}>
|
}`}>
|
||||||
{statusLabel(consulta.status)}
|
{statusLabel(consulta.status)}
|
||||||
@ -858,7 +856,7 @@ export default function PacientePage() {
|
|||||||
Detalhes
|
Detalhes
|
||||||
</Button>
|
</Button>
|
||||||
{/* Reagendar removed by request */}
|
{/* Reagendar removed by request */}
|
||||||
{consulta.status !== 'Cancelada' && (
|
{consulta.status !== 'Cancelada' && consulta.status !== 'cancelled' && (
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
@ -1178,15 +1178,8 @@ export function CalendarRegistrationForm({ formData, onFormChange, createMode =
|
|||||||
<div className="grid grid-cols-3 gap-3">
|
<div className="grid grid-cols-3 gap-3">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<Label className="text-[13px]">Status</Label>
|
<Label className="text-[13px]">Status</Label>
|
||||||
<select name="status" className="h-11 w-full rounded-md border border-gray-300 dark:border-input bg-background text-foreground pr-3 text-[13px]" value={formData.status || ''} onChange={handleChange}>
|
<select name="status" className="h-11 w-full rounded-md border border-gray-300 dark:border-input bg-background text-foreground pr-3 text-[13px]" value="confirmed" onChange={handleChange} disabled>
|
||||||
<option value="">Selecione</option>
|
|
||||||
<option value="requested">Solicitado</option>
|
|
||||||
<option value="confirmed">Confirmado</option>
|
<option value="confirmed">Confirmado</option>
|
||||||
<option value="checked_in">Check-in</option>
|
|
||||||
<option value="in_progress">Em andamento</option>
|
|
||||||
<option value="completed">Concluído</option>
|
|
||||||
<option value="cancelled">Cancelado</option>
|
|
||||||
<option value="no_show">Não compareceu</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
|
|||||||
@ -1175,6 +1175,7 @@ export async function criarAgendamento(input: AppointmentCreate): Promise<Appoin
|
|||||||
scheduled_at: new Date(scheduledDate).toISOString(),
|
scheduled_at: new Date(scheduledDate).toISOString(),
|
||||||
duration_minutes: input.duration_minutes ?? 30,
|
duration_minutes: input.duration_minutes ?? 30,
|
||||||
appointment_type: input.appointment_type ?? 'presencial',
|
appointment_type: input.appointment_type ?? 'presencial',
|
||||||
|
status: 'confirmed',
|
||||||
chief_complaint: input.chief_complaint ?? null,
|
chief_complaint: input.chief_complaint ?? null,
|
||||||
patient_notes: input.patient_notes ?? null,
|
patient_notes: input.patient_notes ?? null,
|
||||||
insurance_provider: input.insurance_provider ?? null,
|
insurance_provider: input.insurance_provider ?? null,
|
||||||
@ -1229,6 +1230,7 @@ export async function criarAgendamentoDireto(input: AppointmentCreate & { create
|
|||||||
scheduled_at: new Date(input.scheduled_at).toISOString(),
|
scheduled_at: new Date(input.scheduled_at).toISOString(),
|
||||||
duration_minutes: input.duration_minutes ?? 30,
|
duration_minutes: input.duration_minutes ?? 30,
|
||||||
appointment_type: input.appointment_type ?? 'presencial',
|
appointment_type: input.appointment_type ?? 'presencial',
|
||||||
|
status: 'confirmed',
|
||||||
chief_complaint: input.chief_complaint ?? null,
|
chief_complaint: input.chief_complaint ?? null,
|
||||||
patient_notes: input.patient_notes ?? null,
|
patient_notes: input.patient_notes ?? null,
|
||||||
insurance_provider: input.insurance_provider ?? null,
|
insurance_provider: input.insurance_provider ?? null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user