eleven-solutions-common-website-unique-web 9.0.27 → 9.0.29
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.
|
@@ -1,5 +1,46 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import { addTemplateApi } from "../api/template";
|
|
2
13
|
const TemplateForm = () => {
|
|
3
|
-
|
|
14
|
+
const [name, setName] = useState("");
|
|
15
|
+
const [content, setContent] = useState("");
|
|
16
|
+
const validateForm = () => {
|
|
17
|
+
if (!name || !content) {
|
|
18
|
+
alert("Please fill in all required fields: Name and Content.");
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
const handleAddClick = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
if (!validateForm())
|
|
26
|
+
return;
|
|
27
|
+
try {
|
|
28
|
+
yield addTemplateApi(name, content);
|
|
29
|
+
alert("Template added Successfully.");
|
|
30
|
+
window.history.pushState({}, "", "/admin/template");
|
|
31
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error("Error adding template:", error);
|
|
35
|
+
alert("Failed to add template.");
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const handleCancelClick = () => {
|
|
39
|
+
setName("");
|
|
40
|
+
setContent("");
|
|
41
|
+
window.history.pushState({}, "", "/admin/template");
|
|
42
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
43
|
+
};
|
|
44
|
+
return (_jsx("div", { className: "max-w-4xl p-6 mx-auto dark:bg-gray-800", children: _jsx("div", { children: _jsxs("form", { children: [_jsx("h1", { className: "text-3xl font-bold text-center text-blue-600 capitalize dark:text-white mb-4", children: "Add Template" }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Name ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx("input", { required: true, type: "text", value: name, onChange: (e) => setName(e.target.value), 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 Name" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Content ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx("input", { required: true, type: "text", value: content, onChange: (e) => setContent(e.target.value), 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 Content" })] }), _jsxs("div", { className: "flex space-x-4 mt-6 justify-end", children: [_jsx("button", { type: "submit", onClick: handleAddClick, 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: "Add" }), _jsx("button", { type: "button", onClick: handleCancelClick, 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" })] })] }) }) }));
|
|
4
45
|
};
|
|
5
46
|
export default TemplateForm;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const addTemplateApi: (name: string, content: string) => Promise<Axios.AxiosXHR<unknown>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axios from "axios";
|
|
11
|
+
import Cookies from "universal-cookie";
|
|
12
|
+
const apiUrl = "http://localhost:5260";
|
|
13
|
+
const cookies = new Cookies();
|
|
14
|
+
export const addTemplateApi = (name, content) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const token = cookies.get("token");
|
|
16
|
+
try {
|
|
17
|
+
const response = yield axios.post(`${apiUrl}/template/add`, {
|
|
18
|
+
Name: name,
|
|
19
|
+
Content: content,
|
|
20
|
+
}, {
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${token}`,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return response;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error(error);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { addTemplateApi } from "../api/template";
|
|
2
3
|
|
|
3
4
|
const TemplateForm = () => {
|
|
5
|
+
const [name, setName] = useState("");
|
|
6
|
+
const [content, setContent] = useState("");
|
|
7
|
+
|
|
8
|
+
const validateForm = () => {
|
|
9
|
+
if (!name || !content) {
|
|
10
|
+
alert("Please fill in all required fields: Name and Content.");
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const handleAddClick = async (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
if (!validateForm()) return;
|
|
19
|
+
try {
|
|
20
|
+
await addTemplateApi(name, content);
|
|
21
|
+
alert("Template added Successfully.");
|
|
22
|
+
window.history.pushState({}, "", "/admin/template");
|
|
23
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error("Error adding template:", error);
|
|
26
|
+
alert("Failed to add template.");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handleCancelClick = () => {
|
|
31
|
+
setName("");
|
|
32
|
+
setContent("");
|
|
33
|
+
|
|
34
|
+
window.history.pushState({}, "", "/admin/template");
|
|
35
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
36
|
+
};
|
|
37
|
+
|
|
4
38
|
return (
|
|
5
39
|
<div className="max-w-4xl p-6 mx-auto dark:bg-gray-800">
|
|
6
40
|
<div>
|
|
@@ -16,6 +50,8 @@ const TemplateForm = () => {
|
|
|
16
50
|
<input
|
|
17
51
|
required
|
|
18
52
|
type="text"
|
|
53
|
+
value={name}
|
|
54
|
+
onChange={(e) => setName(e.target.value)}
|
|
19
55
|
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"
|
|
20
56
|
placeholder="Enter Name"
|
|
21
57
|
/>
|
|
@@ -27,6 +63,8 @@ const TemplateForm = () => {
|
|
|
27
63
|
<input
|
|
28
64
|
required
|
|
29
65
|
type="text"
|
|
66
|
+
value={content}
|
|
67
|
+
onChange={(e) => setContent(e.target.value)}
|
|
30
68
|
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"
|
|
31
69
|
placeholder="Enter Content"
|
|
32
70
|
/>
|
|
@@ -35,12 +73,14 @@ const TemplateForm = () => {
|
|
|
35
73
|
<div className="flex space-x-4 mt-6 justify-end">
|
|
36
74
|
<button
|
|
37
75
|
type="submit"
|
|
76
|
+
onClick={handleAddClick}
|
|
38
77
|
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"
|
|
39
78
|
>
|
|
40
79
|
Add
|
|
41
80
|
</button>
|
|
42
81
|
<button
|
|
43
82
|
type="button"
|
|
83
|
+
onClick={handleCancelClick}
|
|
44
84
|
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"
|
|
45
85
|
>
|
|
46
86
|
Cancel
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import Cookies from "universal-cookie";
|
|
3
|
+
const apiUrl = "http://localhost:5260";
|
|
4
|
+
const cookies = new Cookies();
|
|
5
|
+
|
|
6
|
+
export const addTemplateApi = async (name: string, content: string) => {
|
|
7
|
+
const token = cookies.get("token");
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const response = await axios.post(
|
|
11
|
+
`${apiUrl}/template/add`,
|
|
12
|
+
{
|
|
13
|
+
Name: name,
|
|
14
|
+
Content: content,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${token}`,
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
return response;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error(error);
|
|
25
|
+
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|