diff --git a/app/doctor/dashboard/page.tsx b/app/doctor/dashboard/page.tsx
index 060d8e4..af05f6d 100644
--- a/app/doctor/dashboard/page.tsx
+++ b/app/doctor/dashboard/page.tsx
@@ -14,6 +14,7 @@ import { exceptionsService } from "@/services/exceptionApi.mjs";
import { doctorsService } from "@/services/doctorsApi.mjs";
import { usersService } from "@/services/usersApi.mjs";
import Sidebar from "@/components/Sidebar";
+import WeeklyScheduleCard from "@/components/ui/WeeklyScheduleCard";
type Availability = {
id: string;
@@ -35,33 +36,33 @@ type Schedule = {
};
type Doctor = {
- id: string;
- user_id: string | null;
- crm: string;
- crm_uf: string;
- specialty: string;
- full_name: string;
- cpf: string;
- email: string;
- phone_mobile: string | null;
- phone2: string | null;
- cep: string | null;
- street: string | null;
- number: string | null;
- complement: string | null;
- neighborhood: string | null;
- city: string | null;
- state: string | null;
- birth_date: string | null;
- rg: string | null;
- active: boolean;
- created_at: string;
- updated_at: string;
- created_by: string;
- updated_by: string | null;
- max_days_in_advance: number;
- rating: number | null;
-}
+ id: string;
+ user_id: string | null;
+ crm: string;
+ crm_uf: string;
+ specialty: string;
+ full_name: string;
+ cpf: string;
+ email: string;
+ phone_mobile: string | null;
+ phone2: string | null;
+ cep: string | null;
+ street: string | null;
+ number: string | null;
+ complement: string | null;
+ neighborhood: string | null;
+ city: string | null;
+ state: string | null;
+ birth_date: string | null;
+ rg: string | null;
+ active: boolean;
+ created_at: string;
+ updated_at: string;
+ created_by: string;
+ updated_by: string | null;
+ max_days_in_advance: number;
+ rating: number | null;
+};
interface UserPermissions {
isAdmin: boolean;
@@ -94,15 +95,15 @@ interface UserData {
}
interface Exception {
- id: string; // id da exceção
- doctor_id: string;
- date: string; // formato YYYY-MM-DD
- start_time: string | null; // null = dia inteiro
- end_time: string | null; // null = dia inteiro
- kind: "bloqueio" | "disponibilidade"; // tipos conhecidos
- reason: string | null; // pode ser null
- created_at: string; // timestamp ISO
- created_by: string;
+ id: string; // id da exceção
+ doctor_id: string;
+ date: string; // formato YYYY-MM-DD
+ start_time: string | null; // null = dia inteiro
+ end_time: string | null; // null = dia inteiro
+ kind: "bloqueio" | "disponibilidade"; // tipos conhecidos
+ reason: string | null; // pode ser null
+ created_at: string; // timestamp ISO
+ created_by: string;
}
export default function PatientDashboard() {
@@ -128,44 +129,38 @@ export default function PatientDashboard() {
};
useEffect(() => {
- const fetchData = async () => {
- try {
- const doctorsList: Doctor[] = await doctorsService.list();
- const doctor = doctorsList[0];
+ const fetchData = async () => {
+ try {
+ const doctorsList: Doctor[] = await doctorsService.list();
+ const doctor = doctorsList[0];
- // Salva no estado
- setLoggedDoctor(doctor);
+ // Salva no estado
+ setLoggedDoctor(doctor);
- // Busca disponibilidade
- const availabilityList = await AvailabilityService.list();
-
- // Filtra já com a variável local
- const filteredAvail = availabilityList.filter(
- (disp: { doctor_id: string }) => disp.doctor_id === doctor?.id
- );
- setAvailability(filteredAvail);
+ // Busca disponibilidade
+ const availabilityList = await AvailabilityService.list();
- // Busca exceções
- const exceptionsList = await exceptionsService.list();
- const filteredExc = exceptionsList.filter(
- (exc: { doctor_id: string }) => exc.doctor_id === doctor?.id
- );
- console.log(exceptionsList)
- setExceptions(filteredExc);
+ // Filtra já com a variável local
+ const filteredAvail = availabilityList.filter((disp: { doctor_id: string }) => disp.doctor_id === doctor?.id);
+ setAvailability(filteredAvail);
- } catch (e: any) {
- alert(`${e?.error} ${e?.message}`);
- }
- };
+ // Busca exceções
+ const exceptionsList = await exceptionsService.list();
+ const filteredExc = exceptionsList.filter((exc: { doctor_id: string }) => exc.doctor_id === doctor?.id);
+ setExceptions(filteredExc);
+ } catch (e: any) {
+ alert(`${e?.error} ${e?.message}`);
+ }
+ };
- fetchData();
-}, []);
+ fetchData();
+ }, []);
// Função auxiliar para filtrar o id do doctor correspondente ao user logado
function findDoctorById(id: string, doctors: Doctor[]) {
return doctors.find((doctor) => doctor.user_id === id);
}
-
+
const openDeleteDialog = (exceptionId: string) => {
setExceptionToDelete(exceptionId);
setDeleteDialogOpen(true);
@@ -173,7 +168,7 @@ export default function PatientDashboard() {
const handleDeleteException = async (ExceptionId: string) => {
try {
- alert(ExceptionId)
+ alert(ExceptionId);
const res = await exceptionsService.delete(ExceptionId);
let message = "Exceção deletada com sucesso";
@@ -316,31 +311,7 @@ export default function PatientDashboard() {
{weekdaysPT[day]}
- {formatTime(t.start)} Sem horário
{formatTime(t.end)}
-
{date}
-- {startTime && endTime - ? `${startTime} - ${endTime}` - : "Dia todo"} -
+{startTime && endTime ? `${startTime} - ${endTime}` : "Dia todo"}
{ex.kind === "bloqueio" ? "Bloqueio" : "Liberação"}
diff --git a/app/manager/disponibilidade/page.tsx b/app/manager/disponibilidade/page.tsx new file mode 100644 index 0000000..adfcd80 --- /dev/null +++ b/app/manager/disponibilidade/page.tsx @@ -0,0 +1,185 @@ +"use client"; + +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import Sidebar from "@/components/Sidebar"; +import WeeklyScheduleCard from "@/components/ui/WeeklyScheduleCard"; + +import { useEffect, useState, useMemo } from "react"; + +import { AvailabilityService } from "@/services/availabilityApi.mjs"; +import { doctorsService } from "@/services/doctorsApi.mjs"; +import { Input } from "@/components/ui/input"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Button } from "@/components/ui/button"; +import { Filter } from "lucide-react"; + +type Doctor = { + id: string; + full_name: string; + specialty: string; + active: boolean; +}; + +type Availability = { + id: string; + doctor_id: string; + weekday: string; + start_time: string; + end_time: string; +}; + +export default function AllAvailabilities() { + const [availabilities, setAvailabilities] = useStateVisualize a agenda semanal individual de cada médico.
+Carregando...
+ ) : ( + ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "Saturday"].map((day) => { + const times = schedule[day] || []; + return ( +{weekdaysPT[day]}
+
+ {formatTime(t.start)}
{formatTime(t.end)}
+
Sem horário
+ )} +