eleven-solutions-common-website-unique-web 21.0.29 → 21.0.31
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.
@@ -247,36 +247,75 @@ const TaxonomyForm = ({ url }) => {
|
|
247
247
|
setIsModalOpen(true);
|
248
248
|
setIsAddingSubType(true);
|
249
249
|
};
|
250
|
-
const handleEditTaxClick = () =>
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
250
|
+
// const handleEditTaxClick = async () => {
|
251
|
+
// try {
|
252
|
+
// await updateTaxonomyApi(
|
253
|
+
// url,
|
254
|
+
// selectedTaxonomyId,
|
255
|
+
// type,
|
256
|
+
// Number(newCode),
|
257
|
+
// newValue
|
258
|
+
// );
|
259
|
+
// alert("Taxonomy updated successfully");
|
260
|
+
// } catch (error) {
|
261
|
+
// console.error("Error updating Taxonomy:", error);
|
262
|
+
// }
|
263
|
+
// setIsModalOpen(false);
|
264
|
+
// setNewCode("");
|
265
|
+
// setNewValue("");
|
266
|
+
// const response = await fetchTaxonomiessApi(url);
|
267
|
+
// const filteredTaxonomies = (response as { type: string }[]).filter(
|
268
|
+
// (taxonomy: { type: string }) => taxonomy.type === type
|
269
|
+
// );
|
270
|
+
// setSimilarTaxonomies(filteredTaxonomies);
|
271
|
+
// };
|
272
|
+
// const addTaxonomyClick = async () => {
|
273
|
+
// if (!newCode || !newValue) {
|
274
|
+
// alert("Please fill out both Code and Value fields before adding.");
|
275
|
+
// return;
|
276
|
+
// }
|
277
|
+
// try {
|
278
|
+
// await addTaxonomyApi(url, type, Number(newCode), newValue);
|
279
|
+
// alert("Value added successfully");
|
280
|
+
// const response = await fetchTaxonomiessApi(url);
|
281
|
+
// const filteredTaxonomies = (response as { type: string }[]).filter(
|
282
|
+
// (taxonomy: { type: string }) => taxonomy.type === type
|
283
|
+
// );
|
284
|
+
// setSimilarTaxonomies(filteredTaxonomies);
|
285
|
+
// } catch (error) {
|
286
|
+
// console.error("Error adding value:", error);
|
287
|
+
// }
|
288
|
+
// setIsModalOpen(false);
|
289
|
+
// setNewCode("");
|
290
|
+
// setNewValue("");
|
291
|
+
// };
|
292
|
+
const handleSubmitClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
266
293
|
if (!newCode || !newValue) {
|
267
|
-
alert("Please fill out both Code and Value fields before
|
294
|
+
alert("Please fill out both Code and Value fields before submitting.");
|
268
295
|
return;
|
269
296
|
}
|
270
297
|
try {
|
271
|
-
|
272
|
-
|
298
|
+
if (editTaxonomyItem || editTempTaxonomyItem) {
|
299
|
+
// Edit taxonomy logic
|
300
|
+
yield updateTaxonomyApi(url, selectedTaxonomyId, type, Number(newCode), newValue);
|
301
|
+
alert("Taxonomy updated successfully");
|
302
|
+
}
|
303
|
+
else {
|
304
|
+
// Add taxonomy logic
|
305
|
+
yield addTaxonomyApi(url, type, Number(newCode), newValue);
|
306
|
+
alert("Value added successfully");
|
307
|
+
}
|
308
|
+
// Fetch and update similar taxonomies
|
273
309
|
const response = yield fetchTaxonomiessApi(url);
|
274
310
|
const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === type);
|
275
311
|
setSimilarTaxonomies(filteredTaxonomies);
|
276
312
|
}
|
277
313
|
catch (error) {
|
278
|
-
console.error(
|
314
|
+
console.error(editTaxonomyItem || editTempTaxonomyItem
|
315
|
+
? "Error updating Taxonomy:"
|
316
|
+
: "Error adding value:", error);
|
279
317
|
}
|
318
|
+
// Reset modal and input fields
|
280
319
|
setIsModalOpen(false);
|
281
320
|
setNewCode("");
|
282
321
|
setNewValue("");
|
@@ -298,18 +337,16 @@ const TaxonomyForm = ({ url }) => {
|
|
298
337
|
-1 ? (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 15.75l-7.5-7.5-7.5 7.5" }) })) : (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) })) }))] })) }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-400", children: taxonomy.code }), _jsx("td", { className: "px-4 py-4 text-sm font-medium text-gray-900 dark:text-white", children: _jsx("div", { className: "flex justify-between items-center", children: _jsx("span", { children: taxonomy.value }) }) })] }, index), expandedRows.indexOf(taxonomy.id) !== -1 && (_jsx("tr", { children: _jsx("td", { colSpan: 3, children: _jsxs("table", { className: "min-w-full divide-y ", children: [_jsx("thead", { className: "bg-gray-50 dark:bg-gray-800", children: _jsxs("tr", { children: [similarTaxonomies.some((taxonomy) => taxonomy.isEdit) && (_jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", style: { width: "200px" }, children: "Actions" })), _jsx("th", { scope: "col", style: { width: "350px" }, className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400 w-[23%]", children: "Code" }), _jsx("th", { className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Value" })] }) }), _jsx("tbody", { children: allTaxonomies
|
299
338
|
.filter((item) => item.parentId === taxonomy.id)
|
300
339
|
.map((child, key) => (_jsxs("tr", { children: [similarTaxonomies.some((taxonomy) => taxonomy.isEdit) && (_jsx("td", { className: "px-4 py-4 text-sm whitespace-nowrap", children: _jsxs("div", { className: "flex items-center gap-x-6", children: [_jsx("button", { type: "button", onClick: () => handleDeleteSubTypeClick(child.id), className: "text-gray-500 transition-colors duration-200 dark:hover:text-red-600 dark:text-gray-300 hover:text-red-500 focus:outline-none", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" }) }) }), _jsx("button", { onClick: () => handleSubEdit(child), className: "text-gray-500 transition-colors duration-200 dark:hover:text-yellow-500 dark:text-gray-300 hover:text-yellow-500 focus:outline-none", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" }) }) })] }) })), _jsx("td", { className: "px-4 py-2 text-sm text-gray-500 dark:text-gray-400", children: child.code }), _jsx("td", { className: "px-4 py-4 text-sm font-medium text-gray-900 dark:text-white", children: child.value })] }, key))) })] }) }) }))] }, taxonomy.id));
|
301
|
-
}) })] }) }),
|
340
|
+
}) })] }) }), _jsxs("div", { className: "flex space-x-4 mt-6 justify-start", children: [similarTaxonomies.some((taxonomy) => taxonomy.isEdit && taxonomy.isMultiple) && (_jsxs("button", { type: "button", onClick: handleOpenModal, className: "flex items-center justify-center px-6 py-2 font-medium tracking-wide text-white capitalize transition-colors duration-300 transform bg-blue-600 rounded-lg hover:bg-blue-500 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80", children: [_jsx(FaPlus, { className: "mr-2 font-medium" }), "Add Multiple Values"] })), _jsx("button", { onClick: handleCancelClick, type: "button", className: "px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600", children: "Cancel" })] })] }))] }), _jsx("div", { className: `fixed inset-y-0 right-0 z-50 w-1/3 bg-white dark:bg-gray-800 p-6 shadow-lg transform ${isModalOpen ? "translate-x-0" : "translate-x-full"} transition-transform duration-300`, children: _jsxs("div", { className: "p-6", children: [_jsxs("div", { className: "flex justify-between", children: [_jsx("h2", { className: "text-xl font-bold text-blue-600 mb-4 ", children: isAddingSubType
|
302
341
|
? editTaxonomyItem
|
303
342
|
? "Edit SubType"
|
304
343
|
: "Add SubType"
|
305
344
|
: editTaxonomyItem
|
306
345
|
? "Edit Values"
|
307
|
-
: "Add Values" }), _jsx("button", { onClick: handleCloseModal, className: "text-xl text-gray-600 dark:text-gray-400 h-6 w-6", children: "\u00D7" })] }), isAddingSubType ? (_jsxs(_Fragment, { children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Code" }), _jsx("input", { type: "number", value: subCode, onChange: (e) => setSubCode(e.target.value), placeholder: "Enter Code", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Value" }), _jsx("input", { type: "text", value: subValue, onChange: (e) => setSubValue(e.target.value), placeholder: "Enter Value", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsxs("div", { className: "flex space-x-4 justify-end", children: [_jsx("button", {
|
346
|
+
: "Add Values" }), _jsx("button", { onClick: handleCloseModal, className: "text-xl text-gray-600 dark:text-gray-400 h-6 w-6", children: "\u00D7" })] }), isAddingSubType ? (_jsxs(_Fragment, { children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Code" }), _jsx("input", { type: "number", value: subCode, onChange: (e) => setSubCode(e.target.value), placeholder: "Enter Code", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Value" }), _jsx("input", { type: "text", value: subValue, onChange: (e) => setSubValue(e.target.value), placeholder: "Enter Value", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsxs("div", { className: "flex space-x-4 justify-end", children: [_jsx("button", { onClick: handleSubTypeSubmitClick, className: "px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600", children: editTaxonomyItem ? "Edit" : "Add" }), _jsx("button", { onClick: handleCloseModal, className: "px-8 py-2.5 leading-5 bg-gray-300 rounded-md", children: "Cancel" })] })] })) : (_jsxs(_Fragment, { children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Code" }), _jsx("input", { type: "number", value: newCode, onChange: (e) => setNewCode(e.target.value), placeholder: "Enter Code", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Value" }), _jsx("input", { type: "text", value: newValue, onChange: (e) => setNewValue(e.target.value), placeholder: "Enter Value", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsxs("div", { className: "flex space-x-4 justify-end", children: [_jsx("button", {
|
308
347
|
// onClick={
|
309
|
-
// editTaxonomyItem
|
310
|
-
// ? handleSubTypeEditClick
|
311
|
-
// : handleSubTypeAddClick
|
348
|
+
// editTaxonomyItem ? handleEditTaxClick : addTaxonomyClick
|
312
349
|
// }
|
313
|
-
onClick:
|
350
|
+
onClick: handleSubmitClick, className: "px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600", children: editTaxonomyItem || editTempTaxonomyItem ? "Edit" : "Add" }), _jsx("button", { onClick: handleCloseModal, className: "px-8 py-2.5 leading-5 bg-gray-300 rounded-md", children: "Cancel" })] })] }))] }) })] }));
|
314
351
|
};
|
315
352
|
export default TaxonomyForm;
|
package/package.json
CHANGED
@@ -323,46 +323,90 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
323
323
|
setIsAddingSubType(true);
|
324
324
|
};
|
325
325
|
|
326
|
-
const handleEditTaxClick = async () => {
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
};
|
326
|
+
// const handleEditTaxClick = async () => {
|
327
|
+
// try {
|
328
|
+
// await updateTaxonomyApi(
|
329
|
+
// url,
|
330
|
+
// selectedTaxonomyId,
|
331
|
+
// type,
|
332
|
+
// Number(newCode),
|
333
|
+
// newValue
|
334
|
+
// );
|
335
|
+
// alert("Taxonomy updated successfully");
|
336
|
+
// } catch (error) {
|
337
|
+
// console.error("Error updating Taxonomy:", error);
|
338
|
+
// }
|
339
|
+
// setIsModalOpen(false);
|
340
|
+
// setNewCode("");
|
341
|
+
// setNewValue("");
|
342
|
+
// const response = await fetchTaxonomiessApi(url);
|
343
|
+
// const filteredTaxonomies = (response as { type: string }[]).filter(
|
344
|
+
// (taxonomy: { type: string }) => taxonomy.type === type
|
345
|
+
// );
|
346
|
+
// setSimilarTaxonomies(filteredTaxonomies);
|
347
|
+
// };
|
348
|
+
|
349
|
+
// const addTaxonomyClick = async () => {
|
350
|
+
// if (!newCode || !newValue) {
|
351
|
+
// alert("Please fill out both Code and Value fields before adding.");
|
352
|
+
// return;
|
353
|
+
// }
|
354
|
+
// try {
|
355
|
+
// await addTaxonomyApi(url, type, Number(newCode), newValue);
|
356
|
+
|
357
|
+
// alert("Value added successfully");
|
358
|
+
// const response = await fetchTaxonomiessApi(url);
|
359
|
+
// const filteredTaxonomies = (response as { type: string }[]).filter(
|
360
|
+
// (taxonomy: { type: string }) => taxonomy.type === type
|
361
|
+
// );
|
362
|
+
// setSimilarTaxonomies(filteredTaxonomies);
|
363
|
+
// } catch (error) {
|
364
|
+
// console.error("Error adding value:", error);
|
365
|
+
// }
|
366
|
+
// setIsModalOpen(false);
|
367
|
+
// setNewCode("");
|
368
|
+
// setNewValue("");
|
369
|
+
// };
|
348
370
|
|
349
|
-
const
|
371
|
+
const handleSubmitClick = async () => {
|
350
372
|
if (!newCode || !newValue) {
|
351
|
-
alert("Please fill out both Code and Value fields before
|
373
|
+
alert("Please fill out both Code and Value fields before submitting.");
|
352
374
|
return;
|
353
375
|
}
|
376
|
+
|
354
377
|
try {
|
355
|
-
|
378
|
+
if (editTaxonomyItem || editTempTaxonomyItem) {
|
379
|
+
// Edit taxonomy logic
|
380
|
+
await updateTaxonomyApi(
|
381
|
+
url,
|
382
|
+
selectedTaxonomyId,
|
383
|
+
type,
|
384
|
+
Number(newCode),
|
385
|
+
newValue
|
386
|
+
);
|
387
|
+
alert("Taxonomy updated successfully");
|
388
|
+
} else {
|
389
|
+
// Add taxonomy logic
|
390
|
+
await addTaxonomyApi(url, type, Number(newCode), newValue);
|
391
|
+
alert("Value added successfully");
|
392
|
+
}
|
356
393
|
|
357
|
-
|
394
|
+
// Fetch and update similar taxonomies
|
358
395
|
const response = await fetchTaxonomiessApi(url);
|
359
396
|
const filteredTaxonomies = (response as { type: string }[]).filter(
|
360
397
|
(taxonomy: { type: string }) => taxonomy.type === type
|
361
398
|
);
|
362
399
|
setSimilarTaxonomies(filteredTaxonomies);
|
363
400
|
} catch (error) {
|
364
|
-
console.error(
|
401
|
+
console.error(
|
402
|
+
editTaxonomyItem || editTempTaxonomyItem
|
403
|
+
? "Error updating Taxonomy:"
|
404
|
+
: "Error adding value:",
|
405
|
+
error
|
406
|
+
);
|
365
407
|
}
|
408
|
+
|
409
|
+
// Reset modal and input fields
|
366
410
|
setIsModalOpen(false);
|
367
411
|
setNewCode("");
|
368
412
|
setNewValue("");
|
@@ -670,10 +714,11 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
670
714
|
</tbody>
|
671
715
|
</table>
|
672
716
|
</div>
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
717
|
+
|
718
|
+
<div className="flex space-x-4 mt-6 justify-start">
|
719
|
+
{similarTaxonomies.some(
|
720
|
+
(taxonomy) => taxonomy.isEdit && taxonomy.isMultiple
|
721
|
+
) && (
|
677
722
|
<button
|
678
723
|
type="button"
|
679
724
|
onClick={handleOpenModal}
|
@@ -682,15 +727,15 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
682
727
|
<FaPlus className="mr-2 font-medium" />
|
683
728
|
Add Multiple Values
|
684
729
|
</button>
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
</
|
730
|
+
)}
|
731
|
+
<button
|
732
|
+
onClick={handleCancelClick}
|
733
|
+
type="button"
|
734
|
+
className="px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600"
|
735
|
+
>
|
736
|
+
Cancel
|
737
|
+
</button>
|
738
|
+
</div>
|
694
739
|
</div>
|
695
740
|
)}
|
696
741
|
</div>
|
@@ -744,11 +789,6 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
744
789
|
/>
|
745
790
|
<div className="flex space-x-4 justify-end">
|
746
791
|
<button
|
747
|
-
// onClick={
|
748
|
-
// editTaxonomyItem
|
749
|
-
// ? handleSubTypeEditClick
|
750
|
-
// : handleSubTypeAddClick
|
751
|
-
// }
|
752
792
|
onClick={handleSubTypeSubmitClick}
|
753
793
|
className="px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600"
|
754
794
|
>
|
@@ -787,9 +827,10 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
787
827
|
|
788
828
|
<div className="flex space-x-4 justify-end">
|
789
829
|
<button
|
790
|
-
onClick={
|
791
|
-
|
792
|
-
}
|
830
|
+
// onClick={
|
831
|
+
// editTaxonomyItem ? handleEditTaxClick : addTaxonomyClick
|
832
|
+
// }
|
833
|
+
onClick={handleSubmitClick}
|
793
834
|
className="px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600"
|
794
835
|
>
|
795
836
|
{editTaxonomyItem || editTempTaxonomyItem ? "Edit" : "Add"}
|