Formatted the code to accept .xlsx
This commit is contained in:
@@ -49,7 +49,7 @@ export default function BatchCodeGenerator({user}: {user: User}) {
|
||||
const information = uniqBy(
|
||||
rows
|
||||
.map((row) => {
|
||||
const [firstName, lastName, country, passport_id, email, phone] = row.map((x) => (x as string).trim());
|
||||
const [firstName, lastName, country, passport_id, email, phone] = row as string[];
|
||||
return EMAIL_REGEX.test(email) && !users.map((u) => u.email).includes(email)
|
||||
? {
|
||||
email,
|
||||
|
||||
@@ -54,7 +54,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
|
||||
if (infos && infos.length > index) {
|
||||
const {email, name, passport_id} = infos[index];
|
||||
await setDoc(codeRef, {email, name, passport_id}, {merge: true});
|
||||
await setDoc(codeRef, {email: email.trim(), name: name.trim(), passport_id: passport_id.trim()}, {merge: true});
|
||||
|
||||
const transport = prepareMailer();
|
||||
const mailOptions = prepareMailOptions(
|
||||
@@ -62,7 +62,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
type,
|
||||
code,
|
||||
},
|
||||
[email],
|
||||
[email.trim()],
|
||||
"EnCoach Registration",
|
||||
"main",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user