Files
kavehhn bf5e66fa95 feat: add append-only course/user data import and expand user profile
Support uploading structured JSON to create courses, classes, and students without wiping existing data, and merge user name fields while adding gender and registration details from source sheets.
2026-08-15 01:31:44 +03:30

25 lines
659 B
JavaScript

// /utils/userProfile.js
'use strict';
const ALLOWED_GENDERS = ['male', 'female'];
const mergeFullName = (name, surname) => {
const parts = [name, surname].map((v) => (v == null ? '' : String(v).trim())).filter(Boolean);
return parts.join(' ').trim();
};
const normalizeGender = (value) => {
if (value == null || value === '') return undefined;
const g = String(value).trim().toLowerCase();
if (ALLOWED_GENDERS.includes(g)) return g;
if (g === 'مرد' || g === 'آقا') return 'male';
if (g === 'زن' || g === 'خانم') return 'female';
return undefined;
};
module.exports = {
ALLOWED_GENDERS,
mergeFullName,
normalizeGender
};