From 47dbe0d618fbddf1a79c562beae3662a2f506353 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Sat, 20 Apr 2024 14:02:31 +0300 Subject: [PATCH] initials support complex names --- pages/api/schedule.ts | 2 +- src/helpers/common.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pages/api/schedule.ts b/pages/api/schedule.ts index a200b79..d95b1e6 100644 --- a/pages/api/schedule.ts +++ b/pages/api/schedule.ts @@ -140,7 +140,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) if (shift.assignments.some(a => a.isWithTransport)) { if (shift.requiresTransport) { 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(", "); } } diff --git a/src/helpers/common.js b/src/helpers/common.js index 8cbf543..615dfcb 100644 --- a/src/helpers/common.js +++ b/src/helpers/common.js @@ -746,3 +746,8 @@ exports.getLocalStorage = function (key, defaultValue) { exports.root = function (req) { return process.env.NEXT_PUBLIC_PUBLIC_URL; } + +exports.getInitials = function (names) { + const parts = names.split(' '); + return parts.map(part => part[0] + ".").join(''); +} \ No newline at end of file