+
-
- Mandant:
+
+ Mandant / Feature-Instanz:
setSelectedMandateId(e.target.value)}
+ value={selectedCombinedKey}
+ onChange={(e) => setSelectedCombinedKey(e.target.value)}
+ disabled={loading || combinedOptions.length === 0}
>
- -- Mandant wählen --
- {mandates.map(m => (
-
- {getMandateName(m)}
-
- ))}
+ -- Mandant / Feature-Instanz wählen --
+ {/* Group options by mandate */}
+ {(() => {
+ const groupedByMandate: Record = {};
+ combinedOptions.forEach(opt => {
+ if (!groupedByMandate[opt.mandateName]) {
+ groupedByMandate[opt.mandateName] = [];
+ }
+ groupedByMandate[opt.mandateName].push(opt);
+ });
+
+ return Object.entries(groupedByMandate).map(([mandateName, options]) => (
+
+ {options.map(opt => (
+
+ {opt.instanceLabel} ({getFeatureLabel(opt.featureCode)})
+
+ ))}
+
+ ));
+ })()}
-
- {selectedMandateId && (
-
-
-
- Feature-Instanz:
-
- setSelectedInstanceId(e.target.value)}
- disabled={loading || instances.length === 0}
- >
- -- Instanz wählen --
- {instances.map(i => (
-
- {i.label} ({getFeatureLabel(i.featureCode)})
-
- ))}
-
-
- )}
- {selectedInstanceId && (
+ {selectedCombinedKey && (
{
{/* Info box when instance is selected */}
+ {selectedOption && (
+
+
+ Mandant: {selectedOption.mandateName}
+ |
+
+ Instanz: {selectedOption.instanceLabel} ({selectedOption.featureCode})
+
+ )}
+
+ {/* Roles info box */}
{selectedInstance && instanceRoles.length > 0 && (
-
Verfügbare Rollen:
{instanceRoles.map((r, i) => (
@@ -430,21 +487,13 @@ export const AdminFeatureInstanceUsersPage: React.FC = () => {
)}
{/* Content */}
- {!selectedMandateId ? (
-
-
-
Kein Mandant ausgewählt
-
- Wählen Sie einen Mandanten aus, um dessen Feature-Instanzen zu sehen.
-
-
- ) : !selectedInstanceId ? (
+ {!selectedCombinedKey ? (
Keine Feature-Instanz ausgewählt
- {instances.length === 0
- ? 'Dieser Mandant hat noch keine Feature-Instanzen.'
+ {combinedOptions.length === 0
+ ? 'Es gibt noch keine Feature-Instanzen. Erstellen Sie zuerst Feature-Instanzen unter "Feature-Instanzen".'
: 'Wählen Sie eine Feature-Instanz aus, um deren Benutzer zu verwalten.'}
diff --git a/src/pages/admin/AdminFeatureRolesPage.tsx b/src/pages/admin/AdminFeatureRolesPage.tsx
index 3bfa17f..c72fb28 100644
--- a/src/pages/admin/AdminFeatureRolesPage.tsx
+++ b/src/pages/admin/AdminFeatureRolesPage.tsx
@@ -18,10 +18,13 @@ import api from '../../api';
import styles from './Admin.module.css';
interface Feature {
- id: string;
- featureCode: string;
- name: string | { [key: string]: string };
+ id?: string;
+ code: string; // Backend uses 'code' not 'featureCode'
+ featureCode?: string; // Alias for backward compatibility
+ label: string | { [key: string]: string }; // Backend uses 'label' not 'name'
+ name?: string | { [key: string]: string }; // Alias for backward compatibility
description?: string | { [key: string]: string };
+ icon?: string;
}
interface FeatureRole {
@@ -49,13 +52,13 @@ export const AdminFeatureRolesPage: React.FC = () => {
useEffect(() => {
const loadFeatures = async () => {
try {
- const response = await api.get('/api/features');
+ const response = await api.get('/api/features/');
const featureList = response.data?.items || response.data || [];
setFeatures(Array.isArray(featureList) ? featureList : []);
// Auto-select first feature if available
if (featureList.length > 0 && !selectedFeatureCode) {
- setSelectedFeatureCode(featureList[0].featureCode);
+ setSelectedFeatureCode(featureList[0].code || featureList[0].featureCode || '');
}
} catch (err: any) {
console.error('Error loading features:', err);
@@ -235,8 +238,8 @@ export const AdminFeatureRolesPage: React.FC = () => {
setEditingRole(role);
};
- // Get feature name
- const getFeatureName = (feature: Feature) => getTextValue(feature.name);
+ // Get feature name - Backend uses 'label' field
+ const getFeatureName = (feature: Feature) => getTextValue(feature.label || feature.name);
if (error && !selectedFeatureCode) {
return (
@@ -274,11 +277,14 @@ export const AdminFeatureRolesPage: React.FC = () => {
onChange={(e) => setSelectedFeatureCode(e.target.value)}
>
-- Feature wählen --
- {features.map(f => (
-
- {getFeatureName(f)} ({f.featureCode})
-
- ))}
+ {features.map(f => {
+ const featureCode = f.code || f.featureCode || '';
+ return (
+
+ {getFeatureName(f)} ({featureCode})
+
+ );
+ })}