-
{activeTab === "calendar" ? "Calendário" : "Lista de Espera"}
+
+ {activeTab === "calendar" ? "Calendário" : "Lista de Espera"}
+
Navegue através dos atalhos: Calendário (C) ou Fila de espera
(F).
diff --git a/susconecta/app/(main-routes)/consultas/page.tsx b/susconecta/app/(main-routes)/consultas/page.tsx
index 47365d8..59b81d2 100644
--- a/susconecta/app/(main-routes)/consultas/page.tsx
+++ b/susconecta/app/(main-routes)/consultas/page.tsx
@@ -53,10 +53,12 @@ import {
SelectValue,
} from "@/components/ui/select";
-import { mockAppointments, mockProfessionals } from "@/lib/mocks/appointment-mocks";
+import {
+ mockAppointments,
+ mockProfessionals,
+} from "@/lib/mocks/appointment-mocks";
import { CalendarRegistrationForm } from "@/components/forms/calendar-registration-form";
-
const formatDate = (date: string | Date) => {
if (!date) return "";
return new Date(date).toLocaleDateString("pt-BR", {
@@ -69,43 +71,56 @@ const formatDate = (date: string | Date) => {
};
const capitalize = (s: string) => {
- if (typeof s !== 'string' || s.length === 0) return '';
- return s.charAt(0).toUpperCase() + s.slice(1);
+ if (typeof s !== "string" || s.length === 0) return "";
+ return s.charAt(0).toUpperCase() + s.slice(1);
};
export default function ConsultasPage() {
const [appointments, setAppointments] = useState(mockAppointments);
const [showForm, setShowForm] = useState(false);
- const [editingAppointment, setEditingAppointment] = useState(null);
- const [viewingAppointment, setViewingAppointment] = useState(null);
+ const [editingAppointment, setEditingAppointment] = useState(
+ null,
+ );
+ const [viewingAppointment, setViewingAppointment] = useState(
+ null,
+ );
const mapAppointmentToFormData = (appointment: any) => {
- const professional = mockProfessionals.find(p => p.id === appointment.professional);
+ const professional = mockProfessionals.find(
+ (p) => p.id === appointment.professional,
+ );
const appointmentDate = new Date(appointment.time);
-
+
return {
- id: appointment.id,
- patientName: appointment.patient,
- professionalName: professional ? professional.name : '',
- appointmentDate: appointmentDate.toISOString().split('T')[0],
- startTime: appointmentDate.toTimeString().split(' ')[0].substring(0, 5),
- endTime: new Date(appointmentDate.getTime() + appointment.duration * 60000).toTimeString().split(' ')[0].substring(0, 5),
- status: appointment.status,
- appointmentType: appointment.type,
- notes: appointment.notes,
- cpf: '',
- rg: '',
- birthDate: '',
- phoneCode: '+55',
- phoneNumber: '',
- email: '',
- unit: 'nei',
+ id: appointment.id,
+ patientName: appointment.patient,
+ professionalName: professional ? professional.name : "",
+ appointmentDate: appointmentDate.toISOString().split("T")[0],
+ startTime: appointmentDate.toTimeString().split(" ")[0].substring(0, 5),
+ endTime: new Date(
+ appointmentDate.getTime() + appointment.duration * 60000,
+ )
+ .toTimeString()
+ .split(" ")[0]
+ .substring(0, 5),
+ status: appointment.status,
+ appointmentType: appointment.type,
+ notes: appointment.notes,
+ cpf: "",
+ rg: "",
+ birthDate: "",
+ phoneCode: "+55",
+ phoneNumber: "",
+ email: "",
+ unit: "nei",
};
};
const handleDelete = (appointmentId: string) => {
if (window.confirm("Tem certeza que deseja excluir esta consulta?")) {
- setAppointments((prev) => prev.filter((a) => a.id !== appointmentId));
+ setAppointments((previous) =>
+ previous.filter((a) => a.id !== appointmentId),
+ );
}
};
@@ -114,7 +129,7 @@ export default function ConsultasPage() {
setEditingAppointment(formData);
setShowForm(true);
};
-
+
const handleView = (appointment: any) => {
setViewingAppointment(appointment);
};
@@ -125,40 +140,49 @@ export default function ConsultasPage() {
};
const handleSave = (formData: any) => {
-
const updatedAppointment = {
- id: formData.id,
- patient: formData.patientName,
- time: new Date(`${formData.appointmentDate}T${formData.startTime}`).toISOString(),
- duration: 30,
- type: formData.appointmentType as any,
- status: formData.status as any,
- professional: appointments.find(a => a.id === formData.id)?.professional || '',
- notes: formData.notes,
+ id: formData.id,
+ patient: formData.patientName,
+ time: new Date(
+ `${formData.appointmentDate}T${formData.startTime}`,
+ ).toISOString(),
+ duration: 30,
+ type: formData.appointmentType as any,
+ status: formData.status as any,
+ professional:
+ appointments.find((a) => a.id === formData.id)?.professional || "",
+ notes: formData.notes,
};
- setAppointments(prev =>
- prev.map(a => a.id === updatedAppointment.id ? updatedAppointment : a)
+ setAppointments((previous) =>
+ previous.map((a) =>
+ a.id === updatedAppointment.id ? updatedAppointment : a,
+ ),
);
- handleCancel();
+ handleCancel();
};
if (showForm && editingAppointment) {
return (
-
-
-
-
Editar Consulta
-
-
+
+ );
}
return (
@@ -166,7 +190,9 @@ export default function ConsultasPage() {
Gerenciamento de Consultas
-
Visualize, filtre e gerencie todas as consultas da clínica.
+
+ Visualize, filtre e gerencie todas as consultas da clínica.
+
@@ -223,7 +249,7 @@ export default function ConsultasPage() {
{appointments.map((appointment) => {
const professional = mockProfessionals.find(
- (p) => p.id === appointment.professional
+ (p) => p.id === appointment.professional,
);
return (
@@ -239,11 +265,13 @@ export default function ConsultasPage() {
appointment.status === "confirmed"
? "default"
: appointment.status === "pending"
- ? "secondary"
- : "destructive"
+ ? "secondary"
+ : "destructive"
}
className={
- appointment.status === "confirmed" ? "bg-green-600" : ""
+ appointment.status === "confirmed"
+ ? "bg-green-600"
+ : ""
}
>
{capitalize(appointment.status)}
@@ -265,7 +293,9 @@ export default function ConsultasPage() {
Ver
- handleEdit(appointment)}>
+ handleEdit(appointment)}
+ >
Editar
@@ -288,12 +318,16 @@ export default function ConsultasPage() {
{viewingAppointment && (
-