From 67ee90d5e4a3241b88b11372e4d236b128cdc259 Mon Sep 17 00:00:00 2001 From: jwilliam96 Date: Thu, 17 Oct 2024 13:18:57 -0500 Subject: [PATCH] calendar --- client/next.config.mjs | 11 ++++- client/src/actions/doctors/doctorActions.ts | 32 +++++++++++++-- .../app/(patients)/appointment/[id]/page.tsx | 41 +++++++++++++++++-- .../confirmed/[id]/page.tsx | 1 - client/src/app/(patients)/calendar/page.tsx | 33 --------------- .../src/app/(patients)/clinic/[name]/page.tsx | 1 - .../app/(patients)/specialty/[name]/page.tsx | 11 +++-- client/src/app/layout.tsx | 2 - client/src/app/page.tsx | 2 + client/src/components/CalendarDemo.tsx | 9 ++-- client/src/components/alertDialog.tsx | 2 +- .../src/components/search/SearchResults.tsx | 2 +- client/src/interfaces/doctors.ts | 11 +++++ client/src/ui/auth/LoginForm.tsx | 1 - client/src/ui/auth/RegisterForm.tsx | 1 - client/src/ui/cards/SpecialityCard.tsx | 2 +- client/src/ui/dashboard/TopMenu.tsx | 8 +++- 17 files changed, 108 insertions(+), 62 deletions(-) rename client/src/app/(patients)/{calendar => appointment}/confirmed/[id]/page.tsx (97%) delete mode 100644 client/src/app/(patients)/calendar/page.tsx create mode 100644 client/src/interfaces/doctors.ts diff --git a/client/next.config.mjs b/client/next.config.mjs index 4678774..2017ff7 100644 --- a/client/next.config.mjs +++ b/client/next.config.mjs @@ -1,4 +1,13 @@ /** @type {import('next').NextConfig} */ -const nextConfig = {}; +const nextConfig = { + images: { + remotePatterns: [ + { + protocol: 'https', + hostname: 'res.cloudinary.com' + }, + ] + }, +}; export default nextConfig; diff --git a/client/src/actions/doctors/doctorActions.ts b/client/src/actions/doctors/doctorActions.ts index ac1f049..6b1dcad 100644 --- a/client/src/actions/doctors/doctorActions.ts +++ b/client/src/actions/doctors/doctorActions.ts @@ -1,5 +1,8 @@ 'use server' +import { Doctors } from "@/interfaces/doctors" +import { redirect } from "next/navigation" + const BASE_URL = process.env.API_URL export const getAllDoctors = async () => { @@ -16,11 +19,32 @@ export const getAllDoctors = async () => { export const getDoctorById = async (id: number) => { const url = BASE_URL + '/doctor/getById/' + id - const data = await fetch(url).then((res) => res.json()) + const data: Doctors = await fetch(url).then((res) => res.json()) - if (data) { - return data + if (!data) { + redirect("/") + } + + return data +} + +export const getDoctorsBySpecialty = async (specialty: string) => { + const url = BASE_URL + '/doctor/allDoctors' + + const data: Doctors[] = await fetch(url).then((res) => res.json()) + + const filterBySpecialty = data.filter(doctor => doctor.specialization === specialty) + + if (!filterBySpecialty) { + return undefined } - return null + return filterBySpecialty } + +export const getHoursDoctor = async (id: number) => { + const url = BASE_URL + `/appointment/occupied-times/${id}` + + const data = await fetch(url).then((res) => res.json()) + +} \ No newline at end of file diff --git a/client/src/app/(patients)/appointment/[id]/page.tsx b/client/src/app/(patients)/appointment/[id]/page.tsx index c26706c..4d03611 100644 --- a/client/src/app/(patients)/appointment/[id]/page.tsx +++ b/client/src/app/(patients)/appointment/[id]/page.tsx @@ -1,15 +1,48 @@ -import { DoctorDetails } from '@/ui/doctors/Details' import { getDoctorById } from '@/actions/doctors/doctorActions' +import { CalendarDemo } from '@/components/CalendarDemo' +import Image from 'next/image' +import { redirect } from 'next/navigation' export default async function AppointmentById({ params }: { params: { id: string } }) { const id = Number(params.id) const doctor = await getDoctorById(id) + + if (!doctor) { + redirect("/dashboard") + } + return ( -
-

Agenda del doctor

- +
+
+
+

Selecciona un turno

+
+ +
+ +
+
+

{doctor.name}

+ {doctor.specialization} + +

Clínica colón - jujuy 2176

+
+
+ +
+ +
+
+

Primer turno disponible

+

Martes 22 de Octubre 14:00hs

+
+
+
+ + +
) } \ No newline at end of file diff --git a/client/src/app/(patients)/calendar/confirmed/[id]/page.tsx b/client/src/app/(patients)/appointment/confirmed/[id]/page.tsx similarity index 97% rename from client/src/app/(patients)/calendar/confirmed/[id]/page.tsx rename to client/src/app/(patients)/appointment/confirmed/[id]/page.tsx index a214494..e207781 100644 --- a/client/src/app/(patients)/calendar/confirmed/[id]/page.tsx +++ b/client/src/app/(patients)/appointment/confirmed/[id]/page.tsx @@ -3,7 +3,6 @@ import Link from "next/link"; export default function ConfirmedPage({ params }: { params: { name: string } }) { - console.log(params.name) return (
diff --git a/client/src/app/(patients)/calendar/page.tsx b/client/src/app/(patients)/calendar/page.tsx deleted file mode 100644 index a36cf7b..0000000 --- a/client/src/app/(patients)/calendar/page.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { CalendarDemo } from "@/components/CalendarDemo"; - -export default function CalendarPage() { - return ( -
-
-
-

Selecciona un turno

-
-
-
-

Dra. Monica Gonzalez

- Dermatóloga - -

Clínica colón - jujuy 2176

-
-
- -
- -
-
-

Primer turno disponible

-

Martes 22 de Octubre 14:00hs

-
-
-
- - - -
- ); -} \ No newline at end of file diff --git a/client/src/app/(patients)/clinic/[name]/page.tsx b/client/src/app/(patients)/clinic/[name]/page.tsx index f0f45de..ad26704 100644 --- a/client/src/app/(patients)/clinic/[name]/page.tsx +++ b/client/src/app/(patients)/clinic/[name]/page.tsx @@ -4,7 +4,6 @@ import { Select } from "@/ui"; import Image from "next/image"; export default function ClinicPage({ params }: { params: { name: string } }) { - console.log(params.name) return (
diff --git a/client/src/app/(patients)/specialty/[name]/page.tsx b/client/src/app/(patients)/specialty/[name]/page.tsx index faed5dc..8325933 100644 --- a/client/src/app/(patients)/specialty/[name]/page.tsx +++ b/client/src/app/(patients)/specialty/[name]/page.tsx @@ -1,9 +1,12 @@ +import { getDoctorsBySpecialty } from "@/actions/doctors/doctorActions"; import { DoctorCard } from "@/ui"; +export default async function SpecialtyPage({ params }: { params: { name: string } }) { -export default function SpecialtyPage() { + const specialty = decodeURIComponent(params.name) + + const doctors = await getDoctorsBySpecialty(specialty) - const images = ["/images/doctors/img1.jpg", "/images/doctors/img2.jpg", "/images/doctors/img3.jpg", "/images/doctors/img4.jpg", "/images/doctors/img5.jpg", "/images/doctors/img6.jpg", "/images/doctors/img7.jpg"] return (
@@ -12,8 +15,8 @@ export default function SpecialtyPage() {
{ - images.map(item => ( - + doctors?.map(doctor => ( + )) }
diff --git a/client/src/app/layout.tsx b/client/src/app/layout.tsx index a193cb1..0db0ef0 100644 --- a/client/src/app/layout.tsx +++ b/client/src/app/layout.tsx @@ -1,7 +1,6 @@ import type { Metadata } from "next"; import { Poppins } from 'next/font/google' import "./globals.css"; -import { Header } from "@/ui/patient/Header"; const poppins = Poppins({ style: 'normal', @@ -25,7 +24,6 @@ export default function RootLayout({ className={`${poppins.className} antialiased`} >
-
{children}
diff --git a/client/src/app/page.tsx b/client/src/app/page.tsx index 32b8903..e109347 100644 --- a/client/src/app/page.tsx +++ b/client/src/app/page.tsx @@ -3,10 +3,12 @@ import Image from "next/image"; import Link from "next/link"; import HomeImage from '/public/images/home.png' import { ButtonComponent } from "@/ui"; +import { Header } from "@/ui/patient/Header"; export default function Home() { return (
+
diff --git a/client/src/components/CalendarDemo.tsx b/client/src/components/CalendarDemo.tsx index 7f08d36..e2053c7 100644 --- a/client/src/components/CalendarDemo.tsx +++ b/client/src/components/CalendarDemo.tsx @@ -13,7 +13,7 @@ export function CalendarDemo() { const [date, setDate] = useState(new Date()) const [hour, setHour] = useState("") - const formatYear = format(date ?? new Date(), "MM/dd/yyyy") + const formatYear = format(date ?? new Date(), 'yyyy-MM-dd') const formattedDate = format(formatYear, "EEEE d 'de' MMMM", { locale: es }); const createHourItem = (hour: string) => ( @@ -30,12 +30,9 @@ export function CalendarDemo() { const filterHours = () => { - if (formatYear === "10/17/2024") { + if (formatYear === "2024-10-18") { return amHours.filter(item => !hourArray.includes(item.hour)) - } else { - return amHours - } - + } else { return amHours } } return ( diff --git a/client/src/components/alertDialog.tsx b/client/src/components/alertDialog.tsx index 6503a3d..c9a7d3a 100644 --- a/client/src/components/alertDialog.tsx +++ b/client/src/components/alertDialog.tsx @@ -35,7 +35,7 @@ export const AlertDialogCalendar = ({ openDialog, setOpenDialog, hour, formatted Cancel - route.push("/calendar/confirmed/123")}>Continue + route.push("/appointment/confirmed/123")}>Continue diff --git a/client/src/components/search/SearchResults.tsx b/client/src/components/search/SearchResults.tsx index f58b854..66b770c 100644 --- a/client/src/components/search/SearchResults.tsx +++ b/client/src/components/search/SearchResults.tsx @@ -47,7 +47,7 @@ export const SearchResults: React.FC = async ({ query, data }) => { } const results = getDoctorData(data) - console.log(results); + // console.log(results); const isNameSearch = results.some(result => result?.name.toLowerCase().includes(query.toLowerCase())) const isSpecialitySearch = results.some(result => result?.speciality.toLowerCase().includes(query.toLowerCase())) diff --git a/client/src/interfaces/doctors.ts b/client/src/interfaces/doctors.ts new file mode 100644 index 0000000..59025a3 --- /dev/null +++ b/client/src/interfaces/doctors.ts @@ -0,0 +1,11 @@ +export interface Doctors { + id: number; + name: string; + password: string; + email: string; + phone: string; + img: string; + active: boolean; + specialization: string; + licenseNumber: string; +} diff --git a/client/src/ui/auth/LoginForm.tsx b/client/src/ui/auth/LoginForm.tsx index ce092ba..2a816cf 100644 --- a/client/src/ui/auth/LoginForm.tsx +++ b/client/src/ui/auth/LoginForm.tsx @@ -14,7 +14,6 @@ export function LoginForm() { const submit = handleSubmit(data => { - console.log(data) reset({ email: "", password: "", diff --git a/client/src/ui/auth/RegisterForm.tsx b/client/src/ui/auth/RegisterForm.tsx index bb8aefe..08fedf2 100644 --- a/client/src/ui/auth/RegisterForm.tsx +++ b/client/src/ui/auth/RegisterForm.tsx @@ -14,7 +14,6 @@ export function RegisterForm() { const submit = handleSubmit(data => { - console.log(data) reset({ email: "", password: "", diff --git a/client/src/ui/cards/SpecialityCard.tsx b/client/src/ui/cards/SpecialityCard.tsx index 498e27e..1286814 100644 --- a/client/src/ui/cards/SpecialityCard.tsx +++ b/client/src/ui/cards/SpecialityCard.tsx @@ -7,7 +7,7 @@ interface Props { } export function SpecialityCard({ name, img }: Props) { return ( - + <> {img !== '' ? ( {name diff --git a/client/src/ui/dashboard/TopMenu.tsx b/client/src/ui/dashboard/TopMenu.tsx index a59e8e9..6aa306b 100644 --- a/client/src/ui/dashboard/TopMenu.tsx +++ b/client/src/ui/dashboard/TopMenu.tsx @@ -14,8 +14,14 @@ export function TopMenu() {
  • Mis turnos + href={"/dashboard"}>Mis turnos
  • +
  • + Reservar turno +
  • + { icons.map((item, index) => (