diff --git a/src/components/dashboard/admin/index.jsx b/src/components/dashboard/admin/index.jsx index a089f3e..85a05fb 100644 --- a/src/components/dashboard/admin/index.jsx +++ b/src/components/dashboard/admin/index.jsx @@ -8,7 +8,7 @@ function Admin({user,setUser}) { const [page, setPage] = useState("home"); const links = [ {page:"home",name:"Accueil"}, - {page:"appointment",name:"Rendez-vous"}, + config.appointmentOn ? {page:"appointment",name:"Rendez-vous"} : null, config.prescriptionOn ? {page:"prescription",name:"Préscriptions"} : null, {page:"medical-file",name:"Dossier Médical"}, {page:"user",name:"Utilisateurs"}, @@ -16,7 +16,7 @@ function Admin({user,setUser}) { {page:"patient",name:"Patients"}, {page:"hospital",name:"Hôpitaux"}, {page:"service",name:"Services"}, - {page:"profil",name:"Profil"} + config.profilOn ? {page:"profil",name:"Profil"} : null ]; return( diff --git a/src/components/dashboard/doctor/appointment/index.jsx b/src/components/dashboard/doctor/appointment/index.jsx index e69de29..c3b5e2c 100644 --- a/src/components/dashboard/doctor/appointment/index.jsx +++ b/src/components/dashboard/doctor/appointment/index.jsx @@ -0,0 +1,44 @@ +import HeadTitle from "../../head-title"; +import ItemList from "./item-list"; +import MenuDisplay from "../../menu-display"; +import { useState, useEffect } from "react"; +import { get } from "../../../../modules/fetchManager"; +import DeleteMenu from "../../delete-menu"; + +function Appointment({user}) { + + const [appointments, setAppointments] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const [deleteMenu, setDeleteMenu] = useState(false); + + useEffect(() => { + if(loading && !error && appointments.length === 0){ + get('doctors/@me/appointments', user.token) + .then((data) => { + setLoading(false); + if(data.status === 404) { + setError("Aucun rendez-vous trouvé"); + return; + } + + if(data.status === 500) { + setError("Erreur serveur, veuillez réessayer plus tard"); + return; + } + + setAppointments(data.JSON); + }); + } + },[user]); + + return ( +
+ + + { deleteMenu ? : null } +
+ ); +} + +export default Appointment; \ No newline at end of file diff --git a/src/components/dashboard/doctor/appointment/item-list/index.jsx b/src/components/dashboard/doctor/appointment/item-list/index.jsx new file mode 100644 index 0000000..fde66ab --- /dev/null +++ b/src/components/dashboard/doctor/appointment/item-list/index.jsx @@ -0,0 +1,19 @@ +import DeleteButton from "../../../delete-button"; + +function ItemList({item, setDeleteMenu}) { + const date = new Date(item.date); + return ( +
+
+

{item.name} - {date.getDay() > 9 ? date.getDay() : "0"+date.getDay()}/{date.getMonth() > 9 ? date.getMonth() : "0"+date.getMonth()}/{date.getFullYear()},{item.time.substring(0,item.time.length-3)}

+

{item.gender} - {item.first_name} {item.last_name}

+
+
+ {/* */} + +
+
+ ); +} + +export default ItemList; \ No newline at end of file diff --git a/src/components/dashboard/doctor/home/index.jsx b/src/components/dashboard/doctor/home/index.jsx index 0b28818..c6b7535 100644 --- a/src/components/dashboard/doctor/home/index.jsx +++ b/src/components/dashboard/doctor/home/index.jsx @@ -1,12 +1,14 @@ import HeadTitle from "../../head-title"; import Services from "./services"; import Hospitals from "./hospitals"; +import config from "../../../../config"; function Home({user}) { return(
+ {config.affectationOn ?

Affectation

@@ -15,7 +17,7 @@ function Home({user}) {
-
+
: null}
diff --git a/src/components/dashboard/doctor/index.jsx b/src/components/dashboard/doctor/index.jsx index 55064ce..eb7fa35 100644 --- a/src/components/dashboard/doctor/index.jsx +++ b/src/components/dashboard/doctor/index.jsx @@ -7,10 +7,10 @@ function Doctor({user, setUser}) { const [page, setPage] = useState("home"); const links = [ {page:"home",name:"Accueil"}, - {page:"appointment",name:"Rendez-vous"}, + config.appointmentOn ? {page:"appointment",name:"Rendez-vous"} : null, config.prescriptionOn ? {page:"prescription",name:"Préscriptions"} : null, {page:"medical-file",name:"Dossier Médical"}, - {page:"profil",name:"Profil"} + config.profilOn ? {page:"profil",name:"Profil"} : null ]; return ( diff --git a/src/components/dashboard/menu-display/index.jsx b/src/components/dashboard/menu-display/index.jsx index 891dada..4bcb938 100644 --- a/src/components/dashboard/menu-display/index.jsx +++ b/src/components/dashboard/menu-display/index.jsx @@ -2,7 +2,7 @@ import Container from "../container" import Loader from "../loader" import ListDisplay from "../list-display" -function MenuDisplay({loading, error, data, ItemList, setDeleteMenu, setModifyMenu,user = null,setDetailMenu = null}) { +function MenuDisplay({loading, error, data, ItemList, setDeleteMenu = null, setModifyMenu = null,user = null,setDetailMenu = null}) { return( { loading ? : null } diff --git a/src/components/dashboard/patient/appointment/index.jsx b/src/components/dashboard/patient/appointment/index.jsx index 12ce1ad..c31ff57 100644 --- a/src/components/dashboard/patient/appointment/index.jsx +++ b/src/components/dashboard/patient/appointment/index.jsx @@ -5,12 +5,14 @@ import Create from "./create"; import CreateButton from "../../createButton"; import ItemList from "./item-list"; import MenuDisplay from "../../menu-display"; +import DeleteMenu from "../../delete-menu"; function Appointment({user}) { const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [appointments, setAppointments] = useState([]); const [createMenu, setCreateMenu] = useState(false); + const [deleteMenu, setDeleteMenu] = useState(false); // if(loading && !error && appointments.length === 0){ @@ -42,8 +44,9 @@ function Appointment({user}) {
- + { createMenu ? : null } + { deleteMenu ? : null }
); } diff --git a/src/components/dashboard/patient/appointment/item-list/index.jsx b/src/components/dashboard/patient/appointment/item-list/index.jsx index d37267f..063d6bc 100644 --- a/src/components/dashboard/patient/appointment/item-list/index.jsx +++ b/src/components/dashboard/patient/appointment/item-list/index.jsx @@ -1,4 +1,6 @@ -function ItemList({item}) { +import DeleteButton from "../../../delete-button"; + +function ItemList({item, setDeleteMenu}) { const date = new Date(item.date); return (
@@ -6,16 +8,10 @@ function ItemList({item}) {

{item.name} - {date.getDay() > 9 ? date.getDay() : "0"+date.getDay()}/{date.getMonth() > 9 ? date.getMonth() : "0"+date.getMonth()}/{date.getFullYear()},{item.time.substring(0,item.time.length-3)}

Dr.{item.first_name} {item.last_name}, {item.email} - {item.phone}

- {/*
-
- {!item.is_verified ? : null} - -
-
- - -
-
*/} +
+ {/* */} + +
); } diff --git a/src/components/dashboard/patient/index.jsx b/src/components/dashboard/patient/index.jsx index d6b159d..56d9ee5 100644 --- a/src/components/dashboard/patient/index.jsx +++ b/src/components/dashboard/patient/index.jsx @@ -7,10 +7,10 @@ function Patient({user,setUser}) { const [page, setPage] = useState("home"); const links = [ {page:"home",name:"Accueil"}, - {page:"appointment",name:"Rendez-vous"}, + config.appointmentOn ? {page:"appointment",name:"Rendez-vous"} : null, config.prescriptionOn ? {page:"prescription",name:"Préscriptions"} : null, {page:"medical-file",name:"Dossier Médical"}, - {page:"profil",name:"Profil"} + config.profilOn ? {page:"profil",name:"Profil"} : null, ] return ( diff --git a/src/components/dashboard/patient/profil/index.jsx b/src/components/dashboard/patient/profil/index.jsx index bb9b669..3313345 100644 --- a/src/components/dashboard/patient/profil/index.jsx +++ b/src/components/dashboard/patient/profil/index.jsx @@ -1,9 +1,44 @@ import HeadTitle from "../../head-title"; +import { useState, useEffect } from "react"; +import { get } from "../../../../modules/fetchManager"; +import UserForm from '../../user-form'; +import PatientForm from "./patient-form"; + +function Profil({user}) { + + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const [profile, setProfile] = useState(false); + + + useEffect(() => { + get('patients/@me', user.token) + .then((data) => { + setLoading(false); + if(data.status === 404) { + setError("Aucun rendez-vous trouvé"); + return; + } + if(data.status === 500) { + setError("Erreur serveur, veuillez réessayer plus tard"); + return; + } + setProfile(data.JSON); + console.log(profile); + }); + },[user]); -function Profil() { return (
+ {loading ?
Chargement...
: null} + {error ?
{error}
: null} + {profile ? +
+ + +
+ : null}
); } diff --git a/src/components/dashboard/patient/profil/patient-form.jsx b/src/components/dashboard/patient/profil/patient-form.jsx new file mode 100644 index 0000000..1c1341a --- /dev/null +++ b/src/components/dashboard/patient/profil/patient-form.jsx @@ -0,0 +1,64 @@ +import { useForm } from "react-hook-form"; +import SubmitButton from "../../submit-button"; +import { put } from "../../../../modules/fetchManager"; +import { useState,useEffect } from "react"; + +function PatientForm({user, profile}) { + const { register, handleSubmit } = useForm(); + const [gender, setGender] = useState(null); + + const onSubmit = (data) => { + data.user_id = user.data.id; + put('patients/@me', data, user.token) + .then((data) => { + console.log(data); + if(data.status === 200){ + alert("Profil mis à jour"); + return; + } + alert("Erreur lors de la mise à jour"); + return; + }); + }; + + useEffect(() => { + if(profile.gender === 'M') setGender('Homme'); + if(profile.gender === 'F') setGender('Femme'); + if(profile.gender === 'O') setGender('Autre'); + },[user]); + + return( +
+
+

Profil patient

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + + ) +} + +export default PatientForm; \ No newline at end of file diff --git a/src/components/dashboard/user-form/index.jsx b/src/components/dashboard/user-form/index.jsx new file mode 100644 index 0000000..24678f8 --- /dev/null +++ b/src/components/dashboard/user-form/index.jsx @@ -0,0 +1,46 @@ +import { useForm } from "react-hook-form"; +import { put } from "../../../modules/fetchManager"; +import SubmitButton from "../submit-button"; + +function UserForm({user}) { + + const { register, handleSubmit } = useForm(); + + const onSubmit = (data) => { + put('users/@me', data, user.token) + .then((data) => { + if(data.status === 200){ + alert("Profil mis à jour"); + return; + } + alert("Erreur lors de la mise à jour"); + return; + }); + }; + + return( +
+

Profil utilisateur

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + + ); + +} + +export default UserForm; \ No newline at end of file diff --git a/src/config.sample.js b/src/config.sample.js new file mode 100644 index 0000000..984cc7c --- /dev/null +++ b/src/config.sample.js @@ -0,0 +1,9 @@ +const config = { + api: "http://127.0.0.1:3000/api", + prescriptionOn: true, + appointmentOn: true, + profilOn: true, + affectationOn: true, +} + +export default config; \ No newline at end of file