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();