1 import { createSelector } from '@reduxjs/toolkit';
3 import type { InviteState } from '@proton/pass/store/reducers';
4 import type { State } from '@proton/pass/store/types';
5 import type { Invite, Maybe, MaybeNull } from '@proton/pass/types';
6 import { first } from '@proton/pass/utils/array/first';
7 import { sortOn } from '@proton/pass/utils/fp/sort';
9 export const selectInvites = (state: State): InviteState => state.invites;
11 export const selectInviteByToken =
13 (state: State): Maybe<Invite> =>
16 export const selectMostRecentInvite = createSelector(
18 (invites): MaybeNull<Invite> => first(Object.values(invites).sort(sortOn('createTime', 'DESC'))) ?? null