eleven-solutions-common-website-unique-web 6.0.51 → 6.0.53
Sign up to get free protection for your applications and to get access to all the features.
@@ -251,14 +251,24 @@ const TaxonomyForm = () => {
|
|
251
251
|
setSubCode("");
|
252
252
|
setSubValue("");
|
253
253
|
});
|
254
|
-
const handleSubEdit = (index, id) => {
|
254
|
+
// const handleSubEdit = (index: number, id: string) => {
|
255
|
+
// setIsAddingSubType(false);
|
256
|
+
// const item = similarTaxonomies[index];
|
257
|
+
// setSelectedTaxonomyId(id);
|
258
|
+
// setEditTaxonomyItem(item);
|
259
|
+
// setSubType(item.type);
|
260
|
+
// setSubCode(item.code);
|
261
|
+
// setSubValue(item.value);
|
262
|
+
// setIsModalOpen(true);
|
263
|
+
// setIsAddingSubType(true);
|
264
|
+
// };
|
265
|
+
const handleSubEdit = (child) => {
|
255
266
|
setIsAddingSubType(false);
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
setSubValue(item.value);
|
267
|
+
setSelectedTaxonomyId(child.id);
|
268
|
+
setEditTaxonomyItem(child);
|
269
|
+
setSubType(child.type);
|
270
|
+
setSubCode(child.code);
|
271
|
+
setSubValue(child.value);
|
262
272
|
setIsModalOpen(true);
|
263
273
|
setIsAddingSubType(true);
|
264
274
|
};
|
@@ -303,12 +313,6 @@ const TaxonomyForm = () => {
|
|
303
313
|
console.error("Error deleting Taxonomy:", error);
|
304
314
|
}
|
305
315
|
});
|
306
|
-
useEffect(() => {
|
307
|
-
similarTaxonomies.forEach((taxonomy) => {
|
308
|
-
console.log("Taxonomy:", taxonomy);
|
309
|
-
console.log("Parent ID:", taxonomy.parentId);
|
310
|
-
});
|
311
|
-
}, [similarTaxonomies]);
|
312
316
|
return (_jsxs("div", { className: `${isEditMode && isMultiple ? "w-full" : "max-w-4xl"} p-6 mx-auto dark:bg-gray-800`, children: [_jsxs("div", { className: `transition duration-300 ${isModalOpen ? "filter blur-sm" : ""}`, children: [_jsx("h1", { className: "text-3xl font-bold text-center text-blue-600 capitalize dark:text-white mb-4", children: isEditMode ? "Edit Taxonomy" : "Add Taxonomy" }), _jsx("h1", { className: "text-2xl text-blue-600 capitalize dark:text-white mb-4", children: isEditMode ? `Taxonomy Type: ${type}` : "" }), !isMultiple && (_jsxs("form", { children: [!isEditMode && (_jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Type ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx("input", { required: true, value: inputType, onChange: (e) => setInputType(e.target.value), type: "text", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Enter Type" })] })), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Code ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx("input", { required: true, value: code, onChange: (e) => setCode(e.target.value === "" ? "" : Number(e.target.value)), type: "number", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Enter Code", disabled: similarTaxonomies.some((taxonomy) => taxonomy.isEdit === false) })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Value ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx("input", { required: true, value: value, onChange: (e) => setValue(e.target.value), type: "text", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Enter Value", disabled: similarTaxonomies.some((taxonomy) => taxonomy.isEdit === false) })] }), _jsxs("div", { className: "flex space-x-4 mt-6 justify-between", children: [_jsx("div", { children: isEditMode && (_jsx("div", { children: similarTaxonomies.some((taxonomy) => taxonomy.isEdit) && (_jsx("button", { type: "button", onClick: () => {
|
313
317
|
handleDeleteClick(id);
|
314
318
|
window.location.href = "/admin/taxinomies";
|
@@ -317,7 +321,11 @@ const TaxonomyForm = () => {
|
|
317
321
|
const hasChildren = allTaxonomies.some((item) => item.parentId === taxonomy.id);
|
318
322
|
return (_jsxs(React.Fragment, { children: [_jsxs("tr", { children: [_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: () => handleDeleteClick(taxonomy.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", { type: "button", onClick: () => handleEditClick(index, taxonomy.id), 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("button", { type: "button", onClick: () => handleAddSubType(index, taxonomy.id), className: "text-gray-500 transition-colors duration-200 dark:hover:text-blue-500 dark:text-gray-300 hover:text-blue-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: "M12 4.5v15m7.5-7.5h-15" }) }) })] }) }), _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: _jsxs("div", { className: "flex justify-between items-center", children: [_jsx("span", { children: taxonomy.value }), hasChildren && (_jsx("button", { type: "button", onClick: () => toggleRowExpansion(taxonomy.id), className: "text-gray-500 transition-colors duration-200 dark:hover:text-blue-600 dark:text-gray-300 hover:text-blue-500 focus:outline-none", children: expandedRows.indexOf(taxonomy.id) !== -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 8.25l-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 15.75l-7.5-7.5-7.5 7.5" }) })) }))] }) })] }, 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: [_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: "Actions" }), _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: "Sub Type" }), _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: "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
|
319
323
|
.filter((item) => item.parentId === taxonomy.id)
|
320
|
-
.map((child, key) => (_jsxs("tr", { children: [_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", { type: "button",
|
324
|
+
.map((child, key) => (_jsxs("tr", { children: [_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", { type: "button",
|
325
|
+
// onClick={() =>
|
326
|
+
// // handleSubEdit(key, child.id)
|
327
|
+
// }
|
328
|
+
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-4 text-sm font-medium text-gray-900 dark:text-white", children: child.type }), _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));
|
321
329
|
}) })] }) }), similarTaxonomies.some((taxonomy) => taxonomy.isEdit) && (_jsx("div", { className: "flex space-x-4 mt-6 justify-start", children: _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"] }) }))] })), isEditMode && (_jsx(_Fragment, { children: tempTaxonomy.length > 0 && (_jsxs("div", { className: "flex-grow ml-0 mt-4 w-full", children: [_jsx("div", { className: "overflow-hidden border border-gray-200 dark:border-gray-700 md:rounded-lg mt-6", children: _jsxs("table", { className: "min-w-full divide-y divide-gray-200 dark:divide-gray-700", children: [_jsx("thead", { className: "bg-gray-50 dark:bg-gray-800", children: _jsxs("tr", { children: [_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", children: "Edit/Delete" }), _jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left text-gray-500 dark:text-gray-400", children: "Code" }), _jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left text-gray-500 dark:text-gray-400", children: "Value" })] }) }), _jsx("tbody", { className: "bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-gray-700", children: [...tempTaxonomy].map((item, index) => (_jsxs("tr", { children: [_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: () => {
|
322
330
|
const newTempTaxonomy = [...tempTaxonomy];
|
323
331
|
newTempTaxonomy.splice(index, 1);
|
package/package.json
CHANGED
@@ -308,16 +308,33 @@ const TaxonomyForm = () => {
|
|
308
308
|
setSubValue("");
|
309
309
|
};
|
310
310
|
|
311
|
-
const handleSubEdit = (index: number, id: string) => {
|
312
|
-
|
311
|
+
// const handleSubEdit = (index: number, id: string) => {
|
312
|
+
// setIsAddingSubType(false);
|
313
313
|
|
314
|
-
|
315
|
-
|
314
|
+
// const item = similarTaxonomies[index];
|
315
|
+
// setSelectedTaxonomyId(id);
|
316
316
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
317
|
+
// setEditTaxonomyItem(item);
|
318
|
+
// setSubType(item.type);
|
319
|
+
// setSubCode(item.code);
|
320
|
+
// setSubValue(item.value);
|
321
|
+
// setIsModalOpen(true);
|
322
|
+
// setIsAddingSubType(true);
|
323
|
+
// };
|
324
|
+
|
325
|
+
const handleSubEdit = (child: {
|
326
|
+
id: string;
|
327
|
+
type: string;
|
328
|
+
code: string;
|
329
|
+
value: string;
|
330
|
+
}) => {
|
331
|
+
setIsAddingSubType(false);
|
332
|
+
|
333
|
+
setSelectedTaxonomyId(child.id);
|
334
|
+
setEditTaxonomyItem(child);
|
335
|
+
setSubType(child.type);
|
336
|
+
setSubCode(child.code);
|
337
|
+
setSubValue(child.value);
|
321
338
|
setIsModalOpen(true);
|
322
339
|
setIsAddingSubType(true);
|
323
340
|
};
|
@@ -374,13 +391,6 @@ const TaxonomyForm = () => {
|
|
374
391
|
}
|
375
392
|
};
|
376
393
|
|
377
|
-
useEffect(() => {
|
378
|
-
similarTaxonomies.forEach((taxonomy) => {
|
379
|
-
console.log("Taxonomy:", taxonomy);
|
380
|
-
console.log("Parent ID:", taxonomy.parentId);
|
381
|
-
});
|
382
|
-
}, [similarTaxonomies]);
|
383
|
-
|
384
394
|
return (
|
385
395
|
<div
|
386
396
|
className={`${
|
@@ -710,8 +720,11 @@ const TaxonomyForm = () => {
|
|
710
720
|
|
711
721
|
<button
|
712
722
|
type="button"
|
723
|
+
// onClick={() =>
|
724
|
+
// // handleSubEdit(key, child.id)
|
725
|
+
// }
|
713
726
|
onClick={() =>
|
714
|
-
handleSubEdit(
|
727
|
+
handleSubEdit(child)
|
715
728
|
}
|
716
729
|
className="text-gray-500 transition-colors duration-200 dark:hover:text-yellow-500 dark:text-gray-300 hover:text-yellow-500 focus:outline-none"
|
717
730
|
>
|