1 import { createSelector } from '@reduxjs/toolkit';
3 import { LockMode } from '@proton/pass/lib/auth/lock/types';
4 import type { OrganizationState } from '@proton/pass/store/reducers/organization';
5 import type { State } from '@proton/pass/store/types';
6 import type { MaybeNull } from '@proton/pass/types';
7 import type { OrganizationSettings } from '@proton/pass/types/data/organization';
8 import type { Organization } from '@proton/shared/lib/interfaces';
10 import { selectLockMode } from './settings';
12 export const selectOrganizationState = ({ organization }: State): MaybeNull<OrganizationState> => organization;
14 export const selectOrganization = ({ organization }: State): MaybeNull<Organization> =>
15 organization?.organization ?? null;
17 export const selectOrganizationSettings = ({ organization }: State): MaybeNull<OrganizationSettings> =>
18 organization?.settings ?? null;
20 export const selectCanUpdateOrganization = ({ organization }: State): boolean => organization?.canUpdate ?? false;
22 export const selectLockSetupRequired = createSelector(
23 [selectOrganizationSettings, selectLockMode],
24 (orgSettings, lockMode) =>
25 Boolean(orgSettings?.ForceLockSeconds && orgSettings.ForceLockSeconds > 0 && lockMode === LockMode.NONE)