contentoh-components-library 21.1.87 → 21.1.90

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.
@@ -13,10 +13,10 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
13
13
 
14
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
15
15
 
16
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
17
-
18
16
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
19
17
 
18
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
19
+
20
20
  var _styles = require("./styles");
21
21
 
22
22
  var _HeaderTop = require("../../molecules/HeaderTop");
@@ -82,12 +82,27 @@ var _CreateVersion = require("../../organisms/CreateVersion");
82
82
  var _jsxRuntime = require("react/jsx-runtime");
83
83
 
84
84
  var reducerImages = function reducerImages(state, action) {
85
+ var _action$init, _action$init$inputsBy;
86
+
85
87
  var values = state.values,
86
- attrForImgs = state.attrForImgs;
88
+ attrForImgs = state.attrForImgs,
89
+ inputsByRetailer = state.inputsByRetailer;
87
90
 
88
91
  switch (action.action) {
89
92
  case "init":
90
- return action.init;
93
+ var newInputsByRetailer = {};
94
+ action === null || action === void 0 ? void 0 : (_action$init = action.init) === null || _action$init === void 0 ? void 0 : (_action$init$inputsBy = _action$init.inputsByRetailer) === null || _action$init$inputsBy === void 0 ? void 0 : _action$init$inputsBy.forEach(function (inputs) {
95
+ inputs === null || inputs === void 0 ? void 0 : inputs.forEach(function (input) {
96
+ if (!newInputsByRetailer["".concat(input.id_retailer)]) newInputsByRetailer["".concat(input.id_retailer)] = [];
97
+ newInputsByRetailer["".concat(input.id_retailer)].push(input);
98
+ });
99
+ });
100
+ inputsByRetailer = newInputsByRetailer;
101
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, action.init), {}, {
102
+ inputsByRetailer: inputsByRetailer,
103
+ valuesInitial: action.init.values,
104
+ inputsInitial: action.init.inputs
105
+ });
91
106
 
92
107
  case "addImg":
93
108
  values = [].concat((0, _toConsumableArray2.default)(values), [action.img]);
@@ -123,6 +138,32 @@ var reducerImages = function reducerImages(state, action) {
123
138
  values: values
124
139
  });
125
140
 
141
+ case "orderImages":
142
+ {
143
+ var _inputsByRetailer$act;
144
+
145
+ var _inputsByRetailer = state.inputsByRetailer,
146
+ valuesInitial = state.valuesInitial,
147
+ inputsInitial = state.inputsInitial,
148
+ inputs = state.inputs;
149
+ var orderedImages = [];
150
+ var imageIdArray = [];
151
+ action.retailerId && ((_inputsByRetailer$act = _inputsByRetailer[action.retailerId]) === null || _inputsByRetailer$act === void 0 ? void 0 : _inputsByRetailer$act.filter(function (input) {
152
+ imageIdArray.push(input.id_image);
153
+ valuesInitial.forEach(function (value) {
154
+ if (value.image_id === input.id_image) orderedImages.push(value);
155
+ });
156
+ }));
157
+ inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
158
+ return imageIdArray.includes(input.id);
159
+ });
160
+ values = orderedImages.length > 0 ? orderedImages : valuesInitial;
161
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
162
+ values: values,
163
+ inputs: inputs
164
+ });
165
+ }
166
+
126
167
  default:
127
168
  return state;
128
169
  }
@@ -663,6 +704,11 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
663
704
  setDatasheets([datagroups, inputs]);
664
705
  setDescriptions(_descriptions);
665
706
  }
707
+
708
+ setImages({
709
+ action: "orderImages",
710
+ retailerId: activeRetailer.id
711
+ });
666
712
  }, [activeRetailer, services]);
667
713
 
668
714
  var thumbs = function thumbs() {
@@ -696,7 +742,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
696
742
  changeImage: setImages,
697
743
  selectedImages: selectedImages,
698
744
  setSelectedImages: setSelectedImages
699
- }, index);
745
+ }, index + "-" + imageType.name);
700
746
  });
701
747
  };
702
748
 
@@ -834,11 +880,13 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
834
880
  var _images$inputs;
835
881
 
836
882
  var imageInputs = images === null || images === void 0 ? void 0 : (_images$inputs = images.inputs) === null || _images$inputs === void 0 ? void 0 : _images$inputs.map(function (e) {
883
+ var _images$values2;
884
+
837
885
  return {
838
886
  value: e === null || e === void 0 ? void 0 : e.id,
839
887
  name: e === null || e === void 0 ? void 0 : e.name,
840
888
  required: e === null || e === void 0 ? void 0 : e.required,
841
- active: images === null || images === void 0 ? void 0 : images.values.some(function (value) {
889
+ active: images === null || images === void 0 ? void 0 : (_images$values2 = images.values) === null || _images$values2 === void 0 ? void 0 : _images$values2.some(function (value) {
842
890
  return (value === null || value === void 0 ? void 0 : value.image_id) === (e === null || e === void 0 ? void 0 : e.id);
843
891
  })
844
892
  };
@@ -846,7 +894,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
846
894
  setSocketType(imageInputs);
847
895
  }, [images]);
848
896
  var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
849
- var _images$values2, _product$article11, _data$articleData, _data$articleData2, _data$updateImages;
897
+ var _images$values3, _product$article11, _data$articleData, _data$articleData2, _data$updateImages;
850
898
 
851
899
  var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray;
852
900
 
@@ -854,7 +902,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
854
902
  while (1) {
855
903
  switch (_context7.prev = _context7.next) {
856
904
  case 0:
857
- imagesList = images === null || images === void 0 ? void 0 : (_images$values2 = images.values) === null || _images$values2 === void 0 ? void 0 : _images$values2.slice();
905
+ imagesList = images === null || images === void 0 ? void 0 : (_images$values3 = images.values) === null || _images$values3 === void 0 ? void 0 : _images$values3.slice();
858
906
  imagesListTemp = imagesList === null || imagesList === void 0 ? void 0 : imagesList.reduce(function (acc, image) {
859
907
  acc[image === null || image === void 0 ? void 0 : image.image_id] = ++acc[image === null || image === void 0 ? void 0 : image.image_id] || 0;
860
908
  return acc;
@@ -1476,13 +1524,13 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1476
1524
  }();
1477
1525
 
1478
1526
  var downloadImages = function downloadImages() {
1479
- var _images$values3;
1527
+ var _images$values4;
1480
1528
 
1481
1529
  selectedImages.length > 0 ? selectedImages.forEach(function (e) {
1482
1530
  if (e.id) {
1483
1531
  (0, _fileSaver.saveAs)("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(product.article.upc, "_").concat(e.name, ".").concat(e.ext));
1484
1532
  }
1485
- }) : images === null || images === void 0 ? void 0 : (_images$values3 = images.values) === null || _images$values3 === void 0 ? void 0 : _images$values3.forEach(function (e) {
1533
+ }) : images === null || images === void 0 ? void 0 : (_images$values4 = images.values) === null || _images$values4 === void 0 ? void 0 : _images$values4.forEach(function (e) {
1486
1534
  if (e.id) {
1487
1535
  (0, _fileSaver.saveAs)("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(product.article.upc, "_").concat(e.name, ".").concat(e.ext));
1488
1536
  }
@@ -1693,7 +1741,9 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1693
1741
 
1694
1742
  return (product === null || product === void 0 ? void 0 : (_product$services = product.services) === null || _product$services === void 0 ? void 0 : _product$services.images) === 1 && updateImages();
1695
1743
  },
1696
- showSaveButton: auditorAssigned() || userAssigned()
1744
+ showSaveButton: auditorAssigned() || userAssigned(),
1745
+ setShowVersionSelector: setShowVersionSelector,
1746
+ version: version
1697
1747
  })]
1698
1748
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1699
1749
  className: "product-information",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.1.87",
3
+ "version": "21.1.90",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -7,7 +7,7 @@ export default function Select(props) {
7
7
  id={props.id}
8
8
  width={props.width}
9
9
  onChange={props.onChange}
10
- defaultValue={props.valueSelected ? props.valueSelected : ""}
10
+ value={props.valueSelected ? props.valueSelected : ""}
11
11
  className={props.className}
12
12
  >
13
13
  <option value="" disabled>
@@ -11,6 +11,8 @@ export const TableHeader = ({
11
11
  isRetailer,
12
12
  onClickSave,
13
13
  showSaveButton,
14
+ version,
15
+ setShowVersionSelector,
14
16
  }) => {
15
17
  return (
16
18
  <Container>
@@ -26,6 +28,8 @@ export const TableHeader = ({
26
28
  isRetailer={isRetailer}
27
29
  onClickSave={onClickSave}
28
30
  showSaveButton={showSaveButton}
31
+ version={version}
32
+ setShowVersionSelector={setShowVersionSelector}
29
33
  />
30
34
  </Container>
31
35
  );
@@ -16,6 +16,8 @@ export const ImageDataTable = ({
16
16
  isRetailer,
17
17
  onClickSave,
18
18
  showSaveButton,
19
+ version,
20
+ setShowVersionSelector,
19
21
  }) => {
20
22
  return (
21
23
  <Container darkMode={darkMode}>
@@ -27,6 +29,8 @@ export const ImageDataTable = ({
27
29
  isRetailer={isRetailer}
28
30
  showSaveButton={showSaveButton}
29
31
  onClickSave={onClickSave}
32
+ version={version}
33
+ setShowVersionSelector={setShowVersionSelector}
30
34
  />
31
35
  <Row>
32
36
  <ScreenHeader headerType={"table-row-text"} text="Tipo de toma" />
@@ -16,98 +16,133 @@ ProviderProductEditionDefault.args = {
16
16
  Imágenes: true,
17
17
  },
18
18
  token:
19
- "eyJraWQiOiJEV3owZnNieXg2MXNFcVduN3RCXC81bVhod3ZNbFZIOTgwUnZcL3RjT0lKdEk9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI5ZTQ0OGMwZS0xOGVkLTRlYWYtOWY4OC0zYjMxOTdkNGEyZmQiLCJjb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 846,
22
22
  version: 2,
23
23
  productSelected: {
24
- id_article: 76145,
25
- id_category: "700",
26
- name: "prod 8 LCR",
27
- upc: "8484161",
28
- timestamp: "2022-07-11T15:28:44.000Z",
29
- status: "NULL",
30
- categoryName:
31
- "Salud y Belleza|Cuidado Facial|Cremas, Mascarillas y Tratamientos",
32
- asignations: [],
24
+ orderId: 1936,
25
+ article_status: "AP",
26
+ datasheet_status: "NS",
27
+ description_status: "NS",
28
+ images_status: "AP",
29
+ prio: "none",
33
30
  version: 3,
34
- version_status: "R",
31
+ brand: null,
32
+ article: {
33
+ category: "Herramientas|Herramientas Manuales|Espátulas y Llanas",
34
+ company_name: "TRUPER SA DE CV",
35
+ id_company: 301,
36
+ country: null,
37
+ id_category: "2125",
38
+ id_article: 28099,
39
+ name: 'Espátula flexible, mango de madera, 6"',
40
+ upc: "90364",
41
+ },
42
+ retailers: [
43
+ {
44
+ id: 58,
45
+ name: "The Home Depot Golden",
46
+ },
47
+ {
48
+ id: 59,
49
+ name: "The Home Depot Platinum",
50
+ },
51
+ ],
52
+ services: {
53
+ datasheets: 0,
54
+ descriptions: 0,
55
+ images: 1,
56
+ },
57
+ statusByRetailer: {
58
+ 59: {
59
+ images: "AP",
60
+ },
61
+ },
62
+ retailersWithService: ["59"],
63
+ checked: false,
64
+ id_article: 28099,
35
65
  retailersAvailable: [
36
66
  {
37
- id: 12,
38
- name: "La Comer",
39
- country: "México",
40
- id_region: 1,
41
- active: 1,
67
+ id: 58,
68
+ name: "The Home Depot Golden",
69
+ },
70
+ {
71
+ id: 59,
72
+ name: "The Home Depot Platinum",
42
73
  },
43
74
  ],
44
- missing: {},
45
75
  },
46
76
  productToEdit: {
47
- idCategory: "2999",
48
- ArticleId: 69031,
49
- product: [
50
- {
51
- orderId: 1829,
52
- id_category: "2999",
53
- status: "AC",
54
- datasheet_status: "NS",
55
- prio: "none",
56
- version: 2,
57
- description_status: "NS",
58
- images_status: "AC",
59
- brand: null,
60
- missing: {
61
- datasheet: 0,
62
- descriptions: 0,
63
- images: 0,
77
+ ArticleId: 28099,
78
+ idCategory: "2125",
79
+ product: {
80
+ orderId: 1936,
81
+ article_status: "AP",
82
+ datasheet_status: "NS",
83
+ description_status: "NS",
84
+ images_status: "AP",
85
+ prio: "none",
86
+ version: 3,
87
+ brand: null,
88
+ article: {
89
+ category: "Herramientas|Herramientas Manuales|Espátulas y Llanas",
90
+ company_name: "TRUPER SA DE CV",
91
+ id_company: 301,
92
+ country: null,
93
+ id_category: "2125",
94
+ id_article: 28099,
95
+ name: 'Espátula flexible, mango de madera, 6"',
96
+ upc: "90364",
97
+ },
98
+ retailers: [
99
+ {
100
+ id: 58,
101
+ name: "The Home Depot Golden",
64
102
  },
65
- article: {
66
- category: "RESIZING|RESIZING|RESIZING",
67
- company_name: "The Home Depot Resize",
68
- id_category: "2999",
69
- id_article: 69031,
70
- name: "RESIZING",
71
- timestamp: "2022-06-23T15:53:54.000Z",
72
- upc: "130994",
103
+ {
104
+ id: 59,
105
+ name: "The Home Depot Platinum",
73
106
  },
74
- retailers: [
75
- {
76
- id: 60,
77
- name: "The Home Depot Resizing",
78
- },
79
- ],
80
- services: {
81
- datasheets: 0,
82
- descriptions: 0,
83
- images: 1,
107
+ ],
108
+ services: {
109
+ datasheets: 0,
110
+ descriptions: 0,
111
+ images: 1,
112
+ },
113
+ statusByRetailer: {
114
+ 59: {
115
+ images: "AP",
84
116
  },
85
- checked: false,
86
- retailersAvailable: [
87
- {
88
- id: 60,
89
- name: "The Home Depot Resizing",
90
- },
91
- ],
92
- id_article: 69031,
93
- categoryName: "RESIZING|RESIZING|RESIZING",
94
- version_status: "AC",
95
117
  },
96
- ],
118
+ retailersWithService: ["59"],
119
+ checked: false,
120
+ id_article: 28099,
121
+ retailersAvailable: [
122
+ {
123
+ id: 58,
124
+ name: "The Home Depot Golden",
125
+ },
126
+ {
127
+ id: 59,
128
+ name: "The Home Depot Platinum",
129
+ },
130
+ ],
131
+ },
97
132
  },
98
133
  location: {
99
134
  state: { origin: "Contentoh" },
100
135
  },
101
136
  user: {
102
- id_user: 1287,
103
- name: "Gerson",
104
- last_name: "Martinez",
105
- email: "gmartinez@contentoh.com",
106
- position: "Cuenta financiada",
107
- telephone: "+525551234567",
137
+ id_user: 1237,
138
+ name: "The Home",
139
+ last_name: "Depot",
140
+ email: "retailerThd@AllFreeMail.net",
141
+ position: "Retailer",
142
+ telephone: "+523111111111",
108
143
  country: "México",
109
- id_company: 819,
110
- id_cognito: "9e448c0e-18ed-4eaf-9f88-3b3197d4a2fd",
144
+ id_company: 817,
145
+ id_cognito: "abe188e2-25b1-4a19-8672-0d4bc11a9bf2",
111
146
  birth_Date: null,
112
147
  about_me: null,
113
148
  zip_code: null,
@@ -116,12 +151,12 @@ ProviderProductEditionDefault.args = {
116
151
  id_stripe: null,
117
152
  id_role: 0,
118
153
  active: 1,
119
- is_retailer: 0,
154
+ is_retailer: 1,
120
155
  email_notify: 1,
121
156
  membership: {
122
- id: 799,
123
- start_date: "2022-06-19T15:48:09.000Z",
124
- end_date: "2023-06-19T15:48:09.000Z",
157
+ id: 798,
158
+ start_date: "2022-06-19T04:25:07.000Z",
159
+ end_date: "2023-06-19T04:25:07.000Z",
125
160
  planID: 6,
126
161
  plan: "prod_KvGd6YSTJyR3AP",
127
162
  name: "Plan Small",
@@ -129,20 +164,42 @@ ProviderProductEditionDefault.args = {
129
164
  products_limit: "1000",
130
165
  type: "Enterprise",
131
166
  },
132
- src: "https://content-management-profile-prod.s3.amazonaws.com/id-1287/1287.png?1656431499310",
167
+ src: "https://content-management-profile-prod.s3.amazonaws.com/id-1237/1237.png?1659539733360",
133
168
  },
134
169
  company: {
135
- id_company: 1,
136
- trade_name: "COMPANY DEV",
137
- company_name: "COMPANY DEV",
138
- rfc: null,
139
- adress: "",
140
- about_company: "...",
141
- telephone: "",
142
- web_site: "",
143
- zip_code: "",
170
+ id_company: 817,
171
+ trade_name: "Retailer acc",
172
+ company_name: "Retailer acc",
173
+ rfc: "ASER12345",
174
+ adress: "Av. Insurgentes",
175
+ about_company: null,
176
+ telephone: null,
177
+ web_site: null,
178
+ zip_code: null,
144
179
  email: null,
145
- social_link: "",
146
- is_retailer: 0,
180
+ social_link: null,
181
+ is_retailer: 1,
182
+ retailers: [
183
+ {
184
+ id: 58,
185
+ name: "The Home Depot Golden",
186
+ country: "México",
187
+ },
188
+ {
189
+ id: 59,
190
+ name: "The Home Depot Platinum",
191
+ country: "México",
192
+ },
193
+ {
194
+ id: 60,
195
+ name: "The Home Depot Resizing",
196
+ country: "México",
197
+ },
198
+ {
199
+ id: 61,
200
+ name: "Home Depot TAB",
201
+ country: "México",
202
+ },
203
+ ],
147
204
  },
148
205
  };
@@ -45,10 +45,24 @@ import { useCloseModal } from "../../../global-files/customHooks";
45
45
  import { CreateVersion } from "../../organisms/CreateVersion";
46
46
 
47
47
  const reducerImages = (state, action) => {
48
- let { values, attrForImgs } = state;
48
+ let { values, attrForImgs, inputsByRetailer } = state;
49
49
  switch (action.action) {
50
50
  case "init":
51
- return action.init;
51
+ const newInputsByRetailer = {};
52
+ action?.init?.inputsByRetailer?.forEach((inputs) => {
53
+ inputs?.forEach((input) => {
54
+ if (!newInputsByRetailer[`${input.id_retailer}`])
55
+ newInputsByRetailer[`${input.id_retailer}`] = [];
56
+ newInputsByRetailer[`${input.id_retailer}`].push(input);
57
+ });
58
+ });
59
+ inputsByRetailer = newInputsByRetailer;
60
+ return {
61
+ ...action.init,
62
+ inputsByRetailer,
63
+ valuesInitial: action.init.values,
64
+ inputsInitial: action.init.inputs,
65
+ };
52
66
  case "addImg":
53
67
  values = [...values, action.img];
54
68
  return { ...state, values };
@@ -56,18 +70,40 @@ const reducerImages = (state, action) => {
56
70
  values[action.index][action.attribute] = action.value;
57
71
  return { ...state, values };
58
72
  case "changeAttrValue":
59
- attrForImgs[action.retailer][action.index].value = action.value;
73
+ const index = attrForImgs.general.findIndex((f) => (f.id = action.id));
74
+ if (index !== -1) {
75
+ attrForImgs.general[index].value = action.value;
76
+ }
77
+
60
78
  return { ...state, attrForImgs, values };
61
79
  case "deleteImage":
62
80
  values = values.filter(
63
81
  (value) => action.selectedImages.indexOf(value) === -1
64
82
  );
65
83
  return { ...state, values };
84
+ case "orderImages": {
85
+ let { inputsByRetailer, valuesInitial, inputsInitial, inputs } = state;
86
+ const orderedImages = [];
87
+ const imageIdArray = [];
88
+ action.retailerId &&
89
+ inputsByRetailer[action.retailerId]?.filter((input) => {
90
+ imageIdArray.push(input.id_image);
91
+ valuesInitial.forEach((value) => {
92
+ if (value.image_id === input.id_image) orderedImages.push(value);
93
+ });
94
+ });
95
+
96
+ inputs = inputsInitial?.filter((input) =>
97
+ imageIdArray.includes(input.id)
98
+ );
99
+
100
+ values = orderedImages.length > 0 ? orderedImages : valuesInitial;
101
+ return { ...state, values, inputs };
102
+ }
66
103
  default:
67
104
  return state;
68
105
  }
69
106
  };
70
-
71
107
  const S3_BUCKET = process.env.REACT_APP_IMAGES_BUCKET;
72
108
  const REGION = "us-east-1";
73
109
 
@@ -355,6 +391,7 @@ export const ProviderProductEdition = ({
355
391
 
356
392
  useEffect(() => {
357
393
  loadInputs();
394
+ setImages({ action: "orderImages", retailerId: activeRetailer.id });
358
395
  }, [servicesData, activeRetailer, services]);
359
396
 
360
397
  const thumbs = () => {
@@ -1041,6 +1078,8 @@ export const ProviderProductEdition = ({
1041
1078
  onClickSave={() =>
1042
1079
  product?.services?.images === 1 && updateImages()
1043
1080
  }
1081
+ setShowVersionSelector={setShowVersionSelector}
1082
+ version={version}
1044
1083
  />
1045
1084
  </div>
1046
1085
  <div className="product-information">
@@ -1170,7 +1209,9 @@ export const ProviderProductEdition = ({
1170
1209
  <FullTabsMenu
1171
1210
  tabsSections={tabsSections}
1172
1211
  status={
1173
- activeRetailer.id
1212
+ activeRetailer?.id &&
1213
+ retailerStatus &&
1214
+ retailerStatus[activeRetailer.id]
1174
1215
  ? retailerStatus[activeRetailer?.id][getConcept(activeTab)] ||
1175
1216
  "NS"
1176
1217
  : "-"