Skip to content

Commit

Permalink
organization settings (#468)
Browse files Browse the repository at this point in the history
* pnpm-lock version update

* organization settings only renders for ADMINs
  • Loading branch information
sreehhari authored Sep 30, 2024
1 parent aba5094 commit 7bb9bfe
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions apps/web-admin/src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useContext } from 'react';
import { useState, useContext, useEffect } from 'react';
import { useAuth0 } from '@auth0/auth0-react';
import {
Box,
Expand Down Expand Up @@ -26,6 +26,9 @@ const Sidebar = ({ isOpen, onClose }) => {
const [loading, setLoading] = useState(false);
const { logout } = useAuth0();
const [isMobile] = useMediaQuery('(max-width: 768px)');
const { accountDetails } = useContext(account);
const isAdmin = accountDetails.role === 'ADMIN';
// const isUser = accountDetails.role === 'USER';

const router = useRouter();
const { orgId } = router.query;
Expand Down Expand Up @@ -61,15 +64,18 @@ const Sidebar = ({ isOpen, onClose }) => {
<SidebarContents />

<Box flex="1"></Box>
<Button
onClick={() => {
router.push(`/${orgId}/settings`);
}}
isLoading={loading}
width="100%"
>
Organization Settings
</Button>
{isAdmin && (
<Button
onClick={() => {
router.push(`/${orgId}/settings`);
}}
isLoading={loading}
width="100%"
>
Organization Settings
</Button>
)}

<Box paddingY={4}>
<Button
onClick={handleLogout}
Expand Down Expand Up @@ -97,15 +103,18 @@ const Sidebar = ({ isOpen, onClose }) => {
<SidebarContents />

<Box flex="1"></Box>
<Button
onClick={() => {
router.push(`/${orgId}/settings`);
}}
isLoading={loading}
width="100%"
>
Organization Settings
</Button>
{isAdmin && (
<Button
onClick={() => {
router.push(`/${orgId}/settings`);
}}
isLoading={loading}
width="100%"
>
Organization Settings
</Button>
)}

<Box paddingY={4}>
<Button
onClick={handleLogout}
Expand Down Expand Up @@ -138,6 +147,7 @@ const SidebarContents = () => {
{ label: 'My Certificates', path: `/${orgId}/mycertificates`, icon: <PiCertificate /> },
{ label: 'Email Settings', path: `/${orgId}/emailsettings`, icon: <MdOutlineEmail /> },
...(isUser ? [{ label: 'Settings', path: `/settings`, icon: <MdOutlineSettings /> }] : []),
// ...(isAdmin ? [{label:'Organizaion Settings',path:'/${orgId}/settings',icon}]: []),
];

return (
Expand Down

0 comments on commit 7bb9bfe

Please sign in to comment.