diff --git a/web/src/pages/Admin/RolesGroups/index.tsx b/web/src/pages/Admin/RolesGroups/index.tsx index b867f22..6970113 100644 --- a/web/src/pages/Admin/RolesGroups/index.tsx +++ b/web/src/pages/Admin/RolesGroups/index.tsx @@ -1,10 +1,12 @@ import { useEffect, type FC } from "react"; import Breadcrumbs from "@/components/ui/breadcrumbs"; -import { getRolesApi } from "@/api/admin/roles"; +import { useRoles } from "@/store/admin/rolesGroups"; +import type { AppPermission } from "@/types"; interface DisplayRole { name: string; description: string; + permissions: AppPermission[]; } interface IPermissionGroupProps { @@ -15,32 +17,51 @@ interface IPermissionGroupProps { const RolesGroup: FC = ({ scope, roles }) => { return (
-

- {scope} +

+ {scope.toUpperCase()} (scope)

- {(roles?.length ?? 0) > 0 && ( -
    - {roles!.map(({ name, description }) => ( -
  1. -
    - -

    - {description} -

    -
    -
  2. - ))} -
- )} + {roles?.map((role, index) => ( +
+

+ {role.name.toUpperCase()} (role) +

+ +

+ {role.description} +

+ +
    + {role.permissions.map(({ name, description }) => ( +
  1. +
    + +

    + {description} +

    +
    +
  2. + ))} +
+ + {index + 1 < roles.length && ( +
+ )} +
+ ))}
); }; const AdminRolesGroupsPage: FC = () => { + const roles = useRoles((s) => s.roles); + const fetch = useRoles((s) => s.fetch); + useEffect(() => { - getRolesApi().then((res) => console.log("roles:", res)); - }, []); + fetch(); + }, [fetch]); + + console.log("roles:", roles); return (
@@ -58,7 +79,11 @@ const AdminRolesGroupsPage: FC = () => { ]} />
-
+
+ {Object.keys(roles).map((scope) => ( + + ))} +
); };