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') {
|
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,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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 [];
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue