fixed mandate routing

This commit is contained in:
ValueOn AG 2026-02-10 01:44:28 +01:00
parent 861bec31cb
commit 44283cd5c2
5 changed files with 8 additions and 15 deletions

View file

@ -189,7 +189,7 @@ export async function fetchMyFeatures(): Promise<FeaturesMyResponse> {
if (feature.code === 'chatbot') { if (feature.code === 'chatbot') {
console.log('🔍 [DEBUG] featuresApi: Found chatbot feature', { console.log('🔍 [DEBUG] featuresApi: Found chatbot feature', {
mandateId: mandate.id, mandateId: mandate.id,
mandateName: mandate.name, mandateName: mandate.label || mandate.name,
featureCode: feature.code, featureCode: feature.code,
instanceCount: feature.instances.length, instanceCount: feature.instances.length,
}); });

View file

@ -235,23 +235,16 @@ export function useUserMandates() {
*/ */
const fetchRoles = useCallback(async (mandateId?: string): Promise<Role[]> => { const fetchRoles = useCallback(async (mandateId?: string): Promise<Role[]> => {
try { 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[] = []; let roles: Role[] = [];
if (response.data?.items && Array.isArray(response.data.items)) { if (response.data?.items && Array.isArray(response.data.items)) {
roles = response.data.items; roles = response.data.items;
} else if (Array.isArray(response.data)) { } else if (Array.isArray(response.data)) {
roles = response.data; roles = response.data;
} }
return roles;
// 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 [];
} catch (err: any) { } catch (err: any) {
console.error('Error fetching roles:', err); console.error('Error fetching roles:', err);
return []; return [];

View file

@ -252,7 +252,7 @@ export const AdminMandateRolePermissionsPage: React.FC = () => {
> >
{mandates.map(mandate => ( {mandates.map(mandate => (
<option key={mandate.id} value={mandate.id}> <option key={mandate.id} value={mandate.id}>
{getTextValue(mandate.name)} {mandate.label || getTextValue(mandate.name)}
</option> </option>
))} ))}
</select> </select>

View file

@ -197,7 +197,7 @@ export const AdminUserAccessOverviewPage: React.FC = () => {
> >
<div className={styles.roleInfo}> <div className={styles.roleInfo}>
{expandedMandates.has(mandate.id) ? <FaChevronDown className={styles.expandIcon} /> : <FaChevronRight className={styles.expandIcon} />} {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}> <span className={styles.roleDescription}>
{mandate.featureInstances.length} Feature-Instanz(en) {mandate.featureInstances.length} Feature-Instanz(en)
</span> </span>

View file

@ -36,7 +36,7 @@ const MandateSelector: React.FC<MandateSelectorProps> = ({ selectedMandateId, on
<option value="">-- Mandant wählen --</option> <option value="">-- Mandant wählen --</option>
{mandates.map((mandate) => ( {mandates.map((mandate) => (
<option key={mandate.id} value={mandate.id}> <option key={mandate.id} value={mandate.id}>
{mandate.name || mandate.id} {mandate.label || mandate.name || mandate.id}
</option> </option>
))} ))}
</select> </select>