diff --git a/src/components/auth/register/index.jsx b/src/components/auth/register/index.jsx
index fac655c..5b229d7 100644
--- a/src/components/auth/register/index.jsx
+++ b/src/components/auth/register/index.jsx
@@ -13,10 +13,10 @@ function Register() {
}
post('users/register', e)
.then(data => {
- if(data.error){
- setError(data.error);
+ if(data.status === 200){
+ window.location.href = '/login';
}
- console.log(data);
+ setError(data.error);
});
}
diff --git a/src/components/auth/verifyEmail/index.jsx b/src/components/auth/verifyEmail/index.jsx
new file mode 100644
index 0000000..efdee4e
--- /dev/null
+++ b/src/components/auth/verifyEmail/index.jsx
@@ -0,0 +1,63 @@
+import { useState, useEffect } from 'react';
+import { get } from '../../../modules/fetchManager.js';
+import { getUserSession, setUserSession } from '../../../modules/userManager.js';
+
+function VerifyEmail() {
+ const queryParameters = new URLSearchParams(window.location.search);
+ const code = queryParameters.get('code');
+ const user = getUserSession();
+ const [verified,setVerified] =useState(null);
+ const [error, setError] = useState(null);
+
+ if(!user || !user.token || !user.data){
+ console.log(user);
+ window.location.href = '/login';
+ }
+
+ get('users/email/verify?code='+code, user.token)
+ .then(data => {
+ if(data.status !== 200){
+ if(data.status === 400){
+ setError("Le code de vérification est invalide");
+ }
+ if(data.status === 500){
+ setError("Erreur serveur, veuillez réessayer plus tard");
+ }
+ return;
+ }
+ setVerified("Votre email a bien été vérifié");
+ setUserSession({
+ token: user.token,
+ data: user.data,
+ });
+ })
+
+ const handleClick = (e) => {
+ e.preventDefault();
+ get('users/email/request', user.token)
+ .then(data => {
+ if(data.status !== 200){
+ setError("Erreur serveur, veuillez réessayer plus tard");
+ return;
+ }
+ setVerified("Email envoyé");
+ })
+ }
+
+ return (
+
+
+ {code ?
Vérification de l'email en cours...
:
Veuillez vérifiez votre boîte mail, un mail de vérification vous a été envoyé
}
+ {verified ?
{verified}
: null}
+ {error ?
+
{error}
+
+
: null}
+
+
+ );
+}
+
+export default VerifyEmail;
\ No newline at end of file
diff --git a/src/components/dashboard/admin/appointment/index.jsx b/src/components/dashboard/admin/appointment/index.jsx
new file mode 100644
index 0000000..8fe1514
--- /dev/null
+++ b/src/components/dashboard/admin/appointment/index.jsx
@@ -0,0 +1,11 @@
+import HeadTitle from "../../head-title";
+
+function Appointment({user}) {
+ return(
+
+
+
+ )
+}
+
+export default Appointment;
\ No newline at end of file
diff --git a/src/components/dashboard/admin/hospital/create/index.jsx b/src/components/dashboard/admin/hospital/create/index.jsx
new file mode 100644
index 0000000..09d449c
--- /dev/null
+++ b/src/components/dashboard/admin/hospital/create/index.jsx
@@ -0,0 +1,53 @@
+import ModalContainer from '../../../modal-container';
+import { useForm } from 'react-hook-form';
+import { post } from '../../../../../modules/fetchManager';
+
+function CreateHospital({setCreateMenu,user}) {
+
+ const { register, handleSubmit } = useForm();
+
+ const onSubmit = (data) => {
+ data.company_id = 1;
+ data.country = "France";
+ post('hospitals', data, user.token)
+ .then(data => {
+ console.log(data);
+ })
+ }
+
+ return(
+
+
+
+ )
+}
+
+export default CreateHospital;
\ No newline at end of file
diff --git a/src/components/dashboard/admin/hospital/index.jsx b/src/components/dashboard/admin/hospital/index.jsx
new file mode 100644
index 0000000..090391c
--- /dev/null
+++ b/src/components/dashboard/admin/hospital/index.jsx
@@ -0,0 +1,11 @@
+import HeadTitle from "../../head-title";
+
+function Hospital({user}) {
+ return(
+
+
+
+ )
+}
+
+export default Hospital;
\ No newline at end of file
diff --git a/src/components/dashboard/admin/index.jsx b/src/components/dashboard/admin/index.jsx
new file mode 100644
index 0000000..f952097
--- /dev/null
+++ b/src/components/dashboard/admin/index.jsx
@@ -0,0 +1,26 @@
+import { useState } from 'react';
+import PageContainer from '../page-container';
+import config from '../../../config';
+import MenuHandler from './menu-handler';
+
+function Admin({user,setUser}) {
+
+ const [page, setPage] = useState("home");
+ const links = [
+ {page:"home",name:"Accueil"},
+ {page:"appointment",name:"Rendez-vous"},
+ config.prescriptionOn ? {page:"prescription",name:"Préscriptions"} : null,
+ {page:"medical-file",name:"Dossier Médical"},
+ {page:"user",name:"Utilisateurs"},
+ {page:"hospital",name:"Hôpitaux"},
+ {page:"profil",name:"Profil"}
+ ]
+
+ return(
+
+
+
+ )
+}
+
+export default Admin;
\ No newline at end of file
diff --git a/src/components/dashboard/admin/medical-file/index.jsx b/src/components/dashboard/admin/medical-file/index.jsx
new file mode 100644
index 0000000..809f6f8
--- /dev/null
+++ b/src/components/dashboard/admin/medical-file/index.jsx
@@ -0,0 +1,11 @@
+import HeadTitle from "../../head-title";
+
+function MedicalFile({user}) {
+ return(
+
+
+
+ )
+}
+
+export default MedicalFile;
\ No newline at end of file
diff --git a/src/components/dashboard/admin/menu-handler/index.jsx b/src/components/dashboard/admin/menu-handler/index.jsx
new file mode 100644
index 0000000..489220d
--- /dev/null
+++ b/src/components/dashboard/admin/menu-handler/index.jsx
@@ -0,0 +1,28 @@
+import Prescription from "../prescription";
+import MedicalFile from "../medical-file";
+import Appointment from "../appointment";
+import User from "../user";
+import Hospital from "../hospital";
+import Profil from "../profil";
+import Home from "../../home";
+
+function MenuHandler({page,user}) {
+ switch (page) {
+ case "prescription":
+ return
;
+ case "medical-file":
+ return
;
+ case "appointment":
+ return
;
+ case "user":
+ return
;
+ case "hospital":
+ return
;
+ case "profil":
+ return
;
+ default:
+ return
;
+ }
+}
+
+export default MenuHandler;
\ No newline at end of file
diff --git a/src/components/dashboard/admin/prescription/index.jsx b/src/components/dashboard/admin/prescription/index.jsx
new file mode 100644
index 0000000..0477a42
--- /dev/null
+++ b/src/components/dashboard/admin/prescription/index.jsx
@@ -0,0 +1,11 @@
+import HeadTitle from "../../head-title";
+
+function Prescription({user}) {
+ return (
+
+
+
+ );
+}
+
+export default Prescription;
\ No newline at end of file
diff --git a/src/components/dashboard/admin/profil/index.jsx b/src/components/dashboard/admin/profil/index.jsx
new file mode 100644
index 0000000..1906037
--- /dev/null
+++ b/src/components/dashboard/admin/profil/index.jsx
@@ -0,0 +1,11 @@
+import HeadTitle from "../../head-title";
+
+function Profil({user}) {
+ return(
+
+
+
+ )
+}
+
+export default Profil;
\ No newline at end of file
diff --git a/src/components/dashboard/admin/user/index.jsx b/src/components/dashboard/admin/user/index.jsx
new file mode 100644
index 0000000..e60fa2d
--- /dev/null
+++ b/src/components/dashboard/admin/user/index.jsx
@@ -0,0 +1,11 @@
+import HeadTitle from "../../head-title";
+
+function User({user}) {
+ return(
+
+
+
+ )
+}
+
+export default User;
\ No newline at end of file
diff --git a/src/components/dashboard/appointment/index.jsx b/src/components/dashboard/appointment/index.jsx
deleted file mode 100644
index 3ca2a4d..0000000
--- a/src/components/dashboard/appointment/index.jsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import HeadTitle from "../head-title";
-
-function Appointment() {
- return (
-
-
-
- );
-}
-
-export default Appointment;
\ No newline at end of file
diff --git a/src/components/dashboard/back-button/index.jsx b/src/components/dashboard/back-button/index.jsx
new file mode 100644
index 0000000..7716c04
--- /dev/null
+++ b/src/components/dashboard/back-button/index.jsx
@@ -0,0 +1,12 @@
+function BackButton({setMenu,value}) {
+
+ const val = value ? value : null;
+
+ return(
+
+ );
+}
+
+export default BackButton;
\ No newline at end of file
diff --git a/src/components/dashboard/container/index.jsx b/src/components/dashboard/container/index.jsx
new file mode 100644
index 0000000..7d31c88
--- /dev/null
+++ b/src/components/dashboard/container/index.jsx
@@ -0,0 +1,9 @@
+function Container({children}) {
+ return(
+
+ {children}
+
+ )
+}
+
+export default Container;
\ No newline at end of file
diff --git a/src/components/dashboard/createButton/index.jsx b/src/components/dashboard/createButton/index.jsx
new file mode 100644
index 0000000..a3c7920
--- /dev/null
+++ b/src/components/dashboard/createButton/index.jsx
@@ -0,0 +1,9 @@
+function CreateButton({setCreateMenu, nameMenu}) {
+ return(
+
+ )
+}
+
+export default CreateButton;
\ No newline at end of file
diff --git a/src/components/dashboard/doctor/index.jsx b/src/components/dashboard/doctor/index.jsx
new file mode 100644
index 0000000..55064ce
--- /dev/null
+++ b/src/components/dashboard/doctor/index.jsx
@@ -0,0 +1,23 @@
+import { useState } from 'react';
+import PageContainer from '../page-container';
+import config from '../../../config';
+import MenuHandler from './menu-handler';
+
+function Doctor({user, setUser}) {
+ const [page, setPage] = useState("home");
+ const links = [
+ {page:"home",name:"Accueil"},
+ {page:"appointment",name:"Rendez-vous"},
+ config.prescriptionOn ? {page:"prescription",name:"Préscriptions"} : null,
+ {page:"medical-file",name:"Dossier Médical"},
+ {page:"profil",name:"Profil"}
+ ];
+
+ return (
+
+
+
+ )
+}
+
+export default Doctor;
\ No newline at end of file
diff --git a/src/components/dashboard/doctor/menu-handler/index.jsx b/src/components/dashboard/doctor/menu-handler/index.jsx
new file mode 100644
index 0000000..ba73c50
--- /dev/null
+++ b/src/components/dashboard/doctor/menu-handler/index.jsx
@@ -0,0 +1,10 @@
+function MenuHandler({page, setPage, user}) {
+ return (
+
+
MenuHandler
+
Current page: {page}
+
+ )
+}
+
+export default MenuHandler;
\ No newline at end of file
diff --git a/src/components/dashboard/home/index.jsx b/src/components/dashboard/home/index.jsx
index 341cf85..f886396 100644
--- a/src/components/dashboard/home/index.jsx
+++ b/src/components/dashboard/home/index.jsx
@@ -2,7 +2,7 @@ import HeadTitle from "../head-title"
function Home() {
return(
-
+
)
diff --git a/src/components/dashboard/index.jsx b/src/components/dashboard/index.jsx
index b94e8ed..b5793b4 100644
--- a/src/components/dashboard/index.jsx
+++ b/src/components/dashboard/index.jsx
@@ -1,17 +1,102 @@
-import Navbarre from "./navbarre";
-import Layout from "./layout";
import PageHandler from "./page-handler";
-import { useState } from "react";
+import { useState, useEffect } from "react";
+import { getUserSession, setUserSession } from "../../modules/userManager";
+import { get } from "../../modules/fetchManager";
+import TypeUser from "./type-user";
+import Loader from "./loader";
+import SecondMenuBg from "./second-menu-bg";
+import NotVerified from "./notVerified";
function Dashboard() {
- const [page, setPage] = useState("home");
+ const [user, setUser] = useState(getUserSession());
+ const [type, setType] = useState((user.roles) ? true : false);
+ const [loading, setLoading] = useState(0);
+
+ // useEffect(() => {
+ // setUserSession(user);
+ // }, [user]);
+
+ if(!user.token || !user.data){
+ window.location.href = '/login';
+ }
+
+ if(!type && loading === 0){
+ get('users/@me/roles', user.token).then((data) => {
+
+ setLoading(loading + 1);
+
+ if(data.status === 403) {
+ window.location.href = '/login';
+ return;
+ }
+
+ if(data.status === 404) {
+ setType(false);
+ get('doctors/@me', user.token).then((data) => {
+ setLoading(loading + 1);
+
+ if(data.status >= 400) {
+ return;
+ }
+
+ const newUser = {
+ token: user.token,
+ data: user.data,
+ roles: user.roles,
+ doctor: data.JSON,
+ };
+
+ setUser(newUser);
+ setUserSession(newUser);
+ setType(true);
+ });
+ return;
+ }
+
+ const newUser = {
+ token: user.token,
+ data: user.data,
+ roles: data.JSON,
+ };
+
+ setUser(newUser);
+ setUserSession(newUser);
+ setType(true);
+ });
+
+ // console.log(type);
+ }
return(
-
-
-
-
+ {
+ type && (!user.doctor || user.doctor.is_verified) ?
+
+ :
+ null
+ }
+ {
+ type && user.doctor && !user.doctor.is_verified ?
+
+ :
+ null
+ }
+ {
+ !type && loading < 2 ?
+
+
+
+ :
+ null
+ }
+ {
+ !type && loading === 2 ?
+
+
+
+ :
+ null
+ }
);
}
diff --git a/src/components/dashboard/list-display/index.jsx b/src/components/dashboard/list-display/index.jsx
new file mode 100644
index 0000000..20e4cd2
--- /dev/null
+++ b/src/components/dashboard/list-display/index.jsx
@@ -0,0 +1,18 @@
+function ListDisplay({data,itemComponent,setCreateMenu,nameMenu}) {
+ return(
+
+
+
+ {
+ data.map((item) => {
+ -
+ {itemComponent(item)}
+
+ })
+ }
+
+
+ )
+}
+
+export default ListDisplay;
\ No newline at end of file
diff --git a/src/components/dashboard/loader/index.jsx b/src/components/dashboard/loader/index.jsx
new file mode 100644
index 0000000..6c6cfed
--- /dev/null
+++ b/src/components/dashboard/loader/index.jsx
@@ -0,0 +1,15 @@
+import './loader.css';
+import SecondMenuBg from '../second-menu-bg';
+
+function Loader({color}) {
+ let cssColor = 'loader'
+ if(color) {
+ cssColor += ' cyan';
+ }
+
+ return(
+
+ );
+}
+
+export default Loader;
\ No newline at end of file
diff --git a/src/components/dashboard/loader/loader.css b/src/components/dashboard/loader/loader.css
new file mode 100644
index 0000000..9d29eb0
--- /dev/null
+++ b/src/components/dashboard/loader/loader.css
@@ -0,0 +1,24 @@
+.loader {
+ width: 48px;
+ height: 48px;
+ border: 5px solid #FFF;
+ border-bottom-color: transparent;
+ border-radius: 50%;
+ display: inline-block;
+ box-sizing: border-box;
+ animation: rotation 1s linear infinite;
+}
+
+.cyan {
+ border: 5px solid rgb(22,78,99);
+ border-bottom-color: transparent;
+}
+
+@keyframes rotation {
+ 0% {
+ transform: rotate(0deg);
+ }
+ 100% {
+ transform: rotate(360deg);
+ }
+}
\ No newline at end of file
diff --git a/src/components/dashboard/modal-container/index.jsx b/src/components/dashboard/modal-container/index.jsx
new file mode 100644
index 0000000..b39f755
--- /dev/null
+++ b/src/components/dashboard/modal-container/index.jsx
@@ -0,0 +1,11 @@
+function ModalContainer({ children }) {
+ return (
+
+ );
+}
+
+export default ModalContainer;
\ No newline at end of file
diff --git a/src/components/dashboard/navbarre/hero/index.jsx b/src/components/dashboard/navbarre/hero/index.jsx
new file mode 100644
index 0000000..05d2d11
--- /dev/null
+++ b/src/components/dashboard/navbarre/hero/index.jsx
@@ -0,0 +1,12 @@
+function Hero({user}) {
+ return(
+
+
+
+
{user.data.first_name + " " + user.data.last_name}
+
+
+ )
+}
+
+export default Hero;
\ No newline at end of file
diff --git a/src/components/dashboard/navbarre/index.jsx b/src/components/dashboard/navbarre/index.jsx
index e53cfa6..f430b3a 100644
--- a/src/components/dashboard/navbarre/index.jsx
+++ b/src/components/dashboard/navbarre/index.jsx
@@ -1,45 +1,22 @@
-function Navbarre({setPage}) {
+import Hero from "./hero";
+import LinkMenu from "./link-menu";
+import { removeUserSession } from "../../../modules/userManager";
+
+function Navbarre({setPage, user, setUser, links}) {
+
const handleClick = (e) => {
- // e.preventDefault();
- setPage(e.target.getAttribute("id"));
- };
+ e.preventDefault();
+ setUser(null);
+ removeUserSession();
+ window.location.href = '/';
+ }
return (