refactor: create student with excel (email field)
This commit is contained in:
parent
67c829a498
commit
b1c231668e
|
|
@ -795,9 +795,10 @@ export const registerStudentCSV = async (req, res) => {
|
||||||
if (headers) {
|
if (headers) {
|
||||||
const NISN = row[headers.NISN]?.trim();
|
const NISN = row[headers.NISN]?.trim();
|
||||||
const NAME_USERS = row[headers.NAME_USERS]?.trim();
|
const NAME_USERS = row[headers.NAME_USERS]?.trim();
|
||||||
|
const EMAIL = row[headers.EMAIL]?.trim();
|
||||||
|
|
||||||
if (NISN && NAME_USERS) {
|
if (NISN && NAME_USERS && EMAIL) {
|
||||||
students.push({ NISN, NAME_USERS });
|
students.push({ NISN, NAME_USERS, EMAIL });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -830,9 +831,10 @@ export const registerStudentCSV = async (req, res) => {
|
||||||
|
|
||||||
const NISN = row.getCell(headers.NISN)?.text?.trim();
|
const NISN = row.getCell(headers.NISN)?.text?.trim();
|
||||||
const NAME_USERS = row.getCell(headers.NAME_USERS)?.text?.trim();
|
const NAME_USERS = row.getCell(headers.NAME_USERS)?.text?.trim();
|
||||||
|
const EMAIL = row.getCell(headers.EMAIL)?.text?.trim();
|
||||||
|
|
||||||
if (NISN && NAME_USERS) {
|
if (NISN && NAME_USERS && EMAIL) {
|
||||||
students.push({ NISN, NAME_USERS });
|
students.push({ NISN, NAME_USERS, EMAIL });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -854,9 +856,7 @@ export const registerStudentCSV = async (req, res) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const student of students) {
|
for (const student of students) {
|
||||||
const { NISN, NAME_USERS } = student;
|
const { NISN, NAME_USERS, EMAIL } = student;
|
||||||
|
|
||||||
const EMAIL = `${NISN}@student.seals.com`;
|
|
||||||
const PASSWORD = "12345678";
|
const PASSWORD = "12345678";
|
||||||
|
|
||||||
const salt = await bcrypt.genSalt(10);
|
const salt = await bcrypt.genSalt(10);
|
||||||
|
|
@ -1334,6 +1334,7 @@ function normalizeHeaders(headers) {
|
||||||
const synonyms = {
|
const synonyms = {
|
||||||
NISN: ["nisn", "no nisn", "nomor nisn"],
|
NISN: ["nisn", "no nisn", "nomor nisn"],
|
||||||
NAME_USERS: ["nama", "nama lengkap", "full name", "nama siswa"],
|
NAME_USERS: ["nama", "nama lengkap", "full name", "nama siswa"],
|
||||||
|
EMAIL: ["email", "alamat email"],
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalized = {};
|
const normalized = {};
|
||||||
|
|
@ -1367,6 +1368,8 @@ function normalizeHeadersXLSX(headers) {
|
||||||
"nama lengkap": "NAME_USERS",
|
"nama lengkap": "NAME_USERS",
|
||||||
"full name": "NAME_USERS",
|
"full name": "NAME_USERS",
|
||||||
"nama siswa": "NAME_USERS",
|
"nama siswa": "NAME_USERS",
|
||||||
|
email: "EMAIL",
|
||||||
|
"alamat email": "EMAIL",
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalized = {};
|
const normalized = {};
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
20
package-lock.json
generated
20
package-lock.json
generated
|
|
@ -1250,9 +1250,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/express": {
|
"node_modules/express": {
|
||||||
"version": "4.21.1",
|
"version": "4.21.2",
|
||||||
"resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz",
|
"resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
|
||||||
"integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==",
|
"integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"accepts": "~1.3.8",
|
"accepts": "~1.3.8",
|
||||||
"array-flatten": "1.1.1",
|
"array-flatten": "1.1.1",
|
||||||
|
|
@ -1273,7 +1274,7 @@
|
||||||
"methods": "~1.1.2",
|
"methods": "~1.1.2",
|
||||||
"on-finished": "2.4.1",
|
"on-finished": "2.4.1",
|
||||||
"parseurl": "~1.3.3",
|
"parseurl": "~1.3.3",
|
||||||
"path-to-regexp": "0.1.10",
|
"path-to-regexp": "0.1.12",
|
||||||
"proxy-addr": "~2.0.7",
|
"proxy-addr": "~2.0.7",
|
||||||
"qs": "6.13.0",
|
"qs": "6.13.0",
|
||||||
"range-parser": "~1.2.1",
|
"range-parser": "~1.2.1",
|
||||||
|
|
@ -1288,6 +1289,10 @@
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.10.0"
|
"node": ">= 0.10.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/express-prom-bundle": {
|
"node_modules/express-prom-bundle": {
|
||||||
|
|
@ -2441,9 +2446,10 @@
|
||||||
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="
|
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="
|
||||||
},
|
},
|
||||||
"node_modules/path-to-regexp": {
|
"node_modules/path-to-regexp": {
|
||||||
"version": "0.1.10",
|
"version": "0.1.12",
|
||||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz",
|
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
|
||||||
"integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w=="
|
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
|
||||||
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/pg-connection-string": {
|
"node_modules/pg-connection-string": {
|
||||||
"version": "2.7.0",
|
"version": "2.7.0",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user