diff --git a/src/app/dashboard/(user-dashboard)/settings/organization/roles-and-permissions/page.tsx b/src/app/dashboard/(user-dashboard)/settings/organization/roles-and-permissions/page.tsx index db4d38750..830c1018f 100644 --- a/src/app/dashboard/(user-dashboard)/settings/organization/roles-and-permissions/page.tsx +++ b/src/app/dashboard/(user-dashboard)/settings/organization/roles-and-permissions/page.tsx @@ -1,5 +1,185 @@ -const page = () => { - return
page
; +"use client"; + +import { useState } from "react"; + +import CustomButton from "~/components/common/common-button/common-button"; +import RoleCreationModal from "~/components/common/modals/role-creation"; + +type Role = { + id: number; + name: string; + description: string; +}; + +type Permission = { + name: string; + enabled: boolean; +}; + +const rolesData: Role[] = [ + { id: 1, name: "Guest", description: "Read-only access" }, + { id: 2, name: "User", description: "Read, write, update" }, + { id: 3, name: "Manager", description: "Read, write, approve" }, + { id: 4, name: "Project Lead", description: "Manage, coordinate, oversee" }, + { id: 5, name: "Administrator", description: "Full access, control" }, +]; + +const permissionsData: { [key: number]: Permission[] } = { + 1: [ + { name: "Can view transactions", enabled: true }, + { name: "Can view refunds", enabled: false }, + { name: "Can log refunds", enabled: true }, + ], + 2: [ + { name: "Can view users", enabled: true }, + { name: "Can create users", enabled: false }, + { name: "Can edit users", enabled: true }, + { name: "Can blacklist/whitelist users", enabled: true }, + ], + 3: [ + { name: "Can view users", enabled: true }, + { name: "Can create users", enabled: true }, + { name: "Can edit users", enabled: false }, + { name: "Can blacklist/whitelist users", enabled: true }, + ], + 4: [ + { name: "Can view transactions", enabled: true }, + { name: "Can view refunds", enabled: true }, + { name: "Can log refunds", enabled: true }, + { name: "Can view users", enabled: true }, + { name: "Can create users", enabled: true }, + { name: "Can edit users", enabled: true }, + { name: "Can blacklist/whitelist users", enabled: true }, + ], + 5: [ + { name: "Can view transactions", enabled: true }, + { name: "Can view refunds", enabled: true }, + { name: "Can log refunds", enabled: true }, + { name: "Can view users", enabled: true }, + { name: "Can create users", enabled: true }, + { name: "Can edit users", enabled: true }, + { name: "Can blacklist/whitelist users", enabled: true }, + ], +}; + +const RolesAndPermission = () => { + const [selectedRoleId, setSelectedRoleId] = useState(); + const [permissions, setPermissions] = useState([]); + const [isModalOpen, setIsModalOpen] = useState(false); + + const handleRoleClick = (roleId: number) => { + setSelectedRoleId(roleId); + setPermissions([...permissionsData[roleId]]); + }; + + const handleToggle = (index: number) => { + setPermissions((previous) => { + const newPermissions = [...previous]; + newPermissions[index].enabled = !newPermissions[index].enabled; + permissionsData[selectedRoleId!] = newPermissions; + return newPermissions; + }); + }; + + const handleModalOpen = () => { + setIsModalOpen(true); + }; + + const handleModalClose = () => { + setIsModalOpen(false); + }; + + return ( +
+
+
+

Roles

+
    + {rolesData.map((role) => ( +
  • handleRoleClick(role.id)} + > +
    {role.name}
    +
    + {role.description} +
    +
  • + ))} +
+
+
+
+ + + Create roles + +
+
+
+

+ Permissions +

+

+ See the list of permissions for this role +

+
+ {selectedRoleId === undefined ? ( +
+

+ No list to show +

+

+ Click on a role to view permissions +

+
+ ) : ( +
+

+ Transactions Permission +

+ {permissions.map((permission, index) => ( +
+ + {permission.name} + + +
+ ))} +
+ +
+
+ )} +
+
+
+ +
+ ); }; -export default page; +export default RolesAndPermission; diff --git a/src/components/common/modals/role-creation/index.tsx b/src/components/common/modals/role-creation/index.tsx new file mode 100644 index 000000000..2759b6bdd --- /dev/null +++ b/src/components/common/modals/role-creation/index.tsx @@ -0,0 +1,65 @@ +"use client"; + +import CustomButton from "~/components/common/common-button/common-button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from "~/components/ui/dialog"; + +interface ModalProperties { + show: boolean; + onClose: () => void; +} + +const RoleCreationModal: React.FC = ({ show, onClose }) => { + return ( + <> + + + + +

+ Create Role +

+
+ +

+ Define customized responsibilities for collaborative success. +

+
+ + +
+
+ +