initials support complex names

This commit is contained in:
Dobromir Popov
2024-04-20 14:02:31 +03:00
parent 9586325bfa
commit 47dbe0d618
2 changed files with 6 additions and 1 deletions

View File

@ -140,7 +140,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (shift.assignments.some(a => a.isWithTransport)) { if (shift.assignments.some(a => a.isWithTransport)) {
if (shift.requiresTransport) { if (shift.requiresTransport) {
notes = "Транспорт: "; notes = "Транспорт: ";
notes_bold = " " + shift.assignments.filter(a => a.isWithTransport).map(a => a.publisher.firstName.charAt(0) + "." + a.publisher.lastName.charAt(0) + ".").join(", "); notes_bold = " " + shift.assignments.filter(a => a.isWithTransport).map(a => common.getInitials(a.publisher.firstName + " " + a.publisher.lastName)).join(", ");
} }
} }

View File

@ -746,3 +746,8 @@ exports.getLocalStorage = function (key, defaultValue) {
exports.root = function (req) { exports.root = function (req) {
return process.env.NEXT_PUBLIC_PUBLIC_URL; return process.env.NEXT_PUBLIC_PUBLIC_URL;
} }
exports.getInitials = function (names) {
const parts = names.split(' ');
return parts.map(part => part[0] + ".").join('');
}