diff --git a/client/.env.example b/client/.env.example new file mode 100644 index 0000000..1b76fe4 --- /dev/null +++ b/client/.env.example @@ -0,0 +1 @@ +API_URL=https://clinica-medica-production.up.railway.app/api/v1/ \ No newline at end of file diff --git a/client/.gitignore b/client/.gitignore index 8460eea..b1095a4 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -19,6 +19,7 @@ # misc .DS_Store *.pem +.vscode # debug npm-debug.log* @@ -26,6 +27,7 @@ yarn-debug.log* yarn-error.log* # local env files +.env .env*.local # vercel diff --git a/client/public/images/home.jpg b/client/public/images/home.jpg deleted file mode 100644 index 1bd9b0a..0000000 Binary files a/client/public/images/home.jpg and /dev/null differ diff --git a/client/public/images/home.png b/client/public/images/home.png new file mode 100644 index 0000000..e918756 Binary files /dev/null and b/client/public/images/home.png differ diff --git a/client/src/actions/doctors/doctorActions.ts b/client/src/actions/doctors/doctorActions.ts new file mode 100644 index 0000000..ac1f049 --- /dev/null +++ b/client/src/actions/doctors/doctorActions.ts @@ -0,0 +1,26 @@ +'use server' + +const BASE_URL = process.env.API_URL + +export const getAllDoctors = async () => { + const url = BASE_URL + '/doctor/allDoctors' + const data = await fetch(url).then((res) => res.json()) + + if (data) { + return data + } + + return [] +} + +export const getDoctorById = async (id: number) => { + const url = BASE_URL + '/doctor/getById/' + id + + const data = await fetch(url).then((res) => res.json()) + + if (data) { + return data + } + + return null +} diff --git a/client/src/app/(patients)/appointment/[id]/page.tsx b/client/src/app/(patients)/appointment/[id]/page.tsx index 001c645..c26706c 100644 --- a/client/src/app/(patients)/appointment/[id]/page.tsx +++ b/client/src/app/(patients)/appointment/[id]/page.tsx @@ -1,31 +1,10 @@ -import { Data } from '@/interfaces/user' -import data from '../../../../utils/data.json' import { DoctorDetails } from '@/ui/doctors/Details' +import { getDoctorById } from '@/actions/doctors/doctorActions' export default async function AppointmentById({ params }: { params: { id: string } }) { const id = Number(params.id) - /* const url = '../../../../utils/data.json' - const data = await fetch(url) */ - const getDoctorData = (data: Data) => { - const doctor = data.doctors.find((doctor) => { - const user = data.users.find((user) => user.id === doctor.id_user && user.id === id) - return user - }) - - const user = data.users.find((user) => user.id === doctor?.id_user) - return { - speciality: doctor?.speciality || 'error', - name: user?.name || 'error', - dni: user?.dni || '12312312', - phone: user?.phone || 'error', - email: user?.email || 'error', - address: user?.address || 'error' - } - - } - - const doctor = getDoctorData(data) + const doctor = await getDoctorById(id) return (
Policonsultorio
- Agendar Cita -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas dolor nulla, maximus sit amet nulla egestas, egestas maximus sapien. Aliquam eget libero id justo molestie ultricies. Fusce ac nisi dignissim, finibus libero amet, congue orci. Fusce non gravida nunc. Praesent fermentum egestas eros, non imperdiet dolor.
+ +Chat bot o Publicidad
-{doctor.name}
-Especialidad: {doctor.speciality}
-DNI: {doctor.dni}
+Especialidad: {doctor.specialization}
Teléfono: {doctor.phone}
Email: {doctor.email}
-Dirección:{doctor.address}
Chat bot o Publicidad
+