1 import { put, takeEvery } from 'redux-saga/effects';
3 import { checkInviteAddresses } from '@proton/pass/lib/invites/invite.requests';
5 inviteAddressesValidateFailure,
6 inviteAddressesValidateIntent,
7 inviteAddressesValidateSuccess,
8 } from '@proton/pass/store/actions';
10 function* validateInviteAddressesWorker({
11 payload: { shareId, emails },
13 }: ReturnType<typeof inviteAddressesValidateIntent>) {
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));
19 yield put(inviteAddressesValidateFailure(request.id, err));
23 export default function* watcher() {
24 yield takeEvery(inviteAddressesValidateIntent.match, validateInviteAddressesWorker);