1 import { createSelector } from '@reduxjs/toolkit';
3 import { baseUseSelector } from '@proton/react-redux-store';
4 import { KeyReactivationRequest } from '@proton/shared/lib/keys';
5 import { getAllKeysReactivationRequests } from '@proton/shared/lib/keys/getInactiveKeys';
7 import { type AddressesState, selectAddresses } from '../addresses';
8 import { type UserState, selectUser } from '../user';
9 import { InactiveKeysState, selectInactiveKeys } from './index';
11 type Result = KeyReactivationRequest[];
13 const selector = createSelector(
15 (state: InactiveKeysState) => selectInactiveKeys(state),
16 (state: UserState) => selectUser(state).value,
17 (state: AddressesState) => selectAddresses(state).value,
19 (inactiveKeys, user, addresses): Result => {
20 return getAllKeysReactivationRequests({ addresses, user, inactiveKeys });
24 export const useInactiveKeys = () => {
25 return baseUseSelector<InactiveKeysState & UserState & AddressesState, Result>(selector);