Просмотр исходного кода

♻️ refactor(utils): adicionar getStatusColor e getStatusI18nKey ao helpers/utils

Fase: dev | Origin: melhoria-interna
Gustavo Zanatta 1 неделя назад
Родитель
Сommit
a2799fc550
1 измененных файлов с 18 добавлено и 1 удалено
  1. 18 1
      src/helpers/utils.js

+ 18 - 1
src/helpers/utils.js

@@ -100,7 +100,22 @@ const normalizeString = (val) =>
   val
     .toLowerCase()
     .normalize("NFKD")
-    .replace(/[\u0300-\u036f~]/g, "");
+    .replace(/[̀-ͯ~]/g, "");
+
+const getStatusColor = (status) => {
+  const s = typeof status === "object" ? status?.value : status;
+  if (s === "active")  return "positive";
+  if (s === "pending") return "warning";
+  return "grey-6";
+};
+
+const getStatusI18nKey = (status) => {
+  const s = typeof status === "object" ? status?.value : status;
+  if (s === "active")   return "common.status.active";
+  if (s === "inactive") return "common.status.inactive";
+  if (s === "pending")  return "common.status.pending";
+  return "common.status.inactive";
+};
 
 export {
   formatDateDMYtoYMD,
@@ -109,4 +124,6 @@ export {
   convertDateTime,
   formatToBRLCurrency,
   normalizeString,
+  getStatusColor,
+  getStatusI18nKey,
 };