+
-
+
{projects.length !== 0 ?
@@ -206,11 +205,12 @@ const UpdateUserForm = ({ setUserToUpdate, userToUpdate, setUsers }) => {
:
}
+
-
+
-
+
{roles.length !== 0 ?
@@ -230,9 +230,12 @@ const UpdateUserForm = ({ setUserToUpdate, userToUpdate, setUsers }) => {
}
-
-
-
-
- setUserToUpdate({ email, last_name, first_name, id, role, projects })} className="ml-2 h-9 w-10 flex items-center disabled:cursor-not-allowed justify-center bg-white rounded-md hover:bg-sushi-50 border-2 border-sushi-500 duration-300 group">
+
+
+ setUserToUpdate({ email, last_name, first_name, id, role, projects })} className="flex-none ml-2 h-9 w-10 flex items-center disabled:cursor-not-allowed justify-center bg-white rounded-md hover:bg-sushi-50 border-2 border-sushi-500 duration-300 group">
-
+
diff --git a/src/app/(dashboard)/user/UsersFilter.jsx b/src/app/(dashboard)/user/UsersFilter.jsx
index a2f65f9fdca609edac56658f3d957fb8a0502d80..c284fe734a390def8d4c8830e7d9e9c4f310bc35 100644
--- a/src/app/(dashboard)/user/UsersFilter.jsx
+++ b/src/app/(dashboard)/user/UsersFilter.jsx
@@ -1,40 +1,43 @@
-import React from 'react'
-import SearchIcon from "@/static/image/svg/search.svg"
-const UsersFilter = ({ setFilter }) => {
+import React, { memo } from 'react'
+import ResetIcon from "@/static/image/svg/reset.svg"
+const UsersFilter = memo(function page({ setFilter, filter }) {
const handleChangeFilter = (event) => {
const name = event.target.name
const value = event.target.value
setFilter((filter) => ({ ...filter, [name]: value }))
}
+ const handleResetFilters = () => {
+ setFilter({ first_name: "", last_name: "", email: "", project: "" })
+ }
return (
)
-}
+})
export default UsersFilter
\ No newline at end of file
diff --git a/src/app/(dashboard)/user/page.jsx b/src/app/(dashboard)/user/page.jsx
index 8f5795faa0d9353e48647e70ade6da34957de4c2..d032b245af5e17ad24d2292410924c5cfcf29264 100644
--- a/src/app/(dashboard)/user/page.jsx
+++ b/src/app/(dashboard)/user/page.jsx
@@ -11,7 +11,6 @@ import UserTableRow from './UserTableRow';
import { PAGINATION_SIZE } from '../../lib/constants';
import ArrowRightIcon from "@/static/image/svg/chevron-right.svg"
import ArrowLeftIcon from "@/static/image/svg/chevron-left.svg"
-import SubSideBar from '@/app/ui/SubSideBar';
import UsersFilter from './UsersFilter';
const UserPage = () => {
const [users, setUsers] = useState([])
@@ -52,28 +51,26 @@ const UserPage = () => {
setUsers([newUser, ...users])
}
- const subLinks = [{ label: "Utilisateurs", link: "/user" }, { label: "Rôles", link: "/role" }, { label: "Habilitations", link: "/privilege" }, { label: "Projets", link: "/projects" }]
return (
<>
-
-
-
+
+
{openCreatePopup && }
{userToUpdate && }
Liste des utilisateurs
- setOpenCreatePopup(true)} className="h-9 px-5 disabled:opacity-60 space-x-2 disabled:cursor-not-allowed enabled:hover:-translate-y-1 duration-200 delay-75 enabled:hover:shadow-lg will-change-transform enabled:hover:shadow-sushi-500/70 bg-sushi-500 rounded-md text-white flex items-center justify-center">
+ setOpenCreatePopup(true)} className="text-sm font-medium rounded-md h-9 px-5 disabled:opacity-60 space-x-2 disabled:cursor-not-allowed enabled:hover:-translate-y-1 duration-200 delay-75 enabled:hover:shadow-lg will-change-transform enabled:hover:shadow-sushi-500/70 bg-sushi-500 text-white flex items-center justify-center">
Utilisateur
- {(isLoading) &&
}
+ {(isLoading) &&
}
{(!isLoading) && <> {(!isArray(users) || users?.length === 0)
- ?
- Pas encore des utilisateurs
+ ?
+ Aucun utilisateurs n'a été trouvé
:
-
+
| Prénom |
@@ -89,7 +86,7 @@ const UserPage = () => {
}
>}
-
+
{(paginationData) &&
{(paginationData.currentPage > 1) && getUsers(paginationData.currentPage - 1)} className='flex cursor-pointer hover:bg-neutral-200 duration-150 delay-75 h-8 w-9 items-center justify-center'>
diff --git a/src/app/(dashboard)/zone/CreateZone.jsx b/src/app/(dashboard)/zone/CreateZone.jsx
new file mode 100644
index 0000000000000000000000000000000000000000..6ff7581fb980d01ec068cc0b98ced560cff2e3a0
--- /dev/null
+++ b/src/app/(dashboard)/zone/CreateZone.jsx
@@ -0,0 +1,109 @@
+import Loader from '@/components/Loader/Loader'
+import React, { useState, useRef, useEffect, useMemo } from 'react'
+import fetchRequest from '@/app/lib/fetchRequest'
+import { useNotification } from '@/context/NotificationContext'
+const CreateZone = ({ appendZone, setIsOpen, etages }) => {
+ const [isLoadingAction, setIsLoadingAction] = useState(false)
+ const [selectedEtage, setSelectedEtage] = useState(null)
+ const [nomZone, setNomZone] = useState(null)
+
+ const inputRef = useRef(null)
+ const selectRef = useRef(null)
+ const { toggleNotification } = useNotification()
+
+
+
+
+ const handleSubmit = async (event) => {
+ event.preventDefault()
+ setIsLoadingAction(true)
+ const { data, errors, isSuccess } = await fetchRequest("/zoaning/zones/", {
+ method: "POST",
+ body: JSON.stringify({ nom: nomZone, id_etage: selectedEtage })
+ })
+ if (isSuccess) {
+ setIsLoadingAction(false)
+ appendZone((prevZoneValue) => [...prevZoneValue, { ...data, id_etage: etages.find(etage => etage.id === data.id_etage) }]);
+ inputRef.current.value = ""
+ selectRef.current.value = ""
+ setNomZone(null)
+ setSelectedEtage(null)
+ setIsOpen(false)
+ toggleNotification({
+ visible: true,
+ message: "La zone a été créer avec succès.",
+ type: "success"
+ })
+ } else {
+ setIsLoadingAction(false)
+ if (errors.type === "ValidationError") {
+ if (errors.detail.non_field_errors) {
+ toggleNotification({
+ type: "warning",
+ message: "Le nom de la zone saisie déjà existe.",
+ visible: true,
+ })
+ }
+ } else {
+ setIsOpen(false)
+ toggleNotification({
+ type: "error",
+ message: "Une erreur s'est produite lors de la création de la zone.",
+ visible: true,
+ })
+ }
+ console.log(errors)
+ }
+ }
+
+
+ const handleChangeZone = (event) => {
+ setNomZone(event.target.value)
+ }
+
+ const handleChangeEtage = (event) => {
+ setSelectedEtage(event.target.value)
+ }
+
+ return (
+
+
+ {(etages) ?
+
+ :
+
}
+
+
+ )
+}
+
+export default CreateZone
\ No newline at end of file
diff --git a/src/app/(dashboard)/zone/RowZone.jsx b/src/app/(dashboard)/zone/ZoneTableRow.jsx
similarity index 59%
rename from src/app/(dashboard)/zone/RowZone.jsx
rename to src/app/(dashboard)/zone/ZoneTableRow.jsx
index eac3a4cc6a29bbcbf676e097a3a2cb439d53f9fe..df671e854e3987a880dfac6ba27621b1ac8a3eeb 100644
--- a/src/app/(dashboard)/zone/RowZone.jsx
+++ b/src/app/(dashboard)/zone/ZoneTableRow.jsx
@@ -1,19 +1,15 @@
-"use client"
-import React, { useState, useEffect, useRef } from 'react';
-import fetchRequest from '../../lib/fetchRequest'
-import Loader from '@/components/Loader/Loader'
-import DeleteIcon from "@/static/image/svg/delete.svg"
-import EditIcon from "@/static/image/svg/edit.svg"
-import CancelIcon from "@/static/image/svg/cancel.svg"
+import React, { useState, useRef, useEffect } from 'react'
+import fetchRequest from '@/app/lib/fetchRequest'
+import DeleteIcon from "@/static/image/svg/trash-bold.svg"
+import EditIcon from "@/static/image/svg/edit-bold.svg"
import CheckIcon from "@/static/image/svg/check.svg"
+import CancelIcon from "@/static/image/svg/cancel.svg"
import { useNotification } from '@/context/NotificationContext'
-import ConfirmationModal from "@/app/ui/ConfirmationModal";
-
-
+import ConfirmationModal from '@/app/ui/ConfirmationModal'
+import Loader from '@/components/Loader/Loader'
-const RowZone = ({ id, nom, etage, zonesState, etages }) => {
- //states
+const ZoneTableRow = ({ id, nom, etage, zonesState, etages }) => {
const [isUpdating, setIsUpdating] = useState(false)
const [zoneName, setZoneName] = useState(nom)
const [selectedEtage, setSelectedEtage] = useState(etage)
@@ -175,52 +171,54 @@ const RowZone = ({ id, nom, etage, zonesState, etages }) => {
};
return (
-
- |
- setZoneName(event.target.value)} defaultValue={nom} type='text' className='disabled:bg-white border-0 rounded-md px-2 enabled:drop-shadow border-none enabled:bg-gray-100 duration-100 h-10 outline-none' />
- |
-
- |
+ >
+
)
}
-
-export default RowZone
\ No newline at end of file
+export default ZoneTableRow
\ No newline at end of file
diff --git a/src/app/(dashboard)/zone/ZonesFilter.jsx b/src/app/(dashboard)/zone/ZonesFilter.jsx
new file mode 100644
index 0000000000000000000000000000000000000000..0da9e91a748bdc6c820cacea8d53877e8ce6f965
--- /dev/null
+++ b/src/app/(dashboard)/zone/ZonesFilter.jsx
@@ -0,0 +1,77 @@
+import React, { memo, useEffect, useState } from 'react'
+import ResetIcon from "@/static/image/svg/reset.svg"
+import Select from "react-select";
+import fetchRequest from '@/app/lib/fetchRequest';
+const ZonesFilter = memo(function Page({ setFilter, filter, etages }) {
+ const handleChangeZoneName = (event) => {
+ const value = event.target.value
+ setFilter({ ...filter, "zone": value })
+ }
+ const handleResetFilters = () => {
+ setFilter({ "zone": "", "etages": [] })
+ }
+
+ const handleEtagesChange = (selectedOptions) => {
+ setFilter({ ...filter, etages: selectedOptions })
+ }
+ return (
+
+ Recherche
+
+
+
+
+
+
+
+ ({ label: etage.numero, value: etage.id }))}
+ styles={
+ {
+ menu: (provided) => ({
+ ...provided,
+ maxHeight: '170px',
+ overflowY: 'auto'
+ }),
+ menuList: (provided) => ({
+ ...provided,
+ maxHeight: '170px',
+ overflowY: 'auto'
+ }),
+ control: (provided, state) => ({
+ ...provided,
+ borderColor: state.isFocused ? '#93a84c' : 'rgb(212 212 212)',
+ borderWidth: "1px",
+ boxShadow: 'none',
+ borderRadius: "0.375rem",
+ minHeight: "2.5rem",
+ }),
+ option: (provided, state) => ({
+ ...provided,
+ backgroundColor: state.isFocused ? '#d9e1b5' : 'white',
+ '&:hover': {
+ backgroundColor: '#d9e1b5', // Tailwind's blue-200
+ },
+ }),
+ }
+ }
+ />
+
+
+
+
+ )
+})
+
+export default ZonesFilter
\ No newline at end of file
diff --git a/src/app/(dashboard)/zone/page.jsx b/src/app/(dashboard)/zone/page.jsx
index 67764d39af69c17c3d11625dfab7c44db8bd597e..4585298c78ced256a67c50d99ed063170248dceb 100644
--- a/src/app/(dashboard)/zone/page.jsx
+++ b/src/app/(dashboard)/zone/page.jsx
@@ -1,46 +1,42 @@
-"use client"
-import React from 'react'
-import fetchRequest from '../../lib/fetchRequest'
-import { useState, useEffect, useRef } from 'react';
+'use client'
+import React, { useState, useEffect } from 'react'
+import CreateZone from './CreateZone'
import Loader from '@/components/Loader/Loader'
-import DeleteIcon from "@/static/image/svg/delete.svg"
-import EditIcon from "@/static/image/svg/edit.svg"
-import CancelIcon from "@/static/image/svg/cancel.svg"
-import CheckIcon from "@/static/image/svg/check.svg"
+import ZoneTableRow from './ZoneTableRow'
+import fetchRequest from '@/app/lib/fetchRequest'
import { isArray } from '../../lib/TypesHelper'
-import RowZone from './RowZone'
+import AddIcon from "@/static/image/svg/add.svg"
import { useNotification } from '@/context/NotificationContext'
-
-
+import ZonesFilter from "./ZonesFilter"
const Zone = () => {
const [zones, setZones] = useState([])
- const [isLoadingData, setIsLoadingData] = useState(true)
const [etages, setEtages] = useState([])
- const [error, setError] = useState(null)
- const [isLoadingAction, setIsLoadingAction] = useState(false)
- const [nomZone, setNomZone] = useState(null)
- const [selectedEtage, setSelectedEtage] = useState(null)
-
- const inputRef = useRef(null)
- const selectRef = useRef(null)
-
+ const [isLoading, setIsLoading] = useState(true)
+ const [openCreatePopup, setOpenCreatePopup] = useState(null)
const { toggleNotification } = useNotification()
-
-
- // Fetch data from external API
+ const [filter, setFilter] = useState({ zone: "", etages: [] });
useEffect(() => {
- const getAllZones = async () => {
- try {
- const { isSuccess, errors, data } = await fetchRequest('/zoaning/zones/', { method: 'GET' })
- if (isSuccess) {
- setZones(data)
- } else {
- setZones([])
- }
- } catch (error) {
- console.log(error)
+ const getZones = async () => {
+ const zonesIdsString = filter.etages.map((element) => element.value).toString()
+ const { data, errors, isSuccess } = await fetchRequest(`/zoaning/zones/?zone_name=${filter.zone}&etages_ids=${zonesIdsString}`)
+ setIsLoading(false)
+ if (isSuccess) {
+ console.log(data)
+ setZones(data)
+ } else {
+ console.log(errors)
+ toggleNotification({
+ visible: true,
+ message: "Internal Server Error",
+ type: "error"
+ })
}
}
+ getZones()
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [filter.zone, filter.etages])
+
+ useEffect(() => {
const getAllEtages = async () => {
try {
const { isSuccess, errors, data } = await fetchRequest('/zoaning/etages/', { method: 'GET' })
@@ -53,127 +49,42 @@ const Zone = () => {
console.log(error)
}
}
- getAllZones()
getAllEtages()
- setIsLoadingData(false)
}, [])
- // create zone section
- const handleSubmit = async (event) => {
- event.preventDefault()
- setIsLoadingAction(true)
- const { data, errors, isSuccess } = await fetchRequest("/zoaning/zones/", {
- method: "POST",
- body: JSON.stringify({ nom: nomZone, id_etage: selectedEtage })
- })
- if (isSuccess) {
- setIsLoadingAction(false)
- setZones((prevZoneValue) => [...prevZoneValue, { ...data, id_etage: etages.find(etage => etage.id === data.id_etage) }]);
- inputRef.current.value = ""
- selectRef.current.value = ""
- setNomZone(null)
- setSelectedEtage(null)
- toggleNotification({
- visible: true,
- message: "La zone a été créer avec succès.",
- type: "success"
- })
- } else {
- setIsLoadingAction(false)
- if (errors.type === "ValidationError") {
- if (errors.detail.non_field_errors) {
- toggleNotification({
- type: "warning",
- message: "Le nom de la zone saisie déjà existe.",
- visible: true,
- })
- }
- } else {
- toggleNotification({
- type: "error",
- message: "Une erreur s'est produite lors de la création de la zone.",
- visible: true,
- })
- }
- console.log(errors)
- }
- }
-
- // Handle the name of zone change
- const handleChangeZone = (event) => {
- setError("")
- setNomZone(event.target.value)
- }
-
- const handleChangeEtage = (event) => {
- setError("")
- setSelectedEtage(event.target.value)
- }
-
- console.log(zones)
- console.log(etages)
-
return (
-
-
-
- {!isLoadingData ?
- <>
-
- List des Zones
- {isArray(zones) && zones?.length !== 0 && isArray(etages) && etages?.length !== 0 ?
-
-
-
- | Zone |
- Etage |
- Action |
-
- {(selectedEtage) ?
- zones?.filter(zone => zone.id_etage.id == selectedEtage).map((element) => {return })
- :
- zones?.map((element) => {
- return
- })}
-
-
- :
- }
- >
- :
-
- }
+ <>
+
+
+ {openCreatePopup && }
+
+ Liste des Zones
+ setOpenCreatePopup(true)} className="text-sm font-medium rounded-md h-9 px-5 disabled:opacity-60 space-x-2 disabled:cursor-not-allowed enabled:hover:-translate-y-1 duration-200 delay-75 enabled:hover:shadow-lg will-change-transform enabled:hover:shadow-sushi-500/70 bg-sushi-500 text-white flex items-center justify-center">
+
+ Zone
+
+ {isLoading &&
}
+ {!isLoading && <> {(!isArray(zones) || zones?.length === 0)
+ ?
+ Aucune zone n'a été trouvé.
+
+ :
+
+
+ | Zone |
+ Étages |
+ Actions |
+
+ {zones?.map((element) => {
+ return
+ })}
+
+
+ }>}
-
-
+ >
)
}
diff --git a/src/app/auth/change-password/page.jsx b/src/app/auth/change-password/page.jsx
index 6bc46caa9f1a0aa71d39d43d249f2fb50b0bbafd..235d187eb54de5f548100a684bbd91bbf4e76883 100644
--- a/src/app/auth/change-password/page.jsx
+++ b/src/app/auth/change-password/page.jsx
@@ -2,11 +2,12 @@
import fetchRequest from '@/app/lib/fetchRequest'
import Image from 'next/image'
import Link from 'next/link'
-import React, { useEffect, useState } from 'react'
-import { useSearchParams } from 'next/navigation'
+import React, {useEffect, useState} from 'react'
+import {useSearchParams} from 'next/navigation'
import Loader from '@/components/Loader/Loader'
-import { PASSWORD_REGEX } from '@/app/lib/constants'
-import { useNotification } from '@/context/NotificationContext'
+import {PASSWORD_REGEX} from '@/app/lib/constants'
+import {useNotification} from '@/context/NotificationContext'
+import TeambookVertical from "@/static/image/teambook-vertical.png";
const ChangePassword = () => {
const [isSuccess, setIsSuccess] = useState(false)
@@ -15,11 +16,11 @@ const ChangePassword = () => {
const [confirmPassword, setConfirmPassword] = useState("")
const [isLoading, setIsLoading] = useState(false)
const params = useSearchParams();
- const { toggleNotification } = useNotification()
+ const {toggleNotification} = useNotification()
const handleChangePassword = async (event) => {
event.preventDefault()
setIsLoading(true)
- const { isSuccess, data, errors } = await fetchRequest(`/password_reset/confirm/?token=${params.get("token")}`, {
+ const {isSuccess, data, errors} = await fetchRequest(`/password_reset/confirm/?token=${params.get("token")}`, {
method: "POST",
body: JSON.stringify({
password,
@@ -28,21 +29,18 @@ const ChangePassword = () => {
})
if (isSuccess) {
setIsSuccess(true)
- }
- else {
+ } else {
console.log(errors)
setIsLoading(false)
if (errors.type === "ValidationError") {
if (errors.detail.token) {
setFormErrors(["Le lien que vous avez utilisé pour réinitialiser votre mot de passe est invalide"])
- }
- else {
+ } else {
setFormErrors(["Le Mot de passe est invalide"])
}
} else if (errors?.detail?.detail?.startsWith("The OTP password entered is not valid")) {
setFormErrors(["Le lien que vous avez utilisé pour réinitialiser votre mot de passe est déja utilisé"])
- }
- else {
+ } else {
toggleNotification({
type: "error",
message: "Internal Server Error",
@@ -66,60 +64,61 @@ const ChangePassword = () => {
setFormErrors(currentErrors)
}, [password, confirmPassword])
return (
-
-
-
-
-
-
- {(!isSuccess) &&
- Change your password.
-
-
-
- - Le mot de passe doit contenir au moins 8 caractères
- - Le mot de passe doit contenir au moins un chiffre
- - Le mot de passe doit contenir au moins un caractère spécial
-
+
+
+
+
+ {(!isSuccess) &&
+
+ Changer votre Mot de passe
+
+
+ }
+ {(isSuccess) && (
+
+ The password has been changed!
+ log in
+ again?
-
-
+ )}
+
)
}
diff --git a/src/app/auth/forgot-password/page.jsx b/src/app/auth/forgot-password/page.jsx
index d74d5db9ab4b3f3bd45be27257ce6fead4b790b3..434c4237f9113dcd94ce2b11265a98e151ca0e4a 100644
--- a/src/app/auth/forgot-password/page.jsx
+++ b/src/app/auth/forgot-password/page.jsx
@@ -5,6 +5,8 @@ import { useNotification } from '@/context/NotificationContext'
import Image from 'next/image'
import Link from 'next/link'
import React, { useState } from 'react'
+import TeambookVertical from "@/static/image/teambook-vertical.png";
+import UserIcon from "@/static/image/svg/perm_identity.svg";
const ForgotPassword = () => {
const [email, setEmail] = useState("")
@@ -40,39 +42,31 @@ const ForgotPassword = () => {
}
}
return (
-
-
-
-
- {(!isSuccess) &&
-
- Forgot your password!! No Problem
- Reset it here
+
+
+ {(!isSuccess) &&
+
+ Mot de passe oublié!! Aucun problème
+ Réinitialisez-le ici
-
}
{(isSuccess) &&
- }
-
-
)
}
diff --git a/src/app/auth/layout.jsx b/src/app/auth/layout.jsx
new file mode 100644
index 0000000000000000000000000000000000000000..27b0f05df286f35aa68a77ba58383b0f6aef9cbe
--- /dev/null
+++ b/src/app/auth/layout.jsx
@@ -0,0 +1,48 @@
+import React from "react";
+import Link from "next/link";
+import Image from "next/image";
+import Hero from "@/static/image/pc_phone.png";
+import LineWhite from "@/static/image/svg/line-white4.svg";
+import LineSushi from "@/static/image/svg/line-sushi.svg";
+
+const layout = ({children}) => {
+ return (
+ <>
+
+
+ {children}
+
+
+
+ Aide
+
+
+ Vos questions
+
+
+
+
+
+
+
+
+
+
+
+
+ Teambook 2024 ©
+
+
+ Politique de confidentialité
+
+
+ Termes et conditions
+
+
+
+
+ >
+ )
+}
+
+export default layout
\ No newline at end of file
diff --git a/src/app/auth/login/page.jsx b/src/app/auth/login/page.jsx
index 2bdb9a070baaa5983da96f4d5185e8c7919b7d6e..690dcca62084ba67dd408c19c1d355e0a3bff024 100644
--- a/src/app/auth/login/page.jsx
+++ b/src/app/auth/login/page.jsx
@@ -1,11 +1,15 @@
'use client';
-import { useState } from 'react';
+import {useState} from 'react';
import Link from 'next/link';
import Cookies from 'js-cookie';
-import { createSession } from "@/app/lib/session";
-import { useRouter } from 'next/navigation'
+import {createSession} from "@/app/lib/session";
+import {useRouter} from 'next/navigation'
import Loader from '@/components/Loader/Loader';
+import UserIcon from "@/static/image/svg/perm_identity.svg";
+import VisibilityIcon from "@/static/image/svg/visibility_off.svg";
+import Image from "next/image";
+import TeambookVertical from "@/static/image/teambook-vertical.png";
const LoginPage = () => {
const [username, setUsername] = useState('');
@@ -13,6 +17,11 @@ const LoginPage = () => {
const [messages, setMessages] = useState('');
const [isLoading, setIsLoading] = useState(false)
const router = useRouter();
+ const [isPasswordVisible, setIsPasswordVisible] = useState(false);
+
+ const togglePasswordVisibility = () => {
+ setIsPasswordVisible(!isPasswordVisible);
+ };
const handleSubmit = (event) => {
event.preventDefault();
@@ -31,7 +40,7 @@ const LoginPage = () => {
headers: {
'Content-Type': 'application/json',
},
- body: JSON.stringify({ username, password }),
+ body: JSON.stringify({username, password}),
});
const data = await response.json();
console.log(data)
@@ -40,7 +49,12 @@ const LoginPage = () => {
setMessages("Email ou mot de passe incorrect. Veuillez réessayer.");
} else {
await createSession(data);
- router.push('/');
+ // if role ='super-admin'or 'rh' role redirect to reporting
+ if (data.role === 'super-admin' || data.role === 'rh') {
+ router.push('/reporting')
+ } else {
+ router.push('/reservation');
+ }
}
} catch (error) {
setMessages('An error occurred');
@@ -48,54 +62,63 @@ const LoginPage = () => {
};
return (
<>
- | |