eleven-solutions-common-website-unique-web 19.0.16 → 19.0.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -183,9 +183,22 @@ const TaxonomyForm = ({ url }) => {
183
183
  setNewValue(item.value);
184
184
  setIsModalOpen(true);
185
185
  };
186
+ // const handleEditClick = (index: number, id: string) => {
187
+ // setIsAddingSubType(false);
188
+ // const item = similarTaxonomies[index];
189
+ // setSelectedTaxonomyId(id);
190
+ // setEditTaxonomyItem(item);
191
+ // setNewCode(item.code);
192
+ // setNewValue(item.value);
193
+ // setIsModalOpen(true);
194
+ // };
186
195
  const handleEditClick = (index, id) => {
187
196
  setIsAddingSubType(false);
188
- const item = similarTaxonomies[index];
197
+ const item = similarTaxonomies.find((taxonomy) => taxonomy.id === id);
198
+ if (!item) {
199
+ console.error("Taxonomy not found");
200
+ return;
201
+ }
189
202
  setSelectedTaxonomyId(id);
190
203
  setEditTaxonomyItem(item);
191
204
  setNewCode(item.code);
@@ -202,6 +215,10 @@ const TaxonomyForm = ({ url }) => {
202
215
  setIsAddingSubType(true);
203
216
  };
204
217
  const handleSubTypeAddClick = () => __awaiter(void 0, void 0, void 0, function* () {
218
+ if (!subCode || !subValue) {
219
+ alert("Please fill out both Code and Value fields before adding.");
220
+ return;
221
+ }
205
222
  try {
206
223
  yield addSubTypeApi(url, selectedTaxonomyId, type, Number(subCode), subValue);
207
224
  alert("SubType added successfully");
@@ -276,6 +293,10 @@ const TaxonomyForm = ({ url }) => {
276
293
  }
277
294
  });
278
295
  const addTaxonomyClick = () => __awaiter(void 0, void 0, void 0, function* () {
296
+ if (!newCode || !newValue) {
297
+ alert("Please fill out both Code and Value fields before adding.");
298
+ return;
299
+ }
279
300
  try {
280
301
  yield addTaxonomyApi(url, type, Number(newCode), newValue);
281
302
  alert("Value added successfully");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleven-solutions-common-website-unique-web",
3
- "version": "19.0.16",
3
+ "version": "19.0.18",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -233,12 +233,28 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
233
233
  setIsModalOpen(true);
234
234
  };
235
235
 
236
+ // const handleEditClick = (index: number, id: string) => {
237
+ // setIsAddingSubType(false);
238
+
239
+ // const item = similarTaxonomies[index];
240
+ // setSelectedTaxonomyId(id);
241
+
242
+ // setEditTaxonomyItem(item);
243
+ // setNewCode(item.code);
244
+ // setNewValue(item.value);
245
+ // setIsModalOpen(true);
246
+ // };
236
247
  const handleEditClick = (index: number, id: string) => {
237
248
  setIsAddingSubType(false);
238
249
 
239
- const item = similarTaxonomies[index];
240
- setSelectedTaxonomyId(id);
250
+ const item = similarTaxonomies.find((taxonomy) => taxonomy.id === id);
251
+
252
+ if (!item) {
253
+ console.error("Taxonomy not found");
254
+ return;
255
+ }
241
256
 
257
+ setSelectedTaxonomyId(id);
242
258
  setEditTaxonomyItem(item);
243
259
  setNewCode(item.code);
244
260
  setNewValue(item.value);
@@ -258,6 +274,10 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
258
274
  };
259
275
 
260
276
  const handleSubTypeAddClick = async () => {
277
+ if (!subCode || !subValue) {
278
+ alert("Please fill out both Code and Value fields before adding.");
279
+ return;
280
+ }
261
281
  try {
262
282
  await addSubTypeApi(
263
283
  url,
@@ -361,6 +381,10 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
361
381
  };
362
382
 
363
383
  const addTaxonomyClick = async () => {
384
+ if (!newCode || !newValue) {
385
+ alert("Please fill out both Code and Value fields before adding.");
386
+ return;
387
+ }
364
388
  try {
365
389
  await addTaxonomyApi(url, type, Number(newCode), newValue);
366
390