diff --git a/functions/index.js b/functions/index.js index cf080b5..8e7f459 100644 --- a/functions/index.js +++ b/functions/index.js @@ -476,8 +476,8 @@ exports.importUsers = functions.https.onCall(async (data, context) => { // Write user domain data (only need to use notFound since domain data is already written for found) await batchWrite( - Object.keys(notFound), - (batch, email) => batch.set(userDomainDoc(allUsers[email]), { domain }), + notFound.map(email => userDomainDoc(allUsers[email])), + (batch, ref) => batch.set(ref, { domain }), firestore, (error) => errors.push(error) ); diff --git a/src/redux/Actions.js b/src/redux/Actions.js index acb5870..3f8f78f 100644 --- a/src/redux/Actions.js +++ b/src/redux/Actions.js @@ -300,6 +300,8 @@ export function setOrderSchedule(data, dispatch, domain) { export async function importUsers(data, dispatch, domain) { dispatch(setLoading(true)); + + // Turns an array of user objects into an object with email as key let userData = {}; for (let user of data) { if (user.email) { @@ -308,6 +310,7 @@ export async function importUsers(data, dispatch, domain) { userData[user.email] = thisUser; } } + let { updated, created, errors } = await importUsersFunction(userData, domain); console.log(`Successfully updated ${Object.keys(updated).length} users`); console.log(`Successfully created ${Object.keys(created).length} users`);