FIX-1847 added methods in string utils in order to utilise in our code.

This commit is contained in:
Owaise Imdad committed 2025-03-04 09:00:37 +05:30
1 parent 43cf79f93e
commit 0eebd2929b
2 files changed
+22 -2

No files matched your search

+2 -1
View File
@@ -1,4 +1,5 @@
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { isEmpty } from "../stringUtils";
/** /**
* Utility function to render a truncated value with an optional title. * Utility function to render a truncated value with an optional title.
@@ -15,7 +16,7 @@ export const renderTruncatedValue = function (
maxLength, maxLength,
placeholder placeholder
) { ) {
if (!displayName || displayName === "0") return placeholder; if (isEmpty(displayName)) return placeholder;
const truncateTextWithDottedEnds = function (text, maxLength) { const truncateTextWithDottedEnds = function (text, maxLength) {
if (!text || text.length <= maxLength) return text; if (!text || text.length <= maxLength) return text;
+20 -1
View File
@@ -33,4 +33,23 @@ export const toLowerCaseFirstLetter = (str) => {
return ""; return "";
} }
return str.charAt(0).toLowerCase() + str.slice(1); return str.charAt(0).toLowerCase() + str.slice(1);
}; };
/**
* Checks if a string is null, undefined, or empty (including strings with only whitespace).
* @param {string} str - The string to check.
* @returns {boolean} - Returns true if the string is null, undefined, or empty.
*/
export const isEmpty = (str) => {
// Check if string is null, undefined, or empty (including whitespace only)
return str === null || str === undefined || str.trim().length === 0;
};
/**
* Checks if a string is not null, undefined, and not empty (including strings with only whitespace).
* @param {string} str - The string to check.
* @returns {boolean} - Returns true if the string is not null, undefined, and not empty.
*/
export const isNotEmpty = (str) => {
return !isEmpty(str);
};