Update src/widgets/customapi/component.jsx
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
5cb5fdcc82
commit
6e26a01749
@ -103,24 +103,22 @@ function getColor(mapping, customData) {
|
|||||||
const value = getValue(mapping.additionalField, customData);
|
const value = getValue(mapping.additionalField, customData);
|
||||||
const color = mapping.additionalFieldColor;
|
const color = mapping.additionalFieldColor;
|
||||||
|
|
||||||
if (color) {
|
switch (color) {
|
||||||
if (color === "auto") {
|
case "auto":
|
||||||
const numberRegex = /-?\d*\.?\d+/g;
|
try {
|
||||||
const matches = value.match(numberRegex);
|
const number = parseFloat(value);
|
||||||
|
return number > 0 ? "text-emerald-300" : "text-rose-300";
|
||||||
if (matches && matches.length > 0) {
|
} catch (e) {
|
||||||
return matches[0] > 0 ? "text-emerald-300" : "text-rose-300";
|
return "";
|
||||||
}
|
}
|
||||||
} else if (color === "black") {
|
case ("black") :
|
||||||
return `text-black`;
|
return `text-black`;
|
||||||
} else if (color === "white") {
|
case ("white") :
|
||||||
return `text-white`;
|
return `text-white`;
|
||||||
} else if (color === "theme") {
|
case ("theme") :
|
||||||
return `text-theme-500`;
|
return `text-theme-500`;
|
||||||
}
|
default:
|
||||||
}
|
return ""
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user