diff --git a/package.json b/package.json
index 3ed5dd9..cdf13a9 100644
--- a/package.json
+++ b/package.json
@@ -46,6 +46,8 @@
"axios": "^0.25.0",
"bootstrap": "^5.1.3",
"country-state-city": "^3.2.1",
+ "draft-js": "^0.11.7",
+ "draft-js-export-html": "^1.4.1",
"md5": "^2.3.0",
"moment": "^2.30.1",
"prop-types": "^15.7.2",
@@ -54,12 +56,14 @@
"react-bootstrap": "^2.7.0",
"react-datepicker": "^4.8.0",
"react-dom": "^18.0.0",
+ "react-draft-wysiwyg": "^1.15.0",
"react-hot-toast": "^2.4.0",
"react-qr-code": "^2.0.11",
"react-quill": "^2.0.0",
"react-redux": "^7.2.9",
"react-router-dom": "^6.7.0",
"react-spinners": "^0.11.0",
+ "react-tag-input-component": "^2.0.2",
"react-to-print": "^2.14.11",
"redux": "4.1.2",
"serve": "^13.0.2",
diff --git a/src/_nav.js b/src/_nav.js
index 41df504..0c07fc7 100644
--- a/src/_nav.js
+++ b/src/_nav.js
@@ -249,6 +249,20 @@ const _nav = [
},
],
},
+ //Blog start
+ {
+ component: CNavGroup,
+ name: "Blog",
+ icon: ,
+ items: [
+ {
+ component: CNavItem,
+ name: "Blog",
+ icon: ,
+ to: "/blogs",
+ },
+ ],
+ },
];
export default _nav;
diff --git a/src/index.js b/src/index.js
index 3cd5764..3e4516a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,5 +1,6 @@
import "@coreui/coreui/dist/css/coreui.min.css";
import "bootstrap/dist/css/bootstrap.min.css";
+import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
import "react-app-polyfill/stable";
import "core-js";
import React from "react";
diff --git a/src/routes.js b/src/routes.js
index 5162500..ad812ad 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -115,7 +115,9 @@ import SupportReply from "./views/CustomerSupport/SupportReply";
import SupportRequestClosed from "./views/CustomerSupport/SupportRequestClosed";
import CloseRequestView from "./views/CustomerSupport/CloseRequestView";
import EditTestimonial from "./views/Testimonials/EditTestimonial";
-
+//Blogs
+import Blogs from "./views/Blog/Blogs";
+import CreateBlog from "./views/Blog/CreateBlog";
const routes = [
{ path: "/", exact: true, name: "Home" },
{
@@ -295,26 +297,26 @@ const routes = [
// { path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint },
//Complaints
- {
+ {
path: "/testimonials",
- name: "Testimonials",
- element: Testimonials
+ name: "Testimonials",
+ element: Testimonials,
},
- {
+ {
path: "/testimonial/new",
- name: "AddTestimonial",
- element: AddTestimonial
+ name: "AddTestimonial",
+ element: AddTestimonial,
},
{
path: "/testimonial/view/:id",
name: "ViewTestimonial",
element: ViewTestimonial,
},
- {
+ {
path: "/testimonial/edit/:id",
- name: "EditTestimonial",
- element: EditTestimonial
+ name: "EditTestimonial",
+ element: EditTestimonial,
},
{
path: "/banner",
@@ -479,6 +481,17 @@ const routes = [
name: "Edit Coupon",
element: CouponHistory,
},
+ //Blogs Section
+ {
+ path: "/blogs",
+ name: "Blogs",
+ element: Blogs,
+ },
+ {
+ path: "/blogs/create",
+ name: "Blogs",
+ element: CreateBlog,
+ },
];
export default routes;
diff --git a/src/scss/_custom.scss b/src/scss/_custom.scss
index 53c33f4..93c2ee3 100644
--- a/src/scss/_custom.scss
+++ b/src/scss/_custom.scss
@@ -21,3 +21,15 @@ $a-tags: "a, a:active, a:hover, a:visited";
.past-row {
background-color: #f2f2f2;
}
+//blogEditor in CreateBlog.jsx
+.blog-content {
+ // background-color: #f4f4f4;
+ // border: 1px solid black;
+ height: 20rem;
+ scrollbar-width: none;
+ box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
+ border-radius: 0px 0px 10px 10px;
+}
+.blog-toolbar {
+ background-color: #f2f2f2;
+}
diff --git a/src/views/Blog/Blogs.jsx b/src/views/Blog/Blogs.jsx
new file mode 100644
index 0000000..13547c1
--- /dev/null
+++ b/src/views/Blog/Blogs.jsx
@@ -0,0 +1,759 @@
+import React, { useState, useEffect } from "react";
+import { Link } from "react-router-dom";
+import Button from "@material-ui/core/Button";
+import { useNavigate } from "react-router-dom";
+import axios from "axios";
+import { isAutheticated } from "src/auth";
+import swal from "sweetalert";
+import {
+ Box,
+ FormControl,
+ IconButton,
+ InputLabel,
+ MenuItem,
+ Select,
+ TextField,
+} from "@mui/material";
+import SearchIcon from "@mui/icons-material/Search";
+import Fuse from "fuse.js";
+import { Typography } from "@material-ui/core";
+import { AppBlockingSharp } from "@mui/icons-material";
+const Blogs = () => {
+ const token = isAutheticated();
+ const [query, setQuery] = useState("");
+ const navigate = useNavigate();
+ const [loading, setLoading] = useState(true);
+ const [success, setSuccess] = useState(true);
+ const [productsData, setProductsData] = useState([]);
+ const [filterData, setFilterData] = useState([]);
+ const [queryData, setQueryData] = useState([]);
+
+ const [currentPage, setCurrentPage] = useState(1);
+ const [itemPerPage, setItemPerPage] = useState(10);
+ const [showData, setShowData] = useState(productsData);
+
+ const handleShowEntries = (e) => {
+ setCurrentPage(1);
+ setItemPerPage(e.target.value);
+ };
+
+ const getProductsData = async () => {
+ axios
+ .get(`/api/product/getAll/`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ .then((res) => {
+ setProductsData(res.data?.product);
+ setLoading(false);
+ })
+ .catch((error) => {
+ swal({
+ title: error,
+ text: "please login to access the resource or refresh the page ",
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ setLoading(false);
+ });
+ };
+
+ useEffect(() => {
+ getProductsData();
+ }, [success]);
+
+ useEffect(() => {
+ const loadData = () => {
+ const indexOfLastPost = currentPage * itemPerPage;
+ const indexOfFirstPost = indexOfLastPost - itemPerPage;
+ setShowData(productsData.slice(indexOfFirstPost, indexOfLastPost));
+ };
+ loadData();
+ }, [currentPage, itemPerPage, productsData]);
+
+ const handleDelete = (id) => {
+ swal({
+ title: "Are you sure?",
+ icon: "error",
+ buttons: {
+ Yes: { text: "Yes", value: true },
+ Cancel: { text: "Cancel", value: "cancel" },
+ },
+ }).then((value) => {
+ if (value === true) {
+ axios
+ .delete(`/api/product/delete/${id}`, {
+ headers: {
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ .then((res) => {
+ swal({
+ title: "Deleted",
+ text: "Product Deleted successfully!",
+ icon: "success",
+ button: "ok",
+ });
+ setSuccess((prev) => !prev);
+ })
+ .catch((err) => {
+ swal({
+ title: "Warning",
+ text: "Something went wrong!",
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ });
+ }
+ });
+ };
+ const [filterCategory, setFilterCategory] = useState("");
+
+ const handleSearchClick = (query) => {
+ const option = {
+ isCaseSensitive: true,
+ includeScore: false,
+ shouldSort: true,
+ includeMatches: false,
+ findAllMatches: false,
+ minMatchCharLength: 1,
+ location: 0,
+ threshold: 0.6,
+ distance: 100,
+ useExtendedSearch: true,
+ ignoreLocation: false,
+ ignoreFieldNorm: false,
+ fieldNormWeight: 1,
+ keys: ["name"],
+ };
+
+ const fuse = new Fuse(productsData, option);
+ const result = fuse.search(query);
+
+ const searchedResult = result.map((result) => result.item);
+ console.log(searchedResult);
+ setQueryData(searchedResult);
+ };
+ useEffect(() => {
+ if (query !== "") {
+ setFilterCategory("");
+ }
+ setTimeout(() => handleSearchClick(query), 100);
+ }, [query]);
+ useEffect(() => {
+ setTimeout(() => {
+ if (filterCategory !== "") {
+ const filteredProducts = productsData.filter(
+ (product) => product.category?.categoryName === filterCategory
+ );
+
+ setFilterData(filteredProducts);
+ } else {
+ // If no category is selected, show all products
+ setShowData(productsData);
+ // setFilterData(filteredProducts);
+ }
+ }, 100);
+ }, [filterCategory, productsData]);
+ return (
+
+
+
+
+
+
+
+ Blogs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Search by Blog name :
+
+ setQuery(e.target.value)}
+ InputProps={{
+ endAdornment: (
+ handleSearchClick(query)}
+ >
+
+
+ ),
+ disableUnderline: true,
+ }}
+ />
+
+
+
+
+
+
+
+
+
+
+
+ Image |
+ Title |
+ Added On |
+ Actions |
+
+
+
+ {!loading && showData.length === 0 && (
+
+
+ No Data Available
+ |
+
+ )}
+ {loading ? (
+
+
+ Loading...
+ |
+
+ ) : query === "" && filterCategory == "" ? (
+ showData.map((product, i) => {
+ return (
+
+
+ {/* {product.image &&
+ product.image.map((i, j) => (
+
+ ))} */}
+ {product.image && (
+
+ )}
+ |
+ {/* {product.name} | */}
+
+ The All new Samsumg s22 Ultra stormed the
+ market of India
+ |
+ {/*
+ {product.category?.categoryName !== ""
+ ? product.category?.categoryName
+ : "Category Not selected "}
+ | */}
+
+
+ {new Date(product.createdAt).toLocaleString(
+ "en-IN",
+ {
+ weekday: "short",
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "numeric",
+ hour12: true,
+ }
+ )}
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+
+ );
+ })
+ ) : query !== "" ? (
+ queryData.map((product, i) => {
+ return (
+
+
+ {product.image &&
+ product.image.map((i, j) => (
+
+ ))}
+ |
+ {product.name} |
+
+ {product.category !== ""
+ ? product.category?.categoryName
+ : "Category Not selected "}
+ |
+ ₹{product.price} |
+
+ {new Date(product.createdAt).toLocaleString(
+ "en-IN",
+ {
+ weekday: "short",
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "numeric",
+ hour12: true,
+ }
+ )}
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+
+ );
+ })
+ ) : (
+ query == "" &&
+ filterData.map((product, i) => {
+ return (
+
+
+ {product.image &&
+ product.image.map((i, j) => (
+
+ ))}
+ |
+ {product.name} |
+
+ {product.category?.categoryName}
+ |
+ ₹{product.price} |
+
+ {new Date(product.createdAt).toLocaleString(
+ "en-IN",
+ {
+ weekday: "short",
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "numeric",
+ hour12: true,
+ }
+ )}
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+
+ );
+ })
+ )}
+
+
+
+
+
+
+
+ Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
+ {Math.min(
+ currentPage * itemPerPage,
+ productsData.length
+ )}{" "}
+ of {productsData.length} entries
+
+
+
+
+
+
+ -
+ setCurrentPage((prev) => prev - 1)}
+ >
+ Previous
+
+
+
+ {!(currentPage - 1 < 1) && (
+ -
+
+ setCurrentPage((prev) => prev - 1)
+ }
+ >
+ {currentPage - 1}
+
+
+ )}
+
+ -
+
+ {currentPage}
+
+
+
+ {!(
+ (currentPage + 1) * itemPerPage - itemPerPage >
+ productsData.length - 1
+ ) && (
+ -
+ {
+ setCurrentPage((prev) => prev + 1);
+ }}
+ >
+ {currentPage + 1}
+
+
+ )}
+
+ -
+ productsData.length - 1
+ )
+ ? "paginate_button page-item next"
+ : "paginate_button page-item next disabled"
+ }
+ >
+ setCurrentPage((prev) => prev + 1)}
+ >
+ Next
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default Blogs;
diff --git a/src/views/Blog/CreateBlog.jsx b/src/views/Blog/CreateBlog.jsx
new file mode 100644
index 0000000..6391208
--- /dev/null
+++ b/src/views/Blog/CreateBlog.jsx
@@ -0,0 +1,344 @@
+import React, { useEffect, useState } from "react";
+import Button from "@material-ui/core/Button";
+import { Link, useNavigate } from "react-router-dom";
+import swal from "sweetalert";
+import axios from "axios";
+import { isAutheticated } from "src/auth";
+import CloudUploadIcon from "@mui/icons-material/CloudUpload";
+import DeleteSharpIcon from "@mui/icons-material/DeleteSharp";
+import { TagsInput } from "react-tag-input-component";
+import {
+ Box,
+ FormControl,
+ IconButton,
+ MenuItem,
+ Select,
+ TextField,
+} from "@mui/material";
+import { Editor } from "react-draft-wysiwyg";
+import { EditorState, convertToRaw } from "draft-js";
+import { stateToHTML } from "draft-js-export-html";
+// import { WebsiteURL } from '../WebsiteURL'
+
+const CreateBlog = () => {
+ const token = isAutheticated();
+ const navigate = useNavigate();
+
+ const [loading, setLoading] = useState(false);
+
+ const [imagesPreview, setImagesPreview] = useState([]);
+ // const [allimage, setAllImage] = useState([]);
+ const [title, setTitle] = useState("");
+ const [tag, setTag] = useState([]); //tags array
+ const [productImages, setProductImages] = useState([]);
+ const [blogContent, setBlogContent] = useState(EditorState.createEmpty());
+ // const [htmlData, setHtmlData] = useState();
+ const [error, setError] = useState("");
+
+ const handleFileChange = (e) => {
+ const files = e.target.files;
+
+ // Check the total number of selected files
+ if (productImages.length + files.length > 4) {
+ setError("You can only upload up to 4 images.");
+ return;
+ }
+
+ // Check file types and append to selectedFiles
+ const allowedTypes = ["image/jpeg", "image/png", "image/jpg"];
+ const selected = [];
+
+ for (let i = 0; i < files.length; i++) {
+ if (productImages.length + selected.length >= 4) {
+ break; // Don't allow more than 4 images
+ }
+
+ if (allowedTypes.includes(files[i].type)) {
+ selected.push(files[i]);
+ }
+ }
+
+ if (selected.length === 0) {
+ setError("Please upload only PNG, JPEG, or JPG files.");
+ } else {
+ setError("");
+ setProductImages([...productImages, ...selected]);
+ }
+ };
+
+ const handelDelete = (image) => {
+ const filtered = productImages.filter((item) => item !== image);
+ setProductImages(filtered);
+ };
+
+ const handleSubmit = () => {
+ setLoading(true);
+
+ const contentState = blogContent.getCurrentContent();
+ const htmlData = stateToHTML(contentState);
+ console.log(title, typeof htmlData, productImages, tag);
+ const formData = new FormData();
+ formData.append("title", title);
+ formData.append("blog_content", htmlData);
+
+ // Append each file from productImages array individually
+ productImages.forEach((file, index) => {
+ formData.append(`image${index}`, file);
+ });
+
+ // Append each tag from selected array individually
+ tag.forEach((tag, index) => {
+ formData.append(`tag${index}`, tag);
+ });
+ for (let entry of formData.entries()) {
+ console.log(entry);
+ }
+ // axios
+ // .post(`/api/v1/blog/create`, formData, {
+ // headers: {
+ // Authorization: `Bearer ${token}`,
+ // "Content-Type": "multipart/form-data",
+ // "Access-Control-Allow-Origin": "*",
+ // },
+ // })
+ // .then((res) => {
+ // swal({
+ // title: "Added",
+ // text: "Product added successfully!",
+ // icon: "success",
+ // button: "ok",
+ // });
+ // setLoading(false);
+ // // navigate("/products", { replace: true });
+ // })
+ // .catch((err) => {
+ // console.log(err);
+ // setLoading(false);
+ // const message = err.response?.data?.message
+ // ? err.response?.data?.message
+ // : "Something went wrong!";
+ // swal({
+ // title: "Warning",
+ // text: message,
+ // icon: "error",
+ // button: "Retry",
+ // dangerMode: true,
+ // });
+ // });
+ };
+ // console.log(data);
+ // console.log(productImages);
+ // To log the content when needed...
+
+ return (
+
+
+
+
+
+ Add Product
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ setTitle(e.target.value)}
+ />
+ {name ? (
+ <>
+
+ {25 - name.length} characters left
+
+ >
+ ) : (
+ <>>
+ )}{" "}
+
+
+
+
+
+
+ press enter or comma to add new tag
+
+
+
+
+
+
+
+
+ {error &&
{error}
}
+
+ Upload jpg, jpeg and png only*
+
+
+ {productImages &&
+ productImages.map((image, i) => (
+
+
+ handelDelete(image)}
+ fontSize="small"
+ sx={{
+ color: "white",
+ position: "absolute",
+ cursor: "pointer",
+ padding: "0.2rem",
+ background: "black",
+ borderRadius: "50%",
+ }}
+ />
+ {/* */}
+
+ ))}
+
+
+
+
+
+
+
+
+
+
+
+ {/* Note : style at _custom.scss */}
+ {
+ setBlogContent(editorState);
+ }}
+ />
+ {/* */}
+
+
+
+
+
+ );
+};
+
+export default CreateBlog;
diff --git a/src/views/Blog/test.jsx b/src/views/Blog/test.jsx
new file mode 100644
index 0000000..e69de29
diff --git a/src/views/Content/editPrivacyPolicy.js b/src/views/Content/editPrivacyPolicy.js
index 61d8dc2..5f1837b 100644
--- a/src/views/Content/editPrivacyPolicy.js
+++ b/src/views/Content/editPrivacyPolicy.js
@@ -1,27 +1,28 @@
import { Typography } from "@material-ui/core";
-import { Box, Button, TextField } from "@mui/material";
+import { Box, Button } from "@mui/material";
import React, { useEffect, useState } from "react";
-import ReactrichTextEditor from "./reactrichTextEditor";
import ReactQuill from "react-quill";
import "react-quill/dist/quill.snow.css";
import axios from "axios";
import { isAutheticated } from "src/auth";
-import { useNavigate, useNavigation } from "react-router-dom";
const TOOLBAR_OPTIONS = [
[{ header: [1, 2, 3, 4, 5, 6, false] }],
[{ font: [] }],
[{ list: "ordered" }, { list: "bullet" }],
- ["bold", "italic", "underline"],
+ ["bold", "italic", "underline", "strike"],
[{ color: [] }, { background: [] }],
[{ align: [] }],
+ [{ script: "super" }, { script: "sub" }],
+ ["undo", "redo"],
];
+
export default function EditPrivacyPolicy() {
const [title, setTitle] = useState("Privacy Policy");
const [content, setContent] = useState("");
const [added, setAdded] = useState(false);
const [olderContent, setOlderContent] = useState("");
- const navigation = useNavigate();
+ const [id, setId] = useState(null);
const token = isAutheticated();
const handleContentChange = (content, delta, source, editor) => {
@@ -37,6 +38,7 @@ export default function EditPrivacyPolicy() {
// console.log(response);
setContent(response?.data?.privacyAndPolicy[0]?.privacyAndPolicyContent);
+ setId(response?.data?.privacyAndPolicy[0]?._id);
setOlderContent(
response?.data?.privacyAndPolicy[0]?.privacyAndPolicyContent
);
@@ -70,15 +72,17 @@ export default function EditPrivacyPolicy() {
"/api/content/privacy-and-policy-update",
{ content },
{
+ params: { id: id },
headers: {
Authorization: `Bearer ${token}`,
},
}
+
);
if (response.status === 200) {
swal({
- title: "Congratulations!!",
- text: "Terms and condition updated successfully!",
+ title: "Congratulations!",
+ text: "Privacy policy updated successfully!",
icon: "success",
button: "OK",
});
@@ -93,16 +97,15 @@ export default function EditPrivacyPolicy() {
}
};
const handleSaveClick = async () => {
- if (olderContent === undefined) {
+ if (olderContent.length===0) {
await addPrivacyPolicy();
setAdded(true);
} else {
- await updateContent();
setAdded(false);
+ await updateContent();
}
-
- // Reload terms and conditions
- await getPrivacyPolicy();
+ // // Reload terms and conditions
+ // await getPrivacyPolicy();
};
useEffect(() => {
// addTermsandConditions();
diff --git a/src/views/Content/editRefundPolicy.js b/src/views/Content/editRefundPolicy.js
index af151c7..c8cca24 100644
--- a/src/views/Content/editRefundPolicy.js
+++ b/src/views/Content/editRefundPolicy.js
@@ -12,16 +12,20 @@ const TOOLBAR_OPTIONS = [
[{ header: [1, 2, 3, 4, 5, 6, false] }],
[{ font: [] }],
[{ list: "ordered" }, { list: "bullet" }],
- ["bold", "italic", "underline"],
+ ["bold", "italic", "underline", "strike"],
[{ color: [] }, { background: [] }],
[{ align: [] }],
+ [{ script: "super" }, { script: "sub" }],
+ ["undo", "redo"],
];
+
export default function editRefundPolicy() {
const [title, setTitle] = useState("Refund policy");
const [content, setContent] = useState("");
const [added, setAdded] = useState(false);
const [olderContent, setOlderContent] = useState("");
- const navigation = useNavigate();
+ const [id, setId] = useState(null)
+
const token = isAutheticated();
const handleContentChange = (content, delta, source, editor) => {
@@ -37,6 +41,7 @@ export default function editRefundPolicy() {
// console.log(response);
setContent(response?.data?.Refundpolicys[0]?.Refundpolicy);
setOlderContent(response?.data?.Refundpolicys[0]?.Refundpolicy);
+ setId(response?.data?.Refundpolicys[0]?._id);
}
};
@@ -64,13 +69,15 @@ export default function editRefundPolicy() {
};
const updateContent = async () => {
const response = await axios.patch(
- "/api/content//refund-policy",
+ "/api/content/refund-policy-update",
{ content },
{
+ params: { id: id },
headers: {
Authorization: `Bearer ${token}`,
},
}
+
);
if (response.status === 200) {
swal({
@@ -90,7 +97,7 @@ export default function editRefundPolicy() {
}
};
const handleSaveClick = async () => {
- if (olderContent === undefined) {
+ if (olderContent.length===0) {
await addTermsandConditions();
setAdded(true);
} else {
@@ -99,7 +106,7 @@ export default function editRefundPolicy() {
}
// Reload terms and conditions
- await getTermsAndConditions();
+ // await getTermsAndConditions();
};
useEffect(() => {
// addTermsandConditions();
diff --git a/src/views/Content/editShippingPolicy.js b/src/views/Content/editShippingPolicy.js
index 5c26fe6..6286e30 100644
--- a/src/views/Content/editShippingPolicy.js
+++ b/src/views/Content/editShippingPolicy.js
@@ -12,16 +12,20 @@ const TOOLBAR_OPTIONS = [
[{ header: [1, 2, 3, 4, 5, 6, false] }],
[{ font: [] }],
[{ list: "ordered" }, { list: "bullet" }],
- ["bold", "italic", "underline"],
+ ["bold", "italic", "underline", "strike"],
[{ color: [] }, { background: [] }],
[{ align: [] }],
+ [{ script: "super" }, { script: "sub" }],
+ ["undo", "redo"],
];
+
export default function EditShippingPolicy() {
const [title, setTitle] = useState("Shipping Policy");
const [content, setContent] = useState("");
const [added, setAdded] = useState(false);
const [olderContent, setOlderContent] = useState("");
- const navigation = useNavigate();
+ const [id, setId] = useState(null)
+
const token = isAutheticated();
const handleContentChange = (content, delta, source, editor) => {
@@ -38,6 +42,7 @@ export default function EditShippingPolicy() {
setContent(response?.data?.shipping[0]?.shippingContent);
setOlderContent(response?.data?.shipping[0]?.shippingContent);
+ setId(response?.data?.shipping[0]?._id);
}
};
@@ -68,6 +73,7 @@ export default function EditShippingPolicy() {
"/api/content/shipping-and-policy-update",
{ content },
{
+ params: { id: id },
headers: {
Authorization: `Bearer ${token}`,
},
@@ -76,7 +82,7 @@ export default function EditShippingPolicy() {
if (response.status === 200) {
swal({
title: "Congratulations!!",
- text: "Terms and condition updated successfully!",
+ text: "Shipping Policy updated successfully!",
icon: "success",
button: "OK",
});
@@ -91,7 +97,7 @@ export default function EditShippingPolicy() {
}
};
const handleSaveClick = async () => {
- if (olderContent === undefined) {
+ if (olderContent.length===0) {
await addShipping();
setAdded(true);
} else {
@@ -100,7 +106,7 @@ export default function EditShippingPolicy() {
}
// Reload terms and conditions
- await getShipping();
+ // await getShipping();
};
useEffect(() => {
// addTermsandConditions();
diff --git a/src/views/Content/editTermsConditions.js b/src/views/Content/editTermsConditions.js
index 0aa7c02..9e16e16 100644
--- a/src/views/Content/editTermsConditions.js
+++ b/src/views/Content/editTermsConditions.js
@@ -12,16 +12,20 @@ const TOOLBAR_OPTIONS = [
[{ header: [1, 2, 3, 4, 5, 6, false] }],
[{ font: [] }],
[{ list: "ordered" }, { list: "bullet" }],
- ["bold", "italic", "underline"],
+ ["bold", "italic", "underline", "strike"],
[{ color: [] }, { background: [] }],
[{ align: [] }],
+ [{ script: "super" }, { script: "sub" }],
+ ["undo", "redo"],
];
+
export default function EditTermsConditions() {
const [title, setTitle] = useState("Terms and conditions");
const [content, setContent] = useState("");
const [added, setAdded] = useState(false);
const [olderContent, setOlderContent] = useState("");
- const navigation = useNavigate();
+ const [id, setId] = useState(null)
+
const token = isAutheticated();
const handleContentChange = (content, delta, source, editor) => {
@@ -39,6 +43,9 @@ export default function EditTermsConditions() {
setOlderContent(
response?.data?.termsAndCondition[0]?.termsAndContionContent
);
+ setId(
+ response?.data?.termsAndCondition[0]?._id
+ );
}
};
@@ -69,6 +76,7 @@ export default function EditTermsConditions() {
"/api/content/terms-and-condition-update",
{ content },
{
+ params: { id: id },
headers: {
Authorization: `Bearer ${token}`,
},
@@ -92,7 +100,7 @@ export default function EditTermsConditions() {
}
};
const handleSaveClick = async () => {
- if (olderContent === undefined) {
+ if (olderContent.length===0) {
await addTermsandConditions();
setAdded(true);
} else {
@@ -101,7 +109,7 @@ export default function EditTermsConditions() {
}
// Reload terms and conditions
- await getTermsAndConditions();
+ // await getTermsAndConditions();
};
useEffect(() => {
// addTermsandConditions();