Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / pass / store / sagas / invites / invite-addresses-validate.saga.ts
blob86063f1312878fc3e7b76ff6d45f15891c0f47b1
1 import { put, takeEvery } from 'redux-saga/effects';
3 import { checkInviteAddresses } from '@proton/pass/lib/invites/invite.requests';
4 import {
5     inviteAddressesValidateFailure,
6     inviteAddressesValidateIntent,
7     inviteAddressesValidateSuccess,
8 } from '@proton/pass/store/actions';
10 function* validateInviteAddressesWorker({
11     payload: { shareId, emails },
12     meta: { request },
13 }: ReturnType<typeof inviteAddressesValidateIntent>) {
14     try {
15         const validAddresses: string[] = yield checkInviteAddresses(shareId, emails);
16         const result = Object.fromEntries(emails.map((email) => [email, validAddresses.includes(email)]));
17         yield put(inviteAddressesValidateSuccess(request.id, result));
18     } catch (err) {
19         yield put(inviteAddressesValidateFailure(request.id, err));
20     }
23 export default function* watcher() {
24     yield takeEvery(inviteAddressesValidateIntent.match, validateInviteAddressesWorker);