-
-
Liste des habilitations
- {isLoading &&
}
- {!isLoading && <> {(!isArray(privileges) || privileges?.length === 0)
- ?
-
Pas encore des habilitations
+ <>
+
+
+
+
+
Liste des habilitations
+
- :
-
-
- | Habilitation |
- Action |
-
- {privileges.map((element) => {
- return
- })}
-
-
- }>}
-
+ {isLoading &&
}
+ {!isLoading && <> {(!isArray(privileges) || privileges?.length === 0)
+ ?
+
Aucune habilitation n'a été trouvée.
+
+ :
+
+
+ | Habilitation |
+ Actions |
+
+ {(isCreating) && setIsCreating(false)} appendPrivilege={appendPrivilege} />}
+ {privileges?.map((element) => {
+ return
+ })}
+
+
+ }>}
+
+ >
)
}
diff --git a/src/app/(dashboard)/reporting/page.jsx b/src/app/(dashboard)/reporting/page.jsx
index 47058e4bce01ba403b2a2878ac147e39372cbd40..22ca155804efd376b20ae37d7647109bf5bbcd82 100644
--- a/src/app/(dashboard)/reporting/page.jsx
+++ b/src/app/(dashboard)/reporting/page.jsx
@@ -18,14 +18,14 @@ const Reporting = () => {
const [chartDataProject, setChartDataProject] = useState(null)
const [isLoadingZone, setIsLoadingZone] = useState(false)
const [isLoadingProject, setIsLoadingProject] = useState(false)
- const [ countUsers, setCountUsers ] = useState(0)
- const [ countProjects, setCountProjects ] = useState(0)
- const [ countPlaces, setCountPlaces ] = useState(0)
+ const [countUsers, setCountUsers] = useState(0)
+ const [countProjects, setCountProjects] = useState(0)
+ const [countPlaces, setCountPlaces] = useState(0)
const { toggleNotification } = useNotification()
const [dates, setDates] = useState({ fromDate: extractDate(subtractDays(new Date(), 4)), toDate: extractDate(new Date()) })
useEffect(() => {
- const getStats= async () => {
+ const getStats = async () => {
const { data, errors, isSuccess } = await fetchRequest(`/statistics/`, {
method: "GET",
})
@@ -146,15 +146,15 @@ const Reporting = () => {
}))
}, [chartDataZone, axisX])
return (
-
-
+
+
@@ -163,8 +163,8 @@ const Reporting = () => {
@@ -173,8 +173,8 @@ const Reporting = () => {
@@ -192,7 +192,7 @@ const Reporting = () => {
{(isLoadingZone || isLoadingProject) ?
-
:
+
:
}
diff --git a/src/app/(dashboard)/role/RoleTableRows.jsx b/src/app/(dashboard)/role/RoleTableRows.jsx
index ccdcad936b6b9f077fc3ac86eb584d85d919d691..a834a619b496ff0e7f107bf50c6205e35e7a6826 100644
--- a/src/app/(dashboard)/role/RoleTableRows.jsx
+++ b/src/app/(dashboard)/role/RoleTableRows.jsx
@@ -1,7 +1,7 @@
import React, { useState } from 'react'
import fetchRequest from '@/app/lib/fetchRequest'
-import DeleteIcon from "@/static/image/svg/delete.svg"
-import EditIcon from "@/static/image/svg/edit.svg"
+import DeleteIcon from "@/static/image/svg/trash-bold.svg"
+import EditIcon from "@/static/image/svg/edit-bold.svg"
import { useNotification } from '@/context/NotificationContext'
import ConfirmationModal from '@/app/ui/ConfirmationModal'
@@ -48,29 +48,29 @@ const RoleTableRows = ({ name, setRoles, id, privileges, setRoleToUpdate }) => {
return (
<>
-
- |
- {name}
+ |
+ |
+ {name}
|
-
-
+
+
{privileges?.map((element, index) => {
- return {element.name}
+ return {element.name}
})}
- {!privileges || privileges.length == 0 && - }
+ {!privileges || privileges.length == 0 && Habilitations non accordées à ce rôle }
|
-
-
- | |
+
setModalOpen(false)}
diff --git a/src/app/(dashboard)/role/RolesFilter.jsx b/src/app/(dashboard)/role/RolesFilter.jsx
new file mode 100644
index 0000000000000000000000000000000000000000..25fc2cdb4fc812581f4ba9188a88e559155d4658
--- /dev/null
+++ b/src/app/(dashboard)/role/RolesFilter.jsx
@@ -0,0 +1,89 @@
+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 RolesFilter = memo(function Page({ setFilter, filter }) {
+ const [privileges, setPrivileges] = useState([])
+ const handleChangeRoleName = (event) => {
+ const value = event.target.value
+ setFilter({ ...filter, "role": value })
+ }
+ const handleResetFilters = () => {
+ setFilter({ "role": "", "privileges": [] })
+ }
+
+ const handlePrivilegesChange = (selectedOptions) => {
+ setFilter({ ...filter, privileges: selectedOptions })
+ }
+ useEffect(() => {
+ const getPrivileges = async () => {
+ const { data, errors, isSuccess } = await fetchRequest(`/privileges`)
+ if (isSuccess) {
+ setPrivileges(data)
+ } else {
+ console.log(errors)
+ }
+ }
+ getPrivileges()
+ }, [])
+ return (
+
+
Recherche
+
+
+
+
+
+
+
+
+
+
+
+ )
+})
+
+export default RolesFilter
\ No newline at end of file
diff --git a/src/app/(dashboard)/role/page.jsx b/src/app/(dashboard)/role/page.jsx
index dfca5e0015cdcda426b78d1e4bf8375ba0de8701..ef605d2fcec0715882d3950f05286bb9e117af89 100644
--- a/src/app/(dashboard)/role/page.jsx
+++ b/src/app/(dashboard)/role/page.jsx
@@ -8,15 +8,19 @@ import { isArray } from '../../lib/TypesHelper'
import AddIcon from "@/static/image/svg/add.svg"
import UpdateRoleForm from './UpdateRoleForm'
import { useNotification } from '@/context/NotificationContext'
+import SubSideBar from '@/app/ui/SubSideBar'
+import RolesFilter from "./RolesFilter"
const Role = () => {
const [roles, setRoles] = useState([])
const [isLoading, setIsLoading] = useState(true)
const [openCreatePopup, setOpenCreatePopup] = useState(null)
const [roleToUpdate, setRoleToUpdate] = useState(null)
const { toggleNotification } = useNotification()
+ const [filter, setFilter] = useState({ role: "", privileges: [] });
useEffect(() => {
const getRoles = async () => {
- const { data, errors, isSuccess } = await fetchRequest("/roles")
+ const privilegesIdsString = filter.privileges.map((element) => element.value).toString()
+ const { data, errors, isSuccess } = await fetchRequest(`/roles/?role_name=${filter.role}&privilege_ids=${privilegesIdsString}`)
setIsLoading(false)
if (isSuccess) {
console.log(data)
@@ -31,40 +35,46 @@ const Role = () => {
}
}
getRoles()
- }, [])
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [filter.role, filter.privileges])
const appendRole = (newRole) => {
setRoles([newRole, ...roles])
}
+ const subLinks = [{ label: "Utilisateurs", link: "/user" }, { label: "Rôles", link: "/role" }, { label: "Habilitations", link: "/privilege" }, { label: "Projets", link: "/projects" }]
return (
-
- {openCreatePopup &&
}
- {roleToUpdate &&
}
-
-
Liste des Rôles
-
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">
-
- Rôle
-
-
- {isLoading &&
}
- {!isLoading && <> {(!isArray(roles) || roles?.length === 0)
- ?
- :
-
-
- | Rôle |
- Habilitations |
- Action |
-
- {roles?.map((element) => {
- return
- })}
-
+ <>
+
+
+
+ {openCreatePopup &&
}
+ {roleToUpdate &&
}
+
+
Liste des Rôles
+
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">
+
+ Rôle
+
- }>}
-
+ {isLoading &&
}
+ {!isLoading && <> {(!isArray(roles) || roles?.length === 0)
+ ?
+
Aucun rôle n'a été trouvé.
+
+ :
+
+
+ | Rôle |
+ Habilitations |
+ Actions |
+
+ {roles?.map((element) => {
+ return
+ })}
+
+
+ }>}
+
+ >
)
}
diff --git a/src/app/(dashboard)/user/UserTableRow.jsx b/src/app/(dashboard)/user/UserTableRow.jsx
index 279a0a794d103601b4eece9af34665ca4c70b7c4..0907f00a4741a7e89736ca2741c5f89f448a0171 100644
--- a/src/app/(dashboard)/user/UserTableRow.jsx
+++ b/src/app/(dashboard)/user/UserTableRow.jsx
@@ -67,12 +67,12 @@ const UserTableRow = ({ email, last_name, first_name, id, setUsers, role, projec
})}
-
-
- 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..ac52b93c9d7a9528a8a5e086f6f606b7389c7949 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..726ea0d09011af2575115c7f413516a8e64ed851 100644
--- a/src/app/(dashboard)/user/page.jsx
+++ b/src/app/(dashboard)/user/page.jsx
@@ -56,7 +56,7 @@ const UserPage = () => {
return (
<>
-
+
{openCreatePopup && }
{userToUpdate && }
@@ -70,7 +70,7 @@ const UserPage = () => {
{(isLoading) &&
}
{(!isLoading) && <> {(!isArray(users) || users?.length === 0)
?
- Pas encore des utilisateurs
+ Aucun utilisateurs n'a été trouvé
:
diff --git a/src/app/ui/SideBar.jsx b/src/app/ui/SideBar.jsx
index ba45eace93b079bae81c0cc00950bb4f78bf2e04..9534806d9808a1d0db05a1856afa3d0b3ec8b084 100644
--- a/src/app/ui/SideBar.jsx
+++ b/src/app/ui/SideBar.jsx
@@ -4,7 +4,7 @@ import RoleIcon from "@/static/image/svg/role.svg"
import UserIcon from "@/static/image/svg/user.svg"
import LogoutButton from "./LogoutButton";
import isAuthenticated from "@/app/lib/isAuthenticated";
-import {useEffect, useState} from "react";
+import { useEffect, useState } from "react";
import { usePathname } from "next/navigation";
import './SideBar.css';
@@ -26,7 +26,7 @@ const SideBar = () => {
if (!isAuth || !sessionData) {
return (
| |