Skip to content

Commit

Permalink
fix device management by admins (#833)
Browse files Browse the repository at this point in the history
* fix device management

* fix formatting

* Update UserDevices.tsx

* format
  • Loading branch information
t-aleksander authored Oct 22, 2024
1 parent 3af2486 commit 1afb5c1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions web/src/pages/users/UserProfile/UserDevices/UserDevices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Skeleton from 'react-loading-skeleton';
import { useNavigate } from 'react-router';

import { useI18nContext } from '../../../../i18n/i18n-react';
import { isUserAdmin } from '../../../../shared/helpers/isUserAdmin';
import { useAppStore } from '../../../../shared/hooks/store/useAppStore';
import { useAuthStore } from '../../../../shared/hooks/store/useAuthStore';
import { useUserProfileStore } from '../../../../shared/hooks/store/useUserProfileStore';
import { useAddDevicePageStore } from '../../../addDevice/hooks/useAddDevicePageStore';
import { AddComponentBox } from '../../shared/components/AddComponentBox/AddComponentBox';
Expand All @@ -21,9 +21,10 @@ export const UserDevices = () => {
const { LL } = useI18nContext();
const userProfile = useUserProfileStore((state) => state.userProfile);
const initAddDevice = useAddDevicePageStore((state) => state.init);
const isAdmin = useAuthStore((state) => state.isAdmin);
const canManageDevices = !!(
userProfile &&
(!settings?.admin_device_management || isUserAdmin(userProfile.user))
(!settings?.admin_device_management || isAdmin)
);

return (
Expand Down

0 comments on commit 1afb5c1

Please sign in to comment.