diff --git a/controllers/auth/auth.js b/controllers/auth/auth.js index 9dd5806..8f7d910 100644 --- a/controllers/auth/auth.js +++ b/controllers/auth/auth.js @@ -795,9 +795,10 @@ export const registerStudentCSV = async (req, res) => { if (headers) { const NISN = row[headers.NISN]?.trim(); const NAME_USERS = row[headers.NAME_USERS]?.trim(); + const EMAIL = row[headers.EMAIL]?.trim(); - if (NISN && NAME_USERS) { - students.push({ NISN, NAME_USERS }); + if (NISN && NAME_USERS && EMAIL) { + 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 NAME_USERS = row.getCell(headers.NAME_USERS)?.text?.trim(); + const EMAIL = row.getCell(headers.EMAIL)?.text?.trim(); - if (NISN && NAME_USERS) { - students.push({ NISN, NAME_USERS }); + if (NISN && NAME_USERS && EMAIL) { + students.push({ NISN, NAME_USERS, EMAIL }); } } }); @@ -854,9 +856,7 @@ export const registerStudentCSV = async (req, res) => { try { for (const student of students) { - const { NISN, NAME_USERS } = student; - - const EMAIL = `${NISN}@student.seals.com`; + const { NISN, NAME_USERS, EMAIL } = student; const PASSWORD = "12345678"; const salt = await bcrypt.genSalt(10); @@ -1334,6 +1334,7 @@ function normalizeHeaders(headers) { const synonyms = { NISN: ["nisn", "no nisn", "nomor nisn"], NAME_USERS: ["nama", "nama lengkap", "full name", "nama siswa"], + EMAIL: ["email", "alamat email"], }; const normalized = {}; @@ -1367,6 +1368,8 @@ function normalizeHeadersXLSX(headers) { "nama lengkap": "NAME_USERS", "full name": "NAME_USERS", "nama siswa": "NAME_USERS", + email: "EMAIL", + "alamat email": "EMAIL", }; const normalized = {}; diff --git a/media/uploads/excel/excel example.xlsx b/media/uploads/excel/excel example.xlsx index 7ef54f2..265012f 100644 Binary files a/media/uploads/excel/excel example.xlsx and b/media/uploads/excel/excel example.xlsx differ diff --git a/media/uploads/excel/excel template.xlsx b/media/uploads/excel/excel template.xlsx index cca4f3a..2e7fa72 100644 Binary files a/media/uploads/excel/excel template.xlsx and b/media/uploads/excel/excel template.xlsx differ diff --git a/package-lock.json b/package-lock.json index 807757a..dea5684 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1250,9 +1250,10 @@ } }, "node_modules/express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "license": "MIT", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -1273,7 +1274,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -1288,6 +1289,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/express-prom-bundle": { @@ -2441,9 +2446,10 @@ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==" }, "node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==" + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "license": "MIT" }, "node_modules/pg-connection-string": { "version": "2.7.0",