Update selected item color in Pass menu
[ProtonMail-WebClient.git] / packages / pass / store / request / selectors.ts
blobb098810399174f589c84ce763fd22bd585a6051d
1 import { createSelector } from '@reduxjs/toolkit';
3 import type { Maybe, MaybeNull } from '@proton/pass/types';
5 import type { RequestEntry, RequestState, RequestStatus } from './types';
7 export const selectRequest =
8     (namespaceOrId: string) =>
9     ({ request }: { request: RequestState }): Maybe<RequestEntry<RequestStatus>> =>
10         request?.[namespaceOrId];
12 export const selectRequestStatus = (namespaceOrId: string) =>
13     createSelector(selectRequest(namespaceOrId), (request) => request?.status);
15 export const selectRequestInFlight = (namespaceOrId: string) =>
16     createSelector(selectRequest(namespaceOrId), (request): boolean => Boolean(request?.status === 'start'));
18 export const selectRequestInFlightData = <D>(namespaceOrId: string) =>
19     createSelector(selectRequest(namespaceOrId), (request): MaybeNull<D> => request?.data ?? null);