fixed mandate routing
This commit is contained in:
parent
861bec31cb
commit
44283cd5c2
5 changed files with 8 additions and 15 deletions
|
|
@ -189,7 +189,7 @@ export async function fetchMyFeatures(): Promise<FeaturesMyResponse> {
|
|||
if (feature.code === 'chatbot') {
|
||||
console.log('🔍 [DEBUG] featuresApi: Found chatbot feature', {
|
||||
mandateId: mandate.id,
|
||||
mandateName: mandate.name,
|
||||
mandateName: mandate.label || mandate.name,
|
||||
featureCode: feature.code,
|
||||
instanceCount: feature.instances.length,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -235,23 +235,16 @@ export function useUserMandates() {
|
|||
*/
|
||||
const fetchRoles = useCallback(async (mandateId?: string): Promise<Role[]> => {
|
||||
try {
|
||||
const response = await api.get('/api/rbac/roles');
|
||||
// Fetch roles server-side filtered by mandate (or templates if no mandateId)
|
||||
const params = mandateId ? { mandateId } : {};
|
||||
const response = await api.get('/api/rbac/roles', { params });
|
||||
let roles: Role[] = [];
|
||||
if (response.data?.items && Array.isArray(response.data.items)) {
|
||||
roles = response.data.items;
|
||||
} else if (Array.isArray(response.data)) {
|
||||
roles = response.data;
|
||||
}
|
||||
|
||||
// Only mandate-instance roles (mandateId matches, no featureInstanceId)
|
||||
// Global templates (mandateId=null) are NOT assignable to users
|
||||
if (mandateId) {
|
||||
return roles.filter(r =>
|
||||
!r.featureInstanceId && r.mandateId === mandateId
|
||||
);
|
||||
}
|
||||
// Without mandateId, no roles available (roles are always mandate-specific)
|
||||
return [];
|
||||
return roles;
|
||||
} catch (err: any) {
|
||||
console.error('Error fetching roles:', err);
|
||||
return [];
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ export const AdminMandateRolePermissionsPage: React.FC = () => {
|
|||
>
|
||||
{mandates.map(mandate => (
|
||||
<option key={mandate.id} value={mandate.id}>
|
||||
{getTextValue(mandate.name)}
|
||||
{mandate.label || getTextValue(mandate.name)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ export const AdminUserAccessOverviewPage: React.FC = () => {
|
|||
>
|
||||
<div className={styles.roleInfo}>
|
||||
{expandedMandates.has(mandate.id) ? <FaChevronDown className={styles.expandIcon} /> : <FaChevronRight className={styles.expandIcon} />}
|
||||
<span className={styles.roleLabel}>{mandate.name}</span>
|
||||
<span className={styles.roleLabel}>{mandate.label || mandate.name}</span>
|
||||
<span className={styles.roleDescription}>
|
||||
{mandate.featureInstances.length} Feature-Instanz(en)
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const MandateSelector: React.FC<MandateSelectorProps> = ({ selectedMandateId, on
|
|||
<option value="">-- Mandant wählen --</option>
|
||||
{mandates.map((mandate) => (
|
||||
<option key={mandate.id} value={mandate.id}>
|
||||
{mandate.name || mandate.id}
|
||||
{mandate.label || mandate.name || mandate.id}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in a new issue