fix: close permission review gaps

This commit is contained in:
2026-07-23 12:23:33 +08:00
parent c98d37307e
commit f39136d9ce
10 changed files with 116 additions and 92 deletions

View File

@@ -1401,9 +1401,12 @@ const StudentProfileContent: React.FC<StudentProfileContentProps> = ({
onClose,
}) => {
const { hasPermission, hasAnyPermission } = usePermission();
const canViewOrganizations = hasPermission('organization:view');
const canChooseOrganization =
canViewOrganizations && hasAnyPermission('student:create', 'student:edit');
const canLoadOrganizations = hasAnyPermission(
'organization:view',
'student:create',
'student:edit',
);
const canChooseOrganization = hasAnyPermission('student:create', 'student:edit');
const [aggregateData, setAggregateData] = useState<StudentProfileAggregate | null>(null);
const [organizations, setOrganizations] = useState<Array<{ id: number; name: string }>>([]);
const [loading, setLoading] = useState(false);
@@ -1426,7 +1429,7 @@ const StudentProfileContent: React.FC<StudentProfileContentProps> = ({
}, [fetchData]);
useEffect(() => {
if (!canViewOrganizations) {
if (!canLoadOrganizations) {
setOrganizations([]);
return;
}
@@ -1436,7 +1439,7 @@ const StudentProfileContent: React.FC<StudentProfileContentProps> = ({
setOrganizations(res as Array<{ id: number; name: string }>);
})
.catch(() => {});
}, [canViewOrganizations]);
}, [canLoadOrganizations]);
const handlePreviewReport = useCallback(async () => {
try {