Skip to content

Commit df9b312

Browse files
committed
feat: add ownership check to PermissionsTable component
- Introduced a new state to track if the user is the organization owner. - Implemented an asynchronous check to determine ownership status based on the active organization ID. - Updated rendering logic to conditionally display permission modification notes based on ownership status.
1 parent 5803e2b commit df9b312

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

components/organization/tabs/MembersTab/PermissionsTable.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export default function PermissionsTable() {
121121
const [isCustom, setIsCustom] = useState(false);
122122
const [canEdit, setCanEdit] = useState(false);
123123
const [isLoading, setIsLoading] = useState(false);
124+
const [userIsOwner, setUserIsOwner] = useState(false);
124125

125126
const {
126127
activeOrgId,
@@ -130,6 +131,17 @@ export default function PermissionsTable() {
130131
isOwner,
131132
} = useOrganization();
132133

134+
// Check if user is owner
135+
useEffect(() => {
136+
const checkOwnership = async () => {
137+
if (activeOrgId) {
138+
const ownerStatus = await isOwner(activeOrgId);
139+
setUserIsOwner(ownerStatus);
140+
}
141+
};
142+
checkOwnership();
143+
}, [activeOrgId, isOwner]);
144+
133145
const loadPermissions = useCallback(async () => {
134146
if (!activeOrgId) return;
135147

@@ -462,7 +474,7 @@ export default function PermissionsTable() {
462474
</TableBody>
463475
</Table>
464476

465-
{!canEdit && isOwner() && (
477+
{!canEdit && userIsOwner && (
466478
<div className='rounded border border-amber-400/20 bg-amber-400/10 p-3 text-xs text-amber-400'>
467479
<strong>Note:</strong> Only organization owners can modify
468480
permissions. You are viewing the permissions but cannot make changes.

0 commit comments

Comments
 (0)