Updated the batch user creation to work without corporate

This commit is contained in:
Tiago Ribeiro
2024-10-29 11:09:07 +00:00
parent dd94f245eb
commit 35ca933339
3 changed files with 11 additions and 9 deletions

View File

@@ -112,7 +112,7 @@ export default function BatchCreateUser({user, users, entities = [], permissions
const information = uniqBy(
rows
.map((row) => {
const [firstName, lastName, studentID, passport_id, email, phone, corporate, group, country] = row as string[];
const [firstName, lastName, studentID, passport_id, email, phone, group, country] = row as string[];
const countryItem =
countryCodes.findOne("countryCode" as any, country.toUpperCase()) ||
countryCodes.all().find((x) => x.countryNameEn.toLowerCase() === country.toLowerCase());
@@ -124,7 +124,6 @@ export default function BatchCreateUser({user, users, entities = [], permissions
type: type,
passport_id: passport_id?.toString().trim() || undefined,
groupName: group,
corporate,
studentID,
entity,
demographicInformation: {
@@ -147,7 +146,9 @@ export default function BatchCreateUser({user, users, entities = [], permissions
}
setInfos(information);
} catch {
} catch(e) {
console.log(e)
toast.error(
"Please upload an Excel file containing user information, one per line! All already registered e-mails have also been ignored!",
);
@@ -166,7 +167,8 @@ export default function BatchCreateUser({user, users, entities = [], permissions
setIsLoading(true);
try {
await axios.post("/api/batch_users", {users: newUsers.map((user) => ({...user, type, expiryDate}))});
const result = await axios.post("/api/batch_users", {users: newUsers.map((user) => ({...user, type, expiryDate}))});
console.log(result)
toast.success(`Successfully added ${newUsers.length} user(s)!`);
onFinish();
} catch {
@@ -193,7 +195,6 @@ export default function BatchCreateUser({user, users, entities = [], permissions
<th className="border border-neutral-200 px-2 py-1">Passport/National ID</th>
<th className="border border-neutral-200 px-2 py-1">E-mail</th>
<th className="border border-neutral-200 px-2 py-1">Phone Number</th>
{user?.type !== "corporate" && <th className="border border-neutral-200 px-2 py-1">Corporate (e-mail)</th>}
<th className="border border-neutral-200 px-2 py-1">Classroom Name</th>
<th className="border border-neutral-200 px-2 py-1">Country</th>
</tr>