Skip to content

Commit

Permalink
trivial: disable add user link correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcosta committed Sep 15, 2024
1 parent d3f1eff commit 8c68479
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apps/web/src/pages/workspaces/[workspaceId]/users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { UserWorkspaceRole } from '@briefer/database'
import clsx from 'clsx'
import { Tooltip } from '@/components/Tooltips'
import { PasswordDialog } from './new'
import { useRouter } from 'next/router'

const pagePath = (workspaceId: string) => [
{ name: 'Configurations', icon: Cog8ToothIcon, href: '#', current: false },
Expand All @@ -26,6 +27,7 @@ const pagePath = (workspaceId: string) => [
export default function UsersPage() {
const workspaceId = useStringQuery('workspaceId')
const session = useSession()
const router = useRouter()

const isAdmin = session.data?.roles[workspaceId] === UserWorkspaceRole.admin

Expand Down Expand Up @@ -79,8 +81,11 @@ export default function UsersPage() {
position="left"
active={!isAddEnabled}
>
<Link
href={`/workspaces/${workspaceId}/users/new`}
<button
onClick={() => {
router.push(`/workspaces/${workspaceId}/users/new`)
}}
disabled={!isAddEnabled}
className={clsx(
isAddEnabled
? 'bg-primary-200 hover:bg-primary-300'
Expand All @@ -89,7 +94,7 @@ export default function UsersPage() {
)}
>
<UserPlusIcon className="h-4 w-4" /> Add user
</Link>
</button>
</Tooltip>
</div>

Expand Down

0 comments on commit 8c68479

Please sign in to comment.