From 6fcd48c87ecc11de01ba7f095e87f536d0e447fe Mon Sep 17 00:00:00 2001 From: Mirian Okradze Date: Wed, 29 Nov 2023 16:51:23 +0400 Subject: [PATCH] fix: text slicer --- apps/ui/src/utils/textSlicer.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/ui/src/utils/textSlicer.ts b/apps/ui/src/utils/textSlicer.ts index e42051bb6..840f41dfa 100644 --- a/apps/ui/src/utils/textSlicer.ts +++ b/apps/ui/src/utils/textSlicer.ts @@ -1,6 +1,8 @@ -export const textSlicer = (text: string, maxLength: number) => { - let shortText = text?.slice(0, maxLength) || '' +export const textSlicer = (text: string | number | undefined, maxLength: number) => { + text = String(text) + if (!text) return { shortText: '' } + let shortText = text?.slice(0, maxLength) || '' // Check if the last character is a space and remove it if it is if (shortText.charAt(shortText.length - 1) === ' ') {