fix(persoenliche-ausruestung): wait for permissions before fetching overview to show all items
This commit is contained in:
@@ -27,7 +27,7 @@ import type { ZustandOption } from '../types/personalEquipment.types';
|
||||
|
||||
function PersoenlicheAusruestungPage() {
|
||||
const navigate = useNavigate();
|
||||
const { hasPermission } = usePermissionContext();
|
||||
const { hasPermission, isLoading: permissionsLoading } = usePermissionContext();
|
||||
|
||||
const canViewAll = hasPermission('persoenliche_ausruestung:view_all');
|
||||
const canCreate = hasPermission('persoenliche_ausruestung:create');
|
||||
@@ -41,9 +41,10 @@ function PersoenlicheAusruestungPage() {
|
||||
|
||||
// Data queries
|
||||
const { data: items, isLoading } = useQuery({
|
||||
queryKey: ['persoenliche-ausruestung', 'all'],
|
||||
queryKey: ['persoenliche-ausruestung', canSeeAll ? 'all' : 'my'],
|
||||
queryFn: () => canSeeAll ? personalEquipmentApi.getAll() : personalEquipmentApi.getMy(),
|
||||
staleTime: 2 * 60 * 1000,
|
||||
enabled: !permissionsLoading,
|
||||
});
|
||||
|
||||
const { data: zustandOptions = [] } = useQuery<ZustandOption[]>({
|
||||
|
||||
Reference in New Issue
Block a user