Merge branch 'MAILWEB-6058-group-notification-on-windows' into 'main'
[ProtonMail-WebClient.git] / packages / account / inactiveKeys / hooks.ts
blob60378c41300658ce18bc3fed908a61a546ec1fef
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(
14     [
15         (state: InactiveKeysState) => selectInactiveKeys(state),
16         (state: UserState) => selectUser(state).value,
17         (state: AddressesState) => selectAddresses(state).value,
18     ],
19     (inactiveKeys, user, addresses): Result => {
20         return getAllKeysReactivationRequests({ addresses, user, inactiveKeys });
21     }
24 export const useInactiveKeys = () => {
25     return baseUseSelector<InactiveKeysState & UserState & AddressesState, Result>(selector);