Update selected item color in Pass menu
[ProtonMail-WebClient.git] / packages / pass / store / selectors / alias.ts
blobd33fe155fd12358e2ef3fe7a01d73ac4d98c01cf
1 import { createSelector } from '@reduxjs/toolkit';
3 import type { AliasState } from '@proton/pass/store/reducers';
4 import type { State } from '@proton/pass/store/types';
5 import type { Maybe } from '@proton/pass/types';
6 import type { AliasMailbox } from '@proton/pass/types/data/alias';
8 import { selectAliasItems } from './items';
10 export const selectAliasOptions = ({ alias }: State): AliasState['aliasOptions'] => alias.aliasOptions;
12 export const selectAliasDetails = (aliasEmail: string) =>
13     createSelector([({ alias }: State) => alias], (alias): Maybe<AliasMailbox[]> => alias.aliasDetails?.[aliasEmail]);
15 export const selectAliasByAliasEmail = (aliasEmail: string) =>
16     createSelector([selectAliasItems, () => aliasEmail], (aliasItems, aliasEmail) =>
17         aliasItems.find((item) => item.aliasEmail! === aliasEmail)
18     );