softdinlibreriajs 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "softdinlibreriajs",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Libreria Softdin",
5
5
  "main": "src/",
6
6
  "scripts": {
@@ -18,6 +18,32 @@ class EnumRespuestaSINO {
18
18
  static getByDescription(description) {
19
19
  return EnumRespuestaSINO.descriptions.find(item => item.description === description) || null;
20
20
  }
21
+
22
+ static colorMapping = [
23
+ { 'success': EnumRespuestaSINO.SI },
24
+ { 'danger': EnumRespuestaSINO.NO },
25
+ ];
26
+
27
+ static getColors(campo) {
28
+ const colorArray = {};
29
+
30
+ for (const color of EnumRespuestaSINO.colorMapping) {
31
+ const description = Object.values(color)[0];
32
+ const descriptionEntry = EnumRespuestaSINO.descriptions.find(item => item.id === description);
33
+ if (descriptionEntry) {
34
+ colorArray[Object.keys(color)[0]] = descriptionEntry[campo];
35
+ } else {
36
+ colorArray[Object.keys(color)[0]] = null; // Handle the case where the field does not exist
37
+ }
38
+ }
39
+ return colorArray;
40
+ }
41
+
42
+ static getColorName(campo, valor) {
43
+ const colors = EnumRespuestaSINO.getColors(campo);
44
+ return Object.keys(colors).find(key => colors[key] === valor);
45
+ }
46
+
21
47
  }
22
48
 
23
49
  module.exports = EnumRespuestaSINO;