eleven-solutions-common-website-unique-web 10.0.8 → 10.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/admin/Taxionomies.d.ts +1 -3
- package/dist/components/admin/Taxionomies.js +3 -3
- package/dist/components/admin/TaxonomyForm.d.ts +1 -3
- package/dist/components/admin/TaxonomyForm.js +20 -20
- package/dist/components/admin/UserForm.d.ts +1 -5
- package/dist/components/admin/UserForm.js +4 -4
- package/dist/components/admin/Users.d.ts +1 -5
- package/dist/components/admin/Users.js +6 -6
- package/dist/components/api/taxonomy.d.ts +8 -8
- package/dist/components/api/taxonomy.js +16 -16
- package/dist/components/api/user.d.ts +5 -5
- package/dist/components/api/user.js +10 -10
- package/dist/components/login/Header.js +1 -5
- package/package.json +1 -1
- package/src/components/admin/Taxionomies.tsx +3 -3
- package/src/components/admin/TaxonomyForm.tsx +17 -20
- package/src/components/admin/UserForm.tsx +4 -8
- package/src/components/admin/Users.tsx +4 -8
- package/src/components/api/taxonomy.ts +12 -16
- package/src/components/api/user.ts +8 -10
- package/src/components/login/Header.tsx +0 -8
@@ -11,10 +11,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { useState, useEffect } from "react";
|
12
12
|
import { FaPlus } from "react-icons/fa";
|
13
13
|
import { fetchTaxonomiessApi } from "../api/taxonomy";
|
14
|
-
const Taxionomies = (
|
14
|
+
const Taxionomies = () => {
|
15
15
|
const [taxonomy, setTaxonomy] = useState([]);
|
16
16
|
const fetchTaxonomiesData = () => __awaiter(void 0, void 0, void 0, function* () {
|
17
|
-
const data = yield fetchTaxonomiessApi(
|
17
|
+
const data = yield fetchTaxonomiessApi();
|
18
18
|
if (data) {
|
19
19
|
const uniqueTaxonomies = data.reduce((acc, item) => {
|
20
20
|
if (!item.parentId &&
|
@@ -62,7 +62,7 @@ const Taxionomies = ({ url }) => {
|
|
62
62
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
63
63
|
};
|
64
64
|
return (_jsxs("div", { className: "container px-4 mx-auto mt-6 h-full", children: [_jsx("div", { className: "w-3/4", children: _jsx("h1", { className: "text-3xl font-bold text-blue-600 mb-5", children: "Taxonomy" }) }), _jsx("div", { className: "flex-grow ml-0 w-full mt-10", children: _jsxs("form", { className: "w-full ", children: [_jsx("label", { htmlFor: "default-search", className: "mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white", children: "Search" }), _jsxs("div", { className: "relative w-full", children: [_jsx("div", { className: "absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none", children: _jsx("svg", { className: "w-4 h-4 text-gray-500 dark:text-gray-400", "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 20 20", children: _jsx("path", { stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z" }) }) }), _jsx("input", { type: "search", id: "default-search", className: "inline-block min-w-full p-3 ps-10 outline-none text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500", placeholder: "Search Taxonomies", required: true }), _jsx("button", { type: "submit", className: "text-white absolute end-1.5 bottom-1.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800", children: "Search" })] })] }) }), _jsx("div", { className: "flex-grow ml-0 w-3/4", children: _jsx("form", { className: "w-auto" }) }), _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", style: { width: "200px" }, children: "Actions" }), _jsx("th", { scope: "col", className: "py-3.5 px-4 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Type" })] }) }), _jsx("tbody", { className: "bg-white divide-y divide-gray-200 dark:divide-gray-700 dark:bg-gray-900", children: paginatedTaxonomies
|
65
|
-
.filter((taxonomy) => taxonomy.isView)
|
65
|
+
.filter((taxonomy) => taxonomy.isView) // Exclude taxonomies where isView is true
|
66
66
|
.map((taxonomy, index) => (_jsxs("tr", { children: [_jsx("td", { className: "px-4 py-4 text-sm whitespace-nowrap", children: _jsx("div", { className: "flex items-center gap-x-6", children: taxonomy.isEdit ? (_jsx("button", { type: "button", onClick: (event) => {
|
67
67
|
handleViewClick(event, "/admin/taxinomies/taxonomyform?", taxonomy.id, taxonomy.type);
|
68
68
|
}, 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", "stroke-width": "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "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" }) }) })) : taxonomy.isView ? (_jsx("button", { onClick: (event) => {
|
@@ -12,7 +12,7 @@ import React from "react";
|
|
12
12
|
import { useState, useEffect } from "react";
|
13
13
|
import { addTaxonomyApi, fetchTaxonomyByIdApi, updateTaxonomyApi, fetchTaxonomiessApi, addMultipleTaxonomiesApi, deleteTaxonomyApi, isMultipleApi, addSubTypeApi, } from "../api/taxonomy";
|
14
14
|
import { FaPlus } from "react-icons/fa";
|
15
|
-
const TaxonomyForm = (
|
15
|
+
const TaxonomyForm = () => {
|
16
16
|
const [type, setType] = useState("");
|
17
17
|
const [inputType, setInputType] = useState("");
|
18
18
|
const [code, setCode] = useState("");
|
@@ -36,7 +36,7 @@ const TaxonomyForm = ({ url }) => {
|
|
36
36
|
useEffect(() => {
|
37
37
|
const fetchAllTaxonomies = () => __awaiter(void 0, void 0, void 0, function* () {
|
38
38
|
try {
|
39
|
-
const fetchedTaxonomies = yield fetchTaxonomiessApi(
|
39
|
+
const fetchedTaxonomies = yield fetchTaxonomiessApi();
|
40
40
|
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
41
41
|
setAllTaxonomies(fetchedTaxonomies);
|
42
42
|
}
|
@@ -54,9 +54,9 @@ const TaxonomyForm = ({ url }) => {
|
|
54
54
|
};
|
55
55
|
const handleDeleteSubTypeClick = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
56
56
|
try {
|
57
|
-
yield deleteTaxonomyApi(
|
57
|
+
yield deleteTaxonomyApi(id);
|
58
58
|
alert("Taxonomy deleted successfully");
|
59
|
-
const fetchedTaxonomies = yield fetchTaxonomiessApi(
|
59
|
+
const fetchedTaxonomies = yield fetchTaxonomiessApi();
|
60
60
|
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
61
61
|
setAllTaxonomies(fetchedTaxonomies);
|
62
62
|
}
|
@@ -81,7 +81,7 @@ const TaxonomyForm = ({ url }) => {
|
|
81
81
|
if (id) {
|
82
82
|
const fetchTaxonomyData = () => __awaiter(void 0, void 0, void 0, function* () {
|
83
83
|
try {
|
84
|
-
const fetchedTaxonomy = yield fetchTaxonomyByIdApi(
|
84
|
+
const fetchedTaxonomy = yield fetchTaxonomyByIdApi(id);
|
85
85
|
if (fetchedTaxonomy) {
|
86
86
|
const taxonomy = fetchedTaxonomy;
|
87
87
|
setIsEditMode(true);
|
@@ -101,7 +101,7 @@ const TaxonomyForm = ({ url }) => {
|
|
101
101
|
useEffect(() => {
|
102
102
|
const handleFetchSimilarTaxonomies = () => __awaiter(void 0, void 0, void 0, function* () {
|
103
103
|
try {
|
104
|
-
const response = yield fetchTaxonomiessApi(
|
104
|
+
const response = yield fetchTaxonomiessApi();
|
105
105
|
const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === type);
|
106
106
|
setSimilarTaxonomies(filteredTaxonomies);
|
107
107
|
}
|
@@ -122,12 +122,12 @@ const TaxonomyForm = ({ url }) => {
|
|
122
122
|
event.preventDefault();
|
123
123
|
try {
|
124
124
|
if (isEditMode) {
|
125
|
-
yield addMultipleTaxonomiesApi(
|
125
|
+
yield addMultipleTaxonomiesApi(tempTaxonomy);
|
126
126
|
setTempTaxonomy([]);
|
127
127
|
alert("Taxonomies saved successfully");
|
128
128
|
}
|
129
129
|
else {
|
130
|
-
yield addTaxonomyApi(
|
130
|
+
yield addTaxonomyApi(inputType, Number(code), value);
|
131
131
|
alert("Taxonomy added successfully");
|
132
132
|
}
|
133
133
|
window.history.pushState({}, "", "/admin/taxinomies");
|
@@ -145,11 +145,11 @@ const TaxonomyForm = ({ url }) => {
|
|
145
145
|
return;
|
146
146
|
try {
|
147
147
|
if (isEditMode) {
|
148
|
-
yield updateTaxonomyApi(
|
148
|
+
yield updateTaxonomyApi(id, inputType, Number(code), value);
|
149
149
|
alert("Taxonomy updated successfully");
|
150
150
|
}
|
151
151
|
else {
|
152
|
-
yield addTaxonomyApi(
|
152
|
+
yield addTaxonomyApi(inputType, Number(code), value);
|
153
153
|
alert("Taxonomy added successfully");
|
154
154
|
}
|
155
155
|
window.location.href = "/admin/taxinomies";
|
@@ -162,7 +162,7 @@ const TaxonomyForm = ({ url }) => {
|
|
162
162
|
useEffect(() => {
|
163
163
|
const fetchIsMultiple = () => __awaiter(void 0, void 0, void 0, function* () {
|
164
164
|
try {
|
165
|
-
const result = yield isMultipleApi(
|
165
|
+
const result = yield isMultipleApi(type);
|
166
166
|
setIsMultiple(typeof result === "boolean");
|
167
167
|
}
|
168
168
|
catch (error) {
|
@@ -237,9 +237,9 @@ const TaxonomyForm = ({ url }) => {
|
|
237
237
|
};
|
238
238
|
const handleSubTypeAddClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
239
239
|
try {
|
240
|
-
yield addSubTypeApi(
|
240
|
+
yield addSubTypeApi(selectedTaxonomyId, subType, Number(subCode), subValue);
|
241
241
|
alert("SubType added successfully");
|
242
|
-
const fetchedTaxonomies = yield fetchTaxonomiessApi(
|
242
|
+
const fetchedTaxonomies = yield fetchTaxonomiessApi();
|
243
243
|
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
244
244
|
setAllTaxonomies(fetchedTaxonomies);
|
245
245
|
}
|
@@ -254,9 +254,9 @@ const TaxonomyForm = ({ url }) => {
|
|
254
254
|
});
|
255
255
|
const handleSubTypeEditClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
256
256
|
try {
|
257
|
-
yield updateTaxonomyApi(
|
257
|
+
yield updateTaxonomyApi(selectedTaxonomyId, subType, Number(subCode), subValue);
|
258
258
|
alert("SubType edited successfully");
|
259
|
-
const fetchedTaxonomies = yield fetchTaxonomiessApi(
|
259
|
+
const fetchedTaxonomies = yield fetchTaxonomiessApi();
|
260
260
|
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
261
261
|
setAllTaxonomies(fetchedTaxonomies);
|
262
262
|
}
|
@@ -280,14 +280,14 @@ const TaxonomyForm = ({ url }) => {
|
|
280
280
|
};
|
281
281
|
const handleEditTaxClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
282
282
|
try {
|
283
|
-
yield updateTaxonomyApi(
|
283
|
+
yield updateTaxonomyApi(selectedTaxonomyId, type, Number(newCode), newValue);
|
284
284
|
alert("Taxonomy updated successfully");
|
285
285
|
}
|
286
286
|
catch (error) {
|
287
287
|
console.error("Error updating Taxonomy:", error);
|
288
288
|
}
|
289
289
|
setIsModalOpen(false);
|
290
|
-
const response = yield fetchTaxonomiessApi(
|
290
|
+
const response = yield fetchTaxonomiessApi();
|
291
291
|
const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === type);
|
292
292
|
setSimilarTaxonomies(filteredTaxonomies);
|
293
293
|
});
|
@@ -297,10 +297,10 @@ const TaxonomyForm = ({ url }) => {
|
|
297
297
|
return;
|
298
298
|
}
|
299
299
|
try {
|
300
|
-
yield addMultipleTaxonomiesApi(
|
300
|
+
yield addMultipleTaxonomiesApi(tempTaxonomy);
|
301
301
|
setTempTaxonomy([]);
|
302
302
|
alert("Multiple taxonomies added successfully");
|
303
|
-
const response = yield fetchTaxonomiessApi(
|
303
|
+
const response = yield fetchTaxonomiessApi();
|
304
304
|
const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === inputType);
|
305
305
|
setSimilarTaxonomies(filteredTaxonomies);
|
306
306
|
}
|
@@ -311,7 +311,7 @@ const TaxonomyForm = ({ url }) => {
|
|
311
311
|
});
|
312
312
|
const handleDeleteClick = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
313
313
|
try {
|
314
|
-
yield deleteTaxonomyApi(
|
314
|
+
yield deleteTaxonomyApi(id);
|
315
315
|
alert("Taxonomy deleted successfully");
|
316
316
|
setSimilarTaxonomies((prevTaxonomies) => prevTaxonomies.filter((taxonomy) => taxonomy.id !== id));
|
317
317
|
}
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
11
11
|
import { useState, useEffect } from "react";
|
12
12
|
import { addUserApi, updateUserApi, fetchUserByIdApi } from "../api/user";
|
13
|
-
const UserForm = (
|
13
|
+
const UserForm = () => {
|
14
14
|
const [userName, setUserName] = useState("");
|
15
15
|
const [email, setEmail] = useState("");
|
16
16
|
const [mobile, setMobile] = useState("");
|
@@ -30,7 +30,7 @@ const UserForm = ({ url }) => {
|
|
30
30
|
if (id) {
|
31
31
|
const fetchUserData = () => __awaiter(void 0, void 0, void 0, function* () {
|
32
32
|
try {
|
33
|
-
const fetchedUser = yield fetchUserByIdApi(
|
33
|
+
const fetchedUser = yield fetchUserByIdApi(id);
|
34
34
|
if (fetchedUser) {
|
35
35
|
const user = fetchedUser;
|
36
36
|
setIsEditMode(true);
|
@@ -54,11 +54,11 @@ const UserForm = ({ url }) => {
|
|
54
54
|
return;
|
55
55
|
try {
|
56
56
|
if (isEditMode) {
|
57
|
-
yield updateUserApi(
|
57
|
+
yield updateUserApi(id, userName, mobile, address, roleType);
|
58
58
|
alert("User updated successfully");
|
59
59
|
}
|
60
60
|
else {
|
61
|
-
yield addUserApi(
|
61
|
+
yield addUserApi(userName, email, mobile, address, roleType);
|
62
62
|
alert("User added successfully");
|
63
63
|
}
|
64
64
|
// window.location.href = "/admin/users";
|
@@ -11,10 +11,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { useState, useEffect } from "react";
|
12
12
|
import { FaPlus } from "react-icons/fa";
|
13
13
|
import { fetchUsersApi, deleteUserApi } from "../api/user";
|
14
|
-
|
14
|
+
function Users() {
|
15
15
|
const [users, setUsers] = useState([]);
|
16
|
-
const fetchUsersData = () => __awaiter(
|
17
|
-
const data = yield fetchUsersApi(
|
16
|
+
const fetchUsersData = () => __awaiter(this, void 0, void 0, function* () {
|
17
|
+
const data = yield fetchUsersApi();
|
18
18
|
if (data) {
|
19
19
|
setUsers(data);
|
20
20
|
}
|
@@ -47,9 +47,9 @@ const Users = ({ url }) => {
|
|
47
47
|
setCurrentPage(pageNumber);
|
48
48
|
};
|
49
49
|
const paginatedUsers = users.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage);
|
50
|
-
const handleDeleteClick = (id) => __awaiter(
|
50
|
+
const handleDeleteClick = (id) => __awaiter(this, void 0, void 0, function* () {
|
51
51
|
try {
|
52
|
-
yield deleteUserApi(
|
52
|
+
yield deleteUserApi(id);
|
53
53
|
alert("User deleted successfully");
|
54
54
|
fetchUsersData();
|
55
55
|
}
|
@@ -65,5 +65,5 @@ const Users = ({ url }) => {
|
|
65
65
|
return (_jsxs("div", { className: "container px-4 mx-auto mt-6", children: [_jsx("div", { className: "w-3/4", children: _jsx("h1", { className: "text-3xl font-bold text-blue-600 mb-5", children: "Users" }) }), _jsx("div", { className: "flex-grow ml-0 w-full mt-10", children: _jsxs("form", { className: "w-full ", children: [_jsx("label", { htmlFor: "default-search", className: "mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white", children: "Search" }), _jsxs("div", { className: "relative w-full", children: [_jsx("div", { className: "absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none", children: _jsx("svg", { className: "w-4 h-4 text-gray-500 dark:text-gray-400", "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 20 20", children: _jsx("path", { stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z" }) }) }), _jsx("input", { type: "search", id: "default-search", className: "inline-block min-w-full p-3 ps-10 outline-none text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500", placeholder: "Search Users", required: true }), _jsx("button", { type: "submit", className: "text-white absolute end-1.5 bottom-1.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800", children: "Search" })] })] }) }), _jsx("div", { className: "flex-grow ml-0 w-3/4", children: _jsx("form", { className: "w-auto" }) }), _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: "py-3.5 px-4 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: _jsx("div", { className: "flex items-center gap-x-3", children: _jsx("span", { children: "Name" }) }) }), _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: _jsx("button", { className: "flex items-center gap-x-2", children: _jsx("span", { children: "Email" }) }) }), _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: _jsx("button", { className: "flex items-center gap-x-2", children: _jsx("span", { children: "Mobile" }) }) }), _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: "Address" }), _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: "Role Type" })] }) }), _jsx("tbody", { className: "bg-white divide-y divide-gray-200 dark:divide-gray-700 dark:bg-gray-900", children: paginatedUsers.map((user, 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", { onClick: () => handleDeleteClick(user.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", "stroke-width": "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "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: (event) => handleEditClick(event, "/admin/users/userform?id=", user.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("td", { className: "px-4 py-4 text-sm font-medium text-gray-700 whitespace-nowrap", children: _jsx("div", { className: "inline-flex items-center gap-x-3", children: _jsx("div", { className: "flex items-center gap-x-2", children: _jsx("div", { children: _jsx("h2", { className: " text-sm font-medium text-gray-800 dark:text-white ", children: user.name }) }) }) }) }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap", children: user.email }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap", children: (user === null || user === void 0 ? void 0 : user.mobile) || "Not Provided" }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap", children: (user === null || user === void 0 ? void 0 : user.address) || "Not Provided" }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap", children: user.roleType === "1" ? "Guest" : "Admin" })] }, user.id || index))) })] }) }), _jsxs("div", { className: "flex items-center justify-between mt-6", children: [_jsxs("button", { onClick: handlePreviousPage, disabled: currentPage === 1, className: "flex items-center px-5 py-2 text-sm text-gray-700 capitalize transition-colors duration-200 bg-white border rounded-md gap-x-2 hover:bg-gray-100 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800", children: [_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", className: "w-5 h-5 rtl:-scale-x-100", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6.75 15.75L3 12m0 0l3.75-3.75M3 12h18" }) }), _jsx("span", { children: "previous" })] }), _jsx("div", { className: "items-center hidden lg:flex gap-x-3", children: Array.from({ length: totalPages }, (_, index) => (_jsx("button", { onClick: () => handlePageClick(index + 1), className: `px-2 py-1 text-sm ${currentPage === index + 1
|
66
66
|
? "text-blue-500 bg-blue-100"
|
67
67
|
: "text-gray-500 hover:bg-gray-100"} rounded-md`, children: index + 1 }, index + 1))) }), _jsxs("button", { onClick: handleNextPage, disabled: currentPage === totalPages, className: "flex items-center px-5 py-2 text-sm text-gray-700 capitalize transition-colors duration-200 bg-white border rounded-md gap-x-2 hover:bg-gray-100 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800", children: [_jsx("span", { children: "Next" }), _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", className: "w-5 h-5 rtl:-scale-x-100", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M17.25 8.25L21 12m0 0l-3.75 3.75M21 12H3" }) })] })] }), _jsx("div", { className: "flex-grow ml-0 mt-4 w-0", children: _jsxs("button", { type: "button", onClick: (event) => handleNavigation(event, "/admin/users/userform"), 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" }), "User"] }) })] })] }));
|
68
|
-
}
|
68
|
+
}
|
69
69
|
export default Users;
|
@@ -1,14 +1,14 @@
|
|
1
|
-
export declare const addTaxonomyApi: (
|
2
|
-
export declare const fetchTaxonomiessApi: (
|
3
|
-
export declare const deleteTaxonomyApi: (
|
1
|
+
export declare const addTaxonomyApi: (type: string, code: number, value: string) => Promise<Axios.AxiosXHR<unknown>>;
|
2
|
+
export declare const fetchTaxonomiessApi: () => Promise<unknown>;
|
3
|
+
export declare const deleteTaxonomyApi: (id: string) => Promise<{
|
4
4
|
id: string;
|
5
5
|
}>;
|
6
|
-
export declare const fetchTaxonomyByIdApi: (
|
7
|
-
export declare const updateTaxonomyApi: (
|
8
|
-
export declare const addMultipleTaxonomiesApi: (
|
6
|
+
export declare const fetchTaxonomyByIdApi: (taxonomyId: string) => Promise<unknown>;
|
7
|
+
export declare const updateTaxonomyApi: (id: string, type: string, code: number, value: string) => Promise<unknown>;
|
8
|
+
export declare const addMultipleTaxonomiesApi: (taxonomies: {
|
9
9
|
type: string;
|
10
10
|
code: number;
|
11
11
|
value: string;
|
12
12
|
}[]) => Promise<Axios.AxiosXHR<unknown>>;
|
13
|
-
export declare const isMultipleApi: (
|
14
|
-
export declare const addSubTypeApi: (
|
13
|
+
export declare const isMultipleApi: (type: string) => Promise<unknown>;
|
14
|
+
export declare const addSubTypeApi: (parentid: string, type: string, code: number, value: string) => Promise<Axios.AxiosXHR<unknown>>;
|
@@ -11,10 +11,10 @@ import axios from "axios";
|
|
11
11
|
import Cookies from "universal-cookie";
|
12
12
|
const apiUrl = "http://localhost:5260";
|
13
13
|
const cookies = new Cookies();
|
14
|
-
export const addTaxonomyApi = (
|
14
|
+
export const addTaxonomyApi = (type, code, value) => __awaiter(void 0, void 0, void 0, function* () {
|
15
15
|
const token = cookies.get("authToken");
|
16
16
|
try {
|
17
|
-
const response = yield axios.post(`${
|
17
|
+
const response = yield axios.post(`${apiUrl}/taxonomy/add`, {
|
18
18
|
Type: type,
|
19
19
|
Code: code,
|
20
20
|
Value: value,
|
@@ -30,10 +30,10 @@ export const addTaxonomyApi = (url, type, code, value) => __awaiter(void 0, void
|
|
30
30
|
throw error;
|
31
31
|
}
|
32
32
|
});
|
33
|
-
export const fetchTaxonomiessApi = (
|
33
|
+
export const fetchTaxonomiessApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
34
34
|
const token = cookies.get("authToken");
|
35
35
|
try {
|
36
|
-
const response = yield axios.get(`${
|
36
|
+
const response = yield axios.get(`${apiUrl}/taxonomy/gettaxonomy`, {
|
37
37
|
headers: {
|
38
38
|
Authorization: `Bearer ${token}`,
|
39
39
|
},
|
@@ -45,12 +45,12 @@ export const fetchTaxonomiessApi = (url) => __awaiter(void 0, void 0, void 0, fu
|
|
45
45
|
return false;
|
46
46
|
}
|
47
47
|
});
|
48
|
-
export const deleteTaxonomyApi = (
|
48
|
+
export const deleteTaxonomyApi = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
49
49
|
const token = cookies.get("authToken");
|
50
50
|
try {
|
51
51
|
const response = yield axios.request({
|
52
52
|
method: "DELETE",
|
53
|
-
url: `${
|
53
|
+
url: `${apiUrl}/taxonomy/delete`,
|
54
54
|
headers: {
|
55
55
|
Authorization: `Bearer ${token}`,
|
56
56
|
"Content-Type": "application/json",
|
@@ -66,11 +66,11 @@ export const deleteTaxonomyApi = (url, id) => __awaiter(void 0, void 0, void 0,
|
|
66
66
|
throw error;
|
67
67
|
}
|
68
68
|
});
|
69
|
-
export const fetchTaxonomyByIdApi = (
|
69
|
+
export const fetchTaxonomyByIdApi = (taxonomyId) => __awaiter(void 0, void 0, void 0, function* () {
|
70
70
|
const cookies = new Cookies();
|
71
71
|
const token = cookies.get("authToken");
|
72
72
|
try {
|
73
|
-
const response = yield axios.get(`${
|
73
|
+
const response = yield axios.get(`${apiUrl}/taxonomy/gettaxonomybyid/${taxonomyId}`, {
|
74
74
|
headers: {
|
75
75
|
Authorization: `Bearer ${token}`,
|
76
76
|
},
|
@@ -82,10 +82,10 @@ export const fetchTaxonomyByIdApi = (url, taxonomyId) => __awaiter(void 0, void
|
|
82
82
|
return false;
|
83
83
|
}
|
84
84
|
});
|
85
|
-
export const updateTaxonomyApi = (
|
85
|
+
export const updateTaxonomyApi = (id, type, code, value) => __awaiter(void 0, void 0, void 0, function* () {
|
86
86
|
const token = cookies.get("authToken");
|
87
87
|
try {
|
88
|
-
const response = yield axios.post(`${
|
88
|
+
const response = yield axios.post(`${apiUrl}/taxonomy/updatetaxonomy`, {
|
89
89
|
Id: id,
|
90
90
|
Type: type,
|
91
91
|
Code: code,
|
@@ -101,11 +101,11 @@ export const updateTaxonomyApi = (url, id, type, code, value) => __awaiter(void
|
|
101
101
|
throw error;
|
102
102
|
}
|
103
103
|
});
|
104
|
-
export const addMultipleTaxonomiesApi = (
|
104
|
+
export const addMultipleTaxonomiesApi = (taxonomies) => __awaiter(void 0, void 0, void 0, function* () {
|
105
105
|
var _a;
|
106
106
|
const token = cookies.get("authToken");
|
107
107
|
try {
|
108
|
-
const response = yield axios.post(`${
|
108
|
+
const response = yield axios.post(`${apiUrl}/taxonomy/addmultipletaxonomies`, taxonomies, {
|
109
109
|
headers: {
|
110
110
|
Authorization: `Bearer ${token}`,
|
111
111
|
"Content-Type": "application/json",
|
@@ -118,10 +118,10 @@ export const addMultipleTaxonomiesApi = (url, taxonomies) => __awaiter(void 0, v
|
|
118
118
|
throw error;
|
119
119
|
}
|
120
120
|
});
|
121
|
-
export const isMultipleApi = (
|
121
|
+
export const isMultipleApi = (type) => __awaiter(void 0, void 0, void 0, function* () {
|
122
122
|
const token = cookies.get("authToken");
|
123
123
|
try {
|
124
|
-
const response = yield axios.get(`${
|
124
|
+
const response = yield axios.get(`${apiUrl}/taxonomy/IsTaxonomyMultipleByType/${type}`, {
|
125
125
|
headers: {
|
126
126
|
Authorization: `Bearer ${token}`,
|
127
127
|
},
|
@@ -133,10 +133,10 @@ export const isMultipleApi = (url, type) => __awaiter(void 0, void 0, void 0, fu
|
|
133
133
|
throw error;
|
134
134
|
}
|
135
135
|
});
|
136
|
-
export const addSubTypeApi = (
|
136
|
+
export const addSubTypeApi = (parentid, type, code, value) => __awaiter(void 0, void 0, void 0, function* () {
|
137
137
|
const token = cookies.get("authToken");
|
138
138
|
try {
|
139
|
-
const response = yield axios.post(`${
|
139
|
+
const response = yield axios.post(`${apiUrl}/taxonomy/addsubtype`, {
|
140
140
|
ParentId: parentid,
|
141
141
|
Type: type,
|
142
142
|
Code: code,
|
@@ -1,7 +1,7 @@
|
|
1
|
-
export declare const addUserApi: (
|
2
|
-
export declare const fetchUsersApi: (
|
3
|
-
export declare const fetchUserByIdApi: (
|
4
|
-
export declare const deleteUserApi: (
|
1
|
+
export declare const addUserApi: (name: string, email: string, mobile: string, address: string, roleType: string) => Promise<Axios.AxiosXHR<unknown>>;
|
2
|
+
export declare const fetchUsersApi: () => Promise<unknown>;
|
3
|
+
export declare const fetchUserByIdApi: (userId: string) => Promise<unknown>;
|
4
|
+
export declare const deleteUserApi: (id: string) => Promise<{
|
5
5
|
id: string;
|
6
6
|
}>;
|
7
|
-
export declare const updateUserApi: (
|
7
|
+
export declare const updateUserApi: (id: string, name: string, mobile: string, address: string, roleType: string) => Promise<unknown>;
|
@@ -11,10 +11,10 @@ import axios from "axios";
|
|
11
11
|
import Cookies from "universal-cookie";
|
12
12
|
const apiUrl = "http://localhost:5260";
|
13
13
|
const cookies = new Cookies();
|
14
|
-
export const addUserApi = (
|
14
|
+
export const addUserApi = (name, email, mobile, address, roleType) => __awaiter(void 0, void 0, void 0, function* () {
|
15
15
|
const token = cookies.get("token");
|
16
16
|
try {
|
17
|
-
const response = yield axios.post(`${
|
17
|
+
const response = yield axios.post(`${apiUrl}/login/adduser`, {
|
18
18
|
Name: name,
|
19
19
|
Email: email,
|
20
20
|
Mobile: mobile,
|
@@ -32,10 +32,10 @@ export const addUserApi = (url, name, email, mobile, address, roleType) => __awa
|
|
32
32
|
throw error;
|
33
33
|
}
|
34
34
|
});
|
35
|
-
export const fetchUsersApi = (
|
35
|
+
export const fetchUsersApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
36
36
|
const token = cookies.get("token");
|
37
37
|
try {
|
38
|
-
const response = yield axios.get(`${
|
38
|
+
const response = yield axios.get(`${apiUrl}/login/getuser`, {
|
39
39
|
headers: {
|
40
40
|
Authorization: `Bearer ${token}`,
|
41
41
|
},
|
@@ -47,11 +47,11 @@ export const fetchUsersApi = (url) => __awaiter(void 0, void 0, void 0, function
|
|
47
47
|
return false;
|
48
48
|
}
|
49
49
|
});
|
50
|
-
export const fetchUserByIdApi = (
|
50
|
+
export const fetchUserByIdApi = (userId) => __awaiter(void 0, void 0, void 0, function* () {
|
51
51
|
const cookies = new Cookies();
|
52
52
|
const token = cookies.get("token");
|
53
53
|
try {
|
54
|
-
const response = yield axios.get(`${
|
54
|
+
const response = yield axios.get(`${apiUrl}/login/getuserbyid/${userId}`, {
|
55
55
|
headers: {
|
56
56
|
Authorization: `Bearer ${token}`,
|
57
57
|
},
|
@@ -63,12 +63,12 @@ export const fetchUserByIdApi = (url, userId) => __awaiter(void 0, void 0, void
|
|
63
63
|
return false;
|
64
64
|
}
|
65
65
|
});
|
66
|
-
export const deleteUserApi = (
|
66
|
+
export const deleteUserApi = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
67
67
|
const token = cookies.get("token");
|
68
68
|
try {
|
69
69
|
const response = yield axios.request({
|
70
70
|
method: "DELETE",
|
71
|
-
url: `${
|
71
|
+
url: `${apiUrl}/login/delete`,
|
72
72
|
headers: {
|
73
73
|
Authorization: `Bearer ${token}`,
|
74
74
|
"Content-Type": "application/json",
|
@@ -84,10 +84,10 @@ export const deleteUserApi = (url, id) => __awaiter(void 0, void 0, void 0, func
|
|
84
84
|
throw error;
|
85
85
|
}
|
86
86
|
});
|
87
|
-
export const updateUserApi = (
|
87
|
+
export const updateUserApi = (id, name, mobile, address, roleType) => __awaiter(void 0, void 0, void 0, function* () {
|
88
88
|
const token = cookies.get("token");
|
89
89
|
try {
|
90
|
-
const response = yield axios.post(`${
|
90
|
+
const response = yield axios.post(`${apiUrl}/login/updateuser`, {
|
91
91
|
id: id,
|
92
92
|
name: name,
|
93
93
|
Mobile: mobile,
|
@@ -15,10 +15,6 @@ import { RxPerson } from "react-icons/rx";
|
|
15
15
|
import Cookies from "universal-cookie";
|
16
16
|
import { useState } from "react";
|
17
17
|
import UpdateUserDetails from "../useraccount/UpdateUserDetails";
|
18
|
-
import Taxionomies from "../admin/Taxionomies";
|
19
|
-
import TaxonomyForm from "../admin/TaxonomyForm";
|
20
|
-
import Users from "../admin/Users";
|
21
|
-
import UserForm from "../admin/UserForm";
|
22
18
|
const IconWrapper = (_a) => {
|
23
19
|
var { className } = _a, props = __rest(_a, ["className"]);
|
24
20
|
return (_jsx("div", { className: className, children: _jsx(RxPerson, Object.assign({}, props)) }));
|
@@ -98,6 +94,6 @@ const Header = ({ toggleTheme, isDarkMode, userLogedin, userType, url, img, name
|
|
98
94
|
? "text-white hover:bg-gray-600"
|
99
95
|
: "text-black hover:bg-gray-200"}`, children: "Login" })), _jsx("button", { onClick: () => handleDark(), className: `md:px-3 pl-1 py-1 md:border-2 rounded-md transition-transform transform hover:scale-95 duration-300 ${isDarkMode
|
100
96
|
? "text-white border-white"
|
101
|
-
: "text-black border-black"}`, children: isDarkMode ? _jsx(CiDark, {}) : _jsx(CiLight, {}) })] }) })] }) }), _jsx(UpdateUserDetails, { usermodalopen: usermodalopen, closeusermodal: () => setusermodalopen(false), url: url, isDarkMode: isDarkMode })
|
97
|
+
: "text-black border-black"}`, children: isDarkMode ? _jsx(CiDark, {}) : _jsx(CiLight, {}) })] }) })] }) }), _jsx(UpdateUserDetails, { usermodalopen: usermodalopen, closeusermodal: () => setusermodalopen(false), url: url, isDarkMode: isDarkMode })] }));
|
102
98
|
};
|
103
99
|
export default Header;
|
package/package.json
CHANGED
@@ -4,11 +4,11 @@ import { useState, useEffect } from "react";
|
|
4
4
|
import { FaPlus } from "react-icons/fa";
|
5
5
|
import { fetchTaxonomiessApi } from "../api/taxonomy";
|
6
6
|
|
7
|
-
const Taxionomies = (
|
7
|
+
const Taxionomies = () => {
|
8
8
|
const [taxonomy, setTaxonomy] = useState<any[]>([]);
|
9
9
|
|
10
10
|
const fetchTaxonomiesData = async () => {
|
11
|
-
const data = await fetchTaxonomiessApi(
|
11
|
+
const data = await fetchTaxonomiessApi();
|
12
12
|
if (data) {
|
13
13
|
const uniqueTaxonomies = (data as any[]).reduce(
|
14
14
|
(acc: any[], item: any) => {
|
@@ -153,7 +153,7 @@ const Taxionomies = ({ url }: { url: string }) => {
|
|
153
153
|
</thead>
|
154
154
|
<tbody className="bg-white divide-y divide-gray-200 dark:divide-gray-700 dark:bg-gray-900">
|
155
155
|
{paginatedTaxonomies
|
156
|
-
.filter((taxonomy) => taxonomy.isView)
|
156
|
+
.filter((taxonomy) => taxonomy.isView) // Exclude taxonomies where isView is true
|
157
157
|
.map((taxonomy, index) => (
|
158
158
|
<tr key={taxonomy.id || index}>
|
159
159
|
<td className="px-4 py-4 text-sm whitespace-nowrap">
|
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
} from "../api/taxonomy";
|
13
13
|
import { FaPlus } from "react-icons/fa";
|
14
14
|
|
15
|
-
const TaxonomyForm = (
|
15
|
+
const TaxonomyForm = () => {
|
16
16
|
const [type, setType] = useState<string>("");
|
17
17
|
const [inputType, setInputType] = useState<string>("");
|
18
18
|
const [code, setCode] = useState<number | string>("");
|
@@ -45,7 +45,7 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
45
45
|
useEffect(() => {
|
46
46
|
const fetchAllTaxonomies = async () => {
|
47
47
|
try {
|
48
|
-
const fetchedTaxonomies = await fetchTaxonomiessApi(
|
48
|
+
const fetchedTaxonomies = await fetchTaxonomiessApi();
|
49
49
|
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
50
50
|
setAllTaxonomies(fetchedTaxonomies);
|
51
51
|
}
|
@@ -67,9 +67,9 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
67
67
|
|
68
68
|
const handleDeleteSubTypeClick = async (id: string) => {
|
69
69
|
try {
|
70
|
-
await deleteTaxonomyApi(
|
70
|
+
await deleteTaxonomyApi(id);
|
71
71
|
alert("Taxonomy deleted successfully");
|
72
|
-
const fetchedTaxonomies = await fetchTaxonomiessApi(
|
72
|
+
const fetchedTaxonomies = await fetchTaxonomiessApi();
|
73
73
|
|
74
74
|
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
75
75
|
setAllTaxonomies(fetchedTaxonomies);
|
@@ -110,7 +110,7 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
110
110
|
if (id) {
|
111
111
|
const fetchTaxonomyData = async () => {
|
112
112
|
try {
|
113
|
-
const fetchedTaxonomy = await fetchTaxonomyByIdApi(
|
113
|
+
const fetchedTaxonomy = await fetchTaxonomyByIdApi(id);
|
114
114
|
if (fetchedTaxonomy) {
|
115
115
|
const taxonomy = fetchedTaxonomy as {
|
116
116
|
type: string;
|
@@ -134,7 +134,7 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
134
134
|
useEffect(() => {
|
135
135
|
const handleFetchSimilarTaxonomies = async () => {
|
136
136
|
try {
|
137
|
-
const response = await fetchTaxonomiessApi(
|
137
|
+
const response = await fetchTaxonomiessApi();
|
138
138
|
const filteredTaxonomies = (response as { type: string }[]).filter(
|
139
139
|
(taxonomy: { type: string }) => taxonomy.type === type
|
140
140
|
);
|
@@ -160,11 +160,11 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
160
160
|
|
161
161
|
try {
|
162
162
|
if (isEditMode) {
|
163
|
-
await addMultipleTaxonomiesApi(
|
163
|
+
await addMultipleTaxonomiesApi(tempTaxonomy);
|
164
164
|
setTempTaxonomy([]);
|
165
165
|
alert("Taxonomies saved successfully");
|
166
166
|
} else {
|
167
|
-
await addTaxonomyApi(
|
167
|
+
await addTaxonomyApi(inputType, Number(code), value);
|
168
168
|
alert("Taxonomy added successfully");
|
169
169
|
}
|
170
170
|
window.history.pushState({}, "", "/admin/taxinomies");
|
@@ -182,10 +182,10 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
182
182
|
|
183
183
|
try {
|
184
184
|
if (isEditMode) {
|
185
|
-
await updateTaxonomyApi(
|
185
|
+
await updateTaxonomyApi(id, inputType, Number(code), value);
|
186
186
|
alert("Taxonomy updated successfully");
|
187
187
|
} else {
|
188
|
-
await addTaxonomyApi(
|
188
|
+
await addTaxonomyApi(inputType, Number(code), value);
|
189
189
|
alert("Taxonomy added successfully");
|
190
190
|
}
|
191
191
|
window.location.href = "/admin/taxinomies";
|
@@ -198,7 +198,7 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
198
198
|
useEffect(() => {
|
199
199
|
const fetchIsMultiple = async () => {
|
200
200
|
try {
|
201
|
-
const result = await isMultipleApi(
|
201
|
+
const result = await isMultipleApi(type);
|
202
202
|
setIsMultiple(typeof result === "boolean");
|
203
203
|
} catch (error) {
|
204
204
|
console.error("Error checking if taxonomy is multiple:", error);
|
@@ -291,14 +291,13 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
291
291
|
const handleSubTypeAddClick = async () => {
|
292
292
|
try {
|
293
293
|
await addSubTypeApi(
|
294
|
-
url,
|
295
294
|
selectedTaxonomyId,
|
296
295
|
subType,
|
297
296
|
Number(subCode),
|
298
297
|
subValue
|
299
298
|
);
|
300
299
|
alert("SubType added successfully");
|
301
|
-
const fetchedTaxonomies = await fetchTaxonomiessApi(
|
300
|
+
const fetchedTaxonomies = await fetchTaxonomiessApi();
|
302
301
|
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
303
302
|
setAllTaxonomies(fetchedTaxonomies);
|
304
303
|
}
|
@@ -314,7 +313,6 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
314
313
|
const handleSubTypeEditClick = async () => {
|
315
314
|
try {
|
316
315
|
await updateTaxonomyApi(
|
317
|
-
url,
|
318
316
|
selectedTaxonomyId,
|
319
317
|
subType,
|
320
318
|
Number(subCode),
|
@@ -322,7 +320,7 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
322
320
|
);
|
323
321
|
|
324
322
|
alert("SubType edited successfully");
|
325
|
-
const fetchedTaxonomies = await fetchTaxonomiessApi(
|
323
|
+
const fetchedTaxonomies = await fetchTaxonomiessApi();
|
326
324
|
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
327
325
|
setAllTaxonomies(fetchedTaxonomies);
|
328
326
|
}
|
@@ -353,7 +351,6 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
353
351
|
const handleEditTaxClick = async () => {
|
354
352
|
try {
|
355
353
|
await updateTaxonomyApi(
|
356
|
-
url,
|
357
354
|
selectedTaxonomyId,
|
358
355
|
type,
|
359
356
|
Number(newCode),
|
@@ -364,7 +361,7 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
364
361
|
console.error("Error updating Taxonomy:", error);
|
365
362
|
}
|
366
363
|
setIsModalOpen(false);
|
367
|
-
const response = await fetchTaxonomiessApi(
|
364
|
+
const response = await fetchTaxonomiessApi();
|
368
365
|
const filteredTaxonomies = (response as { type: string }[]).filter(
|
369
366
|
(taxonomy: { type: string }) => taxonomy.type === type
|
370
367
|
);
|
@@ -377,10 +374,10 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
377
374
|
return;
|
378
375
|
}
|
379
376
|
try {
|
380
|
-
await addMultipleTaxonomiesApi(
|
377
|
+
await addMultipleTaxonomiesApi(tempTaxonomy);
|
381
378
|
setTempTaxonomy([]);
|
382
379
|
alert("Multiple taxonomies added successfully");
|
383
|
-
const response = await fetchTaxonomiessApi(
|
380
|
+
const response = await fetchTaxonomiessApi();
|
384
381
|
const filteredTaxonomies = (response as { type: string }[]).filter(
|
385
382
|
(taxonomy: { type: string }) => taxonomy.type === inputType
|
386
383
|
);
|
@@ -393,7 +390,7 @@ const TaxonomyForm = ({ url }: { url: string }) => {
|
|
393
390
|
|
394
391
|
const handleDeleteClick = async (id: string) => {
|
395
392
|
try {
|
396
|
-
await deleteTaxonomyApi(
|
393
|
+
await deleteTaxonomyApi(id);
|
397
394
|
alert("Taxonomy deleted successfully");
|
398
395
|
setSimilarTaxonomies((prevTaxonomies) =>
|
399
396
|
prevTaxonomies.filter((taxonomy) => taxonomy.id !== id)
|
@@ -3,11 +3,7 @@ import { useState, useEffect } from "react";
|
|
3
3
|
|
4
4
|
import { addUserApi, updateUserApi, fetchUserByIdApi } from "../api/user";
|
5
5
|
|
6
|
-
|
7
|
-
url: string;
|
8
|
-
}
|
9
|
-
|
10
|
-
const UserForm: React.FC<UserFormProps> = ({ url }) => {
|
6
|
+
const UserForm = () => {
|
11
7
|
const [userName, setUserName] = useState("");
|
12
8
|
const [email, setEmail] = useState("");
|
13
9
|
const [mobile, setMobile] = useState("");
|
@@ -33,7 +29,7 @@ const UserForm: React.FC<UserFormProps> = ({ url }) => {
|
|
33
29
|
if (id) {
|
34
30
|
const fetchUserData = async () => {
|
35
31
|
try {
|
36
|
-
const fetchedUser = await fetchUserByIdApi(
|
32
|
+
const fetchedUser = await fetchUserByIdApi(id);
|
37
33
|
if (fetchedUser) {
|
38
34
|
const user = fetchedUser as {
|
39
35
|
name: string;
|
@@ -63,10 +59,10 @@ const UserForm: React.FC<UserFormProps> = ({ url }) => {
|
|
63
59
|
|
64
60
|
try {
|
65
61
|
if (isEditMode) {
|
66
|
-
await updateUserApi(
|
62
|
+
await updateUserApi(id, userName, mobile, address, roleType);
|
67
63
|
alert("User updated successfully");
|
68
64
|
} else {
|
69
|
-
await addUserApi(
|
65
|
+
await addUserApi(userName, email, mobile, address, roleType);
|
70
66
|
alert("User added successfully");
|
71
67
|
}
|
72
68
|
// window.location.href = "/admin/users";
|
@@ -5,15 +5,11 @@ import { FaPlus } from "react-icons/fa";
|
|
5
5
|
|
6
6
|
import { fetchUsersApi, deleteUserApi } from "../api/user";
|
7
7
|
|
8
|
-
|
9
|
-
url: string;
|
10
|
-
}
|
11
|
-
|
12
|
-
const Users: React.FC<UsersProps> = ({ url }) => {
|
8
|
+
function Users() {
|
13
9
|
const [users, setUsers] = useState<any[]>([]);
|
14
10
|
|
15
11
|
const fetchUsersData = async () => {
|
16
|
-
const data = await fetchUsersApi(
|
12
|
+
const data = await fetchUsersApi();
|
17
13
|
if (data) {
|
18
14
|
setUsers(data as any[]);
|
19
15
|
} else {
|
@@ -59,7 +55,7 @@ const Users: React.FC<UsersProps> = ({ url }) => {
|
|
59
55
|
|
60
56
|
const handleDeleteClick = async (id: string) => {
|
61
57
|
try {
|
62
|
-
await deleteUserApi(
|
58
|
+
await deleteUserApi(id);
|
63
59
|
alert("User deleted successfully");
|
64
60
|
|
65
61
|
fetchUsersData();
|
@@ -340,6 +336,6 @@ const Users: React.FC<UsersProps> = ({ url }) => {
|
|
340
336
|
</div>
|
341
337
|
</div>
|
342
338
|
);
|
343
|
-
}
|
339
|
+
}
|
344
340
|
|
345
341
|
export default Users;
|
@@ -4,7 +4,6 @@ const apiUrl = "http://localhost:5260";
|
|
4
4
|
const cookies = new Cookies();
|
5
5
|
|
6
6
|
export const addTaxonomyApi = async (
|
7
|
-
url: string,
|
8
7
|
type: string,
|
9
8
|
code: number,
|
10
9
|
value: string
|
@@ -13,7 +12,7 @@ export const addTaxonomyApi = async (
|
|
13
12
|
|
14
13
|
try {
|
15
14
|
const response = await axios.post(
|
16
|
-
`${
|
15
|
+
`${apiUrl}/taxonomy/add`,
|
17
16
|
{
|
18
17
|
Type: type,
|
19
18
|
Code: code,
|
@@ -33,11 +32,11 @@ export const addTaxonomyApi = async (
|
|
33
32
|
}
|
34
33
|
};
|
35
34
|
|
36
|
-
export const fetchTaxonomiessApi = async (
|
35
|
+
export const fetchTaxonomiessApi = async () => {
|
37
36
|
const token = cookies.get("authToken");
|
38
37
|
|
39
38
|
try {
|
40
|
-
const response = await axios.get(`${
|
39
|
+
const response = await axios.get(`${apiUrl}/taxonomy/gettaxonomy`, {
|
41
40
|
headers: {
|
42
41
|
Authorization: `Bearer ${token}`,
|
43
42
|
},
|
@@ -49,13 +48,13 @@ export const fetchTaxonomiessApi = async (url: string) => {
|
|
49
48
|
}
|
50
49
|
};
|
51
50
|
|
52
|
-
export const deleteTaxonomyApi = async (
|
51
|
+
export const deleteTaxonomyApi = async (id: string) => {
|
53
52
|
const token = cookies.get("authToken");
|
54
53
|
|
55
54
|
try {
|
56
55
|
const response = await axios.request({
|
57
56
|
method: "DELETE",
|
58
|
-
url: `${
|
57
|
+
url: `${apiUrl}/taxonomy/delete`,
|
59
58
|
headers: {
|
60
59
|
Authorization: `Bearer ${token}`,
|
61
60
|
"Content-Type": "application/json",
|
@@ -71,13 +70,13 @@ export const deleteTaxonomyApi = async (url: string, id: string) => {
|
|
71
70
|
}
|
72
71
|
};
|
73
72
|
|
74
|
-
export const fetchTaxonomyByIdApi = async (
|
73
|
+
export const fetchTaxonomyByIdApi = async (taxonomyId: string) => {
|
75
74
|
const cookies = new Cookies();
|
76
75
|
const token = cookies.get("authToken");
|
77
76
|
|
78
77
|
try {
|
79
78
|
const response = await axios.get(
|
80
|
-
`${
|
79
|
+
`${apiUrl}/taxonomy/gettaxonomybyid/${taxonomyId}`,
|
81
80
|
{
|
82
81
|
headers: {
|
83
82
|
Authorization: `Bearer ${token}`,
|
@@ -93,7 +92,6 @@ export const fetchTaxonomyByIdApi = async (url: string, taxonomyId: string) => {
|
|
93
92
|
};
|
94
93
|
|
95
94
|
export const updateTaxonomyApi = async (
|
96
|
-
url: string,
|
97
95
|
id: string,
|
98
96
|
type: string,
|
99
97
|
code: number,
|
@@ -103,7 +101,7 @@ export const updateTaxonomyApi = async (
|
|
103
101
|
|
104
102
|
try {
|
105
103
|
const response = await axios.post(
|
106
|
-
`${
|
104
|
+
`${apiUrl}/taxonomy/updatetaxonomy`,
|
107
105
|
{
|
108
106
|
Id: id,
|
109
107
|
Type: type,
|
@@ -123,14 +121,13 @@ export const updateTaxonomyApi = async (
|
|
123
121
|
};
|
124
122
|
|
125
123
|
export const addMultipleTaxonomiesApi = async (
|
126
|
-
url: string,
|
127
124
|
taxonomies: { type: string; code: number; value: string }[]
|
128
125
|
) => {
|
129
126
|
const token = cookies.get("authToken");
|
130
127
|
|
131
128
|
try {
|
132
129
|
const response = await axios.post(
|
133
|
-
`${
|
130
|
+
`${apiUrl}/taxonomy/addmultipletaxonomies`,
|
134
131
|
taxonomies,
|
135
132
|
{
|
136
133
|
headers: {
|
@@ -149,12 +146,12 @@ export const addMultipleTaxonomiesApi = async (
|
|
149
146
|
}
|
150
147
|
};
|
151
148
|
|
152
|
-
export const isMultipleApi = async (
|
149
|
+
export const isMultipleApi = async (type: string) => {
|
153
150
|
const token = cookies.get("authToken");
|
154
151
|
|
155
152
|
try {
|
156
153
|
const response = await axios.get(
|
157
|
-
`${
|
154
|
+
`${apiUrl}/taxonomy/IsTaxonomyMultipleByType/${type}`,
|
158
155
|
{
|
159
156
|
headers: {
|
160
157
|
Authorization: `Bearer ${token}`,
|
@@ -169,7 +166,6 @@ export const isMultipleApi = async (url: string, type: string) => {
|
|
169
166
|
};
|
170
167
|
|
171
168
|
export const addSubTypeApi = async (
|
172
|
-
url: string,
|
173
169
|
parentid: string,
|
174
170
|
type: string,
|
175
171
|
code: number,
|
@@ -179,7 +175,7 @@ export const addSubTypeApi = async (
|
|
179
175
|
|
180
176
|
try {
|
181
177
|
const response = await axios.post(
|
182
|
-
`${
|
178
|
+
`${apiUrl}/taxonomy/addsubtype`,
|
183
179
|
{
|
184
180
|
ParentId: parentid,
|
185
181
|
Type: type,
|
@@ -4,7 +4,6 @@ const apiUrl = "http://localhost:5260";
|
|
4
4
|
const cookies = new Cookies();
|
5
5
|
|
6
6
|
export const addUserApi = async (
|
7
|
-
url: string,
|
8
7
|
name: string,
|
9
8
|
email: string,
|
10
9
|
mobile: string,
|
@@ -15,7 +14,7 @@ export const addUserApi = async (
|
|
15
14
|
|
16
15
|
try {
|
17
16
|
const response = await axios.post(
|
18
|
-
`${
|
17
|
+
`${apiUrl}/login/adduser`,
|
19
18
|
{
|
20
19
|
Name: name,
|
21
20
|
Email: email,
|
@@ -37,11 +36,11 @@ export const addUserApi = async (
|
|
37
36
|
}
|
38
37
|
};
|
39
38
|
|
40
|
-
export const fetchUsersApi = async (
|
39
|
+
export const fetchUsersApi = async () => {
|
41
40
|
const token = cookies.get("token");
|
42
41
|
|
43
42
|
try {
|
44
|
-
const response = await axios.get(`${
|
43
|
+
const response = await axios.get(`${apiUrl}/login/getuser`, {
|
45
44
|
headers: {
|
46
45
|
Authorization: `Bearer ${token}`,
|
47
46
|
},
|
@@ -53,12 +52,12 @@ export const fetchUsersApi = async (url: string) => {
|
|
53
52
|
}
|
54
53
|
};
|
55
54
|
|
56
|
-
export const fetchUserByIdApi = async (
|
55
|
+
export const fetchUserByIdApi = async (userId: string) => {
|
57
56
|
const cookies = new Cookies();
|
58
57
|
const token = cookies.get("token");
|
59
58
|
|
60
59
|
try {
|
61
|
-
const response = await axios.get(`${
|
60
|
+
const response = await axios.get(`${apiUrl}/login/getuserbyid/${userId}`, {
|
62
61
|
headers: {
|
63
62
|
Authorization: `Bearer ${token}`,
|
64
63
|
},
|
@@ -71,13 +70,13 @@ export const fetchUserByIdApi = async (url: string, userId: string) => {
|
|
71
70
|
}
|
72
71
|
};
|
73
72
|
|
74
|
-
export const deleteUserApi = async (
|
73
|
+
export const deleteUserApi = async (id: string) => {
|
75
74
|
const token = cookies.get("token");
|
76
75
|
|
77
76
|
try {
|
78
77
|
const response = await axios.request({
|
79
78
|
method: "DELETE",
|
80
|
-
url: `${
|
79
|
+
url: `${apiUrl}/login/delete`,
|
81
80
|
headers: {
|
82
81
|
Authorization: `Bearer ${token}`,
|
83
82
|
"Content-Type": "application/json",
|
@@ -94,7 +93,6 @@ export const deleteUserApi = async (url: string, id: string) => {
|
|
94
93
|
};
|
95
94
|
|
96
95
|
export const updateUserApi = async (
|
97
|
-
url: string,
|
98
96
|
id: string,
|
99
97
|
name: string,
|
100
98
|
mobile: string,
|
@@ -105,7 +103,7 @@ export const updateUserApi = async (
|
|
105
103
|
|
106
104
|
try {
|
107
105
|
const response = await axios.post(
|
108
|
-
`${
|
106
|
+
`${apiUrl}/login/updateuser`,
|
109
107
|
{
|
110
108
|
id: id,
|
111
109
|
name: name,
|
@@ -4,10 +4,6 @@ import { RxPerson } from "react-icons/rx";
|
|
4
4
|
import Cookies from "universal-cookie";
|
5
5
|
import { FC, useState } from "react";
|
6
6
|
import UpdateUserDetails from "../useraccount/UpdateUserDetails";
|
7
|
-
import Taxionomies from "../admin/Taxionomies";
|
8
|
-
import TaxonomyForm from "../admin/TaxonomyForm";
|
9
|
-
import Users from "../admin/Users";
|
10
|
-
import UserForm from "../admin/UserForm";
|
11
7
|
|
12
8
|
interface HeaderProps {
|
13
9
|
toggleTheme;
|
@@ -337,10 +333,6 @@ const Header = ({
|
|
337
333
|
url={url}
|
338
334
|
isDarkMode={isDarkMode}
|
339
335
|
/>
|
340
|
-
<Taxionomies url={url} />
|
341
|
-
<TaxonomyForm url={url} />
|
342
|
-
<Users url={url} />
|
343
|
-
<UserForm url={url} />
|
344
336
|
</header>
|
345
337
|
);
|
346
338
|
};
|