eleven-solutions-common-website-unique-web 10.0.11 → 10.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/admin/Template.d.ts +4 -1
- package/dist/components/admin/Template.js +3 -3
- package/dist/components/admin/TemplateForm.d.ts +4 -1
- package/dist/components/admin/TemplateForm.js +4 -4
- package/dist/components/api/template.d.ts +5 -5
- package/dist/components/api/template.js +10 -10
- package/package.json +1 -1
- package/src/components/admin/Template.tsx +7 -3
- package/src/components/admin/TemplateForm.tsx +8 -4
- package/src/components/api/template.ts +18 -16
@@ -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 { fetchTemplatesApi, deleteTemplateApi } from "../api/template";
|
14
|
-
const Template = () => {
|
14
|
+
const Template = ({ url }) => {
|
15
15
|
const [templates, setTemplates] = useState([]);
|
16
16
|
const fetchTemplatesData = () => __awaiter(void 0, void 0, void 0, function* () {
|
17
|
-
const data = yield fetchTemplatesApi();
|
17
|
+
const data = yield fetchTemplatesApi(url);
|
18
18
|
if (data) {
|
19
19
|
setTemplates(data);
|
20
20
|
}
|
@@ -55,7 +55,7 @@ const Template = () => {
|
|
55
55
|
};
|
56
56
|
const handleDeleteClick = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
57
57
|
try {
|
58
|
-
yield deleteTemplateApi(id);
|
58
|
+
yield deleteTemplateApi(url, id);
|
59
59
|
alert("Template deleted successfully");
|
60
60
|
fetchTemplatesData();
|
61
61
|
}
|
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { useState, useEffect, useRef, useMemo } from "react";
|
12
12
|
import { addTemplateApi, fetchTemplateByIdApi, updateTemplateApi, } from "../api/template";
|
13
13
|
import Editor from "./Editor";
|
14
|
-
const TemplateForm = () => {
|
14
|
+
const TemplateForm = ({ url }) => {
|
15
15
|
const [name, setName] = useState("");
|
16
16
|
const [content, setContent] = useState("");
|
17
17
|
const placeholder = "";
|
@@ -34,7 +34,7 @@ const TemplateForm = () => {
|
|
34
34
|
if (id) {
|
35
35
|
const fetchTemplateData = () => __awaiter(void 0, void 0, void 0, function* () {
|
36
36
|
try {
|
37
|
-
const fetchedUser = yield fetchTemplateByIdApi(id);
|
37
|
+
const fetchedUser = yield fetchTemplateByIdApi(url, id);
|
38
38
|
if (fetchedUser) {
|
39
39
|
const user = fetchedUser;
|
40
40
|
setIsEditMode(true);
|
@@ -55,11 +55,11 @@ const TemplateForm = () => {
|
|
55
55
|
return;
|
56
56
|
try {
|
57
57
|
if (isEditMode) {
|
58
|
-
yield updateTemplateApi(id, name, content);
|
58
|
+
yield updateTemplateApi(url, id, name, content);
|
59
59
|
alert("Template updated successfully");
|
60
60
|
}
|
61
61
|
else {
|
62
|
-
yield addTemplateApi(name, content);
|
62
|
+
yield addTemplateApi(url, name, content);
|
63
63
|
alert("Template added successfully");
|
64
64
|
}
|
65
65
|
window.history.pushState({}, "", "/admin/template");
|
@@ -1,5 +1,5 @@
|
|
1
|
-
export declare const addTemplateApi: (name: string, content: string) => Promise<Axios.AxiosXHR<unknown>>;
|
2
|
-
export declare const fetchTemplatesApi: () => Promise<unknown>;
|
3
|
-
export declare const fetchTemplateByIdApi: (id: string) => Promise<unknown>;
|
4
|
-
export declare const updateTemplateApi: (id: string, name: string, content: string) => Promise<unknown>;
|
5
|
-
export declare const deleteTemplateApi: (id: string) => Promise<unknown>;
|
1
|
+
export declare const addTemplateApi: (url: string, name: string, content: string) => Promise<Axios.AxiosXHR<unknown>>;
|
2
|
+
export declare const fetchTemplatesApi: (url: string) => Promise<unknown>;
|
3
|
+
export declare const fetchTemplateByIdApi: (url: string, id: string) => Promise<unknown>;
|
4
|
+
export declare const updateTemplateApi: (url: string, id: string, name: string, content: string) => Promise<unknown>;
|
5
|
+
export declare const deleteTemplateApi: (url: string, id: 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 addTemplateApi = (name, content) => __awaiter(void 0, void 0, void 0, function* () {
|
14
|
+
export const addTemplateApi = (url, name, content) => __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(`${url}/template/add`, {
|
18
18
|
Name: name,
|
19
19
|
Content: content,
|
20
20
|
}, {
|
@@ -29,10 +29,10 @@ export const addTemplateApi = (name, content) => __awaiter(void 0, void 0, void
|
|
29
29
|
throw error;
|
30
30
|
}
|
31
31
|
});
|
32
|
-
export const fetchTemplatesApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
32
|
+
export const fetchTemplatesApi = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
33
33
|
const token = cookies.get("authToken");
|
34
34
|
try {
|
35
|
-
const response = yield axios.get(`${
|
35
|
+
const response = yield axios.get(`${url}/template/gettemplate`, {
|
36
36
|
headers: {
|
37
37
|
Authorization: `Bearer ${token}`,
|
38
38
|
},
|
@@ -44,11 +44,11 @@ export const fetchTemplatesApi = () => __awaiter(void 0, void 0, void 0, functio
|
|
44
44
|
return false;
|
45
45
|
}
|
46
46
|
});
|
47
|
-
export const fetchTemplateByIdApi = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
47
|
+
export const fetchTemplateByIdApi = (url, id) => __awaiter(void 0, void 0, void 0, function* () {
|
48
48
|
const cookies = new Cookies();
|
49
49
|
const token = cookies.get("authToken");
|
50
50
|
try {
|
51
|
-
const response = yield axios.get(`${
|
51
|
+
const response = yield axios.get(`${url}/template/gettemplatebyid/${id}`, {
|
52
52
|
headers: {
|
53
53
|
Authorization: `Bearer ${token}`,
|
54
54
|
},
|
@@ -60,10 +60,10 @@ export const fetchTemplateByIdApi = (id) => __awaiter(void 0, void 0, void 0, fu
|
|
60
60
|
return false;
|
61
61
|
}
|
62
62
|
});
|
63
|
-
export const updateTemplateApi = (id, name, content) => __awaiter(void 0, void 0, void 0, function* () {
|
63
|
+
export const updateTemplateApi = (url, id, name, content) => __awaiter(void 0, void 0, void 0, function* () {
|
64
64
|
const token = cookies.get("authToken");
|
65
65
|
try {
|
66
|
-
const response = yield axios.post(`${
|
66
|
+
const response = yield axios.post(`${url}/template/updatetemplate`, {
|
67
67
|
id: id,
|
68
68
|
name: name,
|
69
69
|
content: content,
|
@@ -78,10 +78,10 @@ export const updateTemplateApi = (id, name, content) => __awaiter(void 0, void 0
|
|
78
78
|
throw error;
|
79
79
|
}
|
80
80
|
});
|
81
|
-
export const deleteTemplateApi = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
81
|
+
export const deleteTemplateApi = (url, id) => __awaiter(void 0, void 0, void 0, function* () {
|
82
82
|
const token = cookies.get("authToken");
|
83
83
|
try {
|
84
|
-
const response = yield axios.post(`${
|
84
|
+
const response = yield axios.post(`${url}/template/deletetemplate`, {
|
85
85
|
id: id,
|
86
86
|
}, {
|
87
87
|
headers: {
|
package/package.json
CHANGED
@@ -3,11 +3,15 @@ import { useState, useEffect } from "react";
|
|
3
3
|
import { FaPlus } from "react-icons/fa";
|
4
4
|
import { fetchTemplatesApi, deleteTemplateApi } from "../api/template";
|
5
5
|
|
6
|
-
|
6
|
+
interface TemplateProps {
|
7
|
+
url: string;
|
8
|
+
}
|
9
|
+
|
10
|
+
const Template = ({ url }: TemplateProps) => {
|
7
11
|
const [templates, setTemplates] = useState<any[]>([]);
|
8
12
|
|
9
13
|
const fetchTemplatesData = async () => {
|
10
|
-
const data = await fetchTemplatesApi();
|
14
|
+
const data = await fetchTemplatesApi(url);
|
11
15
|
if (data) {
|
12
16
|
setTemplates(data as any[]);
|
13
17
|
} else {
|
@@ -65,7 +69,7 @@ const Template = () => {
|
|
65
69
|
|
66
70
|
const handleDeleteClick = async (id: string) => {
|
67
71
|
try {
|
68
|
-
await deleteTemplateApi(id);
|
72
|
+
await deleteTemplateApi(url, id);
|
69
73
|
alert("Template deleted successfully");
|
70
74
|
|
71
75
|
fetchTemplatesData();
|
@@ -7,7 +7,11 @@ import {
|
|
7
7
|
|
8
8
|
import Editor from "./Editor";
|
9
9
|
|
10
|
-
|
10
|
+
interface TemplateFormProps {
|
11
|
+
url: string;
|
12
|
+
}
|
13
|
+
|
14
|
+
const TemplateForm = ({ url }: TemplateFormProps) => {
|
11
15
|
const [name, setName] = useState("");
|
12
16
|
const [content, setContent] = useState("");
|
13
17
|
const placeholder = "";
|
@@ -38,7 +42,7 @@ const TemplateForm = () => {
|
|
38
42
|
if (id) {
|
39
43
|
const fetchTemplateData = async () => {
|
40
44
|
try {
|
41
|
-
const fetchedUser = await fetchTemplateByIdApi(id);
|
45
|
+
const fetchedUser = await fetchTemplateByIdApi(url, id);
|
42
46
|
if (fetchedUser) {
|
43
47
|
const user = fetchedUser as {
|
44
48
|
name: string;
|
@@ -62,10 +66,10 @@ const TemplateForm = () => {
|
|
62
66
|
|
63
67
|
try {
|
64
68
|
if (isEditMode) {
|
65
|
-
await updateTemplateApi(id, name, content);
|
69
|
+
await updateTemplateApi(url, id, name, content);
|
66
70
|
alert("Template updated successfully");
|
67
71
|
} else {
|
68
|
-
await addTemplateApi(name, content);
|
72
|
+
await addTemplateApi(url, name, content);
|
69
73
|
alert("Template added successfully");
|
70
74
|
}
|
71
75
|
window.history.pushState({}, "", "/admin/template");
|
@@ -3,12 +3,16 @@ import Cookies from "universal-cookie";
|
|
3
3
|
const apiUrl = "http://localhost:5260";
|
4
4
|
const cookies = new Cookies();
|
5
5
|
|
6
|
-
export const addTemplateApi = async (
|
6
|
+
export const addTemplateApi = async (
|
7
|
+
url: string,
|
8
|
+
name: string,
|
9
|
+
content: string
|
10
|
+
) => {
|
7
11
|
const token = cookies.get("authToken");
|
8
12
|
|
9
13
|
try {
|
10
14
|
const response = await axios.post(
|
11
|
-
`${
|
15
|
+
`${url}/template/add`,
|
12
16
|
{
|
13
17
|
Name: name,
|
14
18
|
Content: content,
|
@@ -26,11 +30,11 @@ export const addTemplateApi = async (name: string, content: string) => {
|
|
26
30
|
}
|
27
31
|
};
|
28
32
|
|
29
|
-
export const fetchTemplatesApi = async () => {
|
33
|
+
export const fetchTemplatesApi = async (url: string) => {
|
30
34
|
const token = cookies.get("authToken");
|
31
35
|
|
32
36
|
try {
|
33
|
-
const response = await axios.get(`${
|
37
|
+
const response = await axios.get(`${url}/template/gettemplate`, {
|
34
38
|
headers: {
|
35
39
|
Authorization: `Bearer ${token}`,
|
36
40
|
},
|
@@ -42,19 +46,16 @@ export const fetchTemplatesApi = async () => {
|
|
42
46
|
}
|
43
47
|
};
|
44
48
|
|
45
|
-
export const fetchTemplateByIdApi = async (id: string) => {
|
49
|
+
export const fetchTemplateByIdApi = async (url: string, id: string) => {
|
46
50
|
const cookies = new Cookies();
|
47
51
|
const token = cookies.get("authToken");
|
48
52
|
|
49
53
|
try {
|
50
|
-
const response = await axios.get(
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
},
|
56
|
-
}
|
57
|
-
);
|
54
|
+
const response = await axios.get(`${url}/template/gettemplatebyid/${id}`, {
|
55
|
+
headers: {
|
56
|
+
Authorization: `Bearer ${token}`,
|
57
|
+
},
|
58
|
+
});
|
58
59
|
|
59
60
|
return response.data;
|
60
61
|
} catch (error) {
|
@@ -64,6 +65,7 @@ export const fetchTemplateByIdApi = async (id: string) => {
|
|
64
65
|
};
|
65
66
|
|
66
67
|
export const updateTemplateApi = async (
|
68
|
+
url: string,
|
67
69
|
id: string,
|
68
70
|
name: string,
|
69
71
|
content: string
|
@@ -72,7 +74,7 @@ export const updateTemplateApi = async (
|
|
72
74
|
|
73
75
|
try {
|
74
76
|
const response = await axios.post(
|
75
|
-
`${
|
77
|
+
`${url}/template/updatetemplate`,
|
76
78
|
{
|
77
79
|
id: id,
|
78
80
|
name: name,
|
@@ -90,12 +92,12 @@ export const updateTemplateApi = async (
|
|
90
92
|
}
|
91
93
|
};
|
92
94
|
|
93
|
-
export const deleteTemplateApi = async (id: string) => {
|
95
|
+
export const deleteTemplateApi = async (url: string, id: string) => {
|
94
96
|
const token = cookies.get("authToken");
|
95
97
|
|
96
98
|
try {
|
97
99
|
const response = await axios.post(
|
98
|
-
`${
|
100
|
+
`${url}/template/deletetemplate`,
|
99
101
|
{
|
100
102
|
id: id,
|
101
103
|
},
|