fixed legal content api
This commit is contained in:
parent
fd6a8e9c9b
commit
608cc318a6
@ -51,16 +51,24 @@ export const getTermsAndCondition = async (req, res) => {
|
|||||||
export const updateTermsAndConditions = async (req, res) => {
|
export const updateTermsAndConditions = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||||
// console.log(req?.user)
|
// new content
|
||||||
const { content } = req.body;
|
const { content } = req.body;
|
||||||
const termsAndCondition = await TermsAndCondition.findOneAndUpdate(
|
|
||||||
{
|
// id of the terms and conndition document
|
||||||
addedBy: req.user._id,
|
const id = req.query.id;
|
||||||
},
|
|
||||||
{
|
// object for updated terms and conndition data
|
||||||
termsAndContionContent: content,
|
const updatedTermsData = {
|
||||||
}
|
termsAndContionContent: content,
|
||||||
);
|
addedBy: req.user._id
|
||||||
|
}
|
||||||
|
|
||||||
|
// update the terms and conndition in database
|
||||||
|
const termsAndCondition = await TermsAndCondition.findByIdAndUpdate(
|
||||||
|
{ _id: id },
|
||||||
|
{ $set: updatedTermsData },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
@ -80,23 +88,10 @@ export const RefundPolicy = async (req, res) => {
|
|||||||
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||||
// console.log(req?.user)
|
// console.log(req?.user)
|
||||||
const { content } = req.body;
|
const { content } = req.body;
|
||||||
const findv = await Refundpolicy.findOne();
|
const refundPolicy = await Refundpolicy.create({
|
||||||
let refundPolicy;
|
|
||||||
if (findv) {
|
|
||||||
refundPolicy = await Refundpolicy.findOneAndUpdate(
|
|
||||||
{
|
|
||||||
addedBy: req.user._id,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Refundpolicy: content,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
refundPolicy = await Refundpolicy.create({
|
|
||||||
addedBy: req.user._id,
|
addedBy: req.user._id,
|
||||||
Refundpolicy: content,
|
Refundpolicy: content,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
@ -130,6 +125,42 @@ export const getRefundPolicy = async (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// update refund policy
|
||||||
|
export const updateRefundPolicy = async (req, res) => {
|
||||||
|
try {
|
||||||
|
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||||
|
|
||||||
|
const {content} = req.body;
|
||||||
|
// id of the refund policy document
|
||||||
|
const id = req.query.id;
|
||||||
|
|
||||||
|
// object for updated refund policy data
|
||||||
|
const updatedRefundPolicyData = {
|
||||||
|
Refundpolicy: content,
|
||||||
|
addedBy: req.user._id
|
||||||
|
}
|
||||||
|
|
||||||
|
// update the refund policy in database
|
||||||
|
const refundPolicy = await Refundpolicy.findByIdAndUpdate(
|
||||||
|
{ _id: id },
|
||||||
|
{ $set: updatedRefundPolicyData },
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
refundPolicy,
|
||||||
|
message: "updated successfully ",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
message: error.message ? error.message : "Something went Wrong",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Privacy policy controller functions
|
// Privacy policy controller functions
|
||||||
|
|
||||||
export const AddPrivacyAndPolicy = async (req, res) => {
|
export const AddPrivacyAndPolicy = async (req, res) => {
|
||||||
@ -180,15 +211,24 @@ export const getPrivacyPolicy = async (req, res) => {
|
|||||||
export const updatePrivacyPolicy = async (req, res) => {
|
export const updatePrivacyPolicy = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||||
// console.log(req?.user)
|
|
||||||
|
// new content
|
||||||
const { content } = req.body;
|
const { content } = req.body;
|
||||||
const privacyAndPolicy = await PrivacyAndPolicy.findOneAndUpdate(
|
|
||||||
{
|
// id of the privacy policy document
|
||||||
addedBy: req.user._id,
|
const id = req.query.id;
|
||||||
},
|
|
||||||
{
|
// object for updated privacy policy data
|
||||||
privacyAndPolicyContent: content,
|
const updatedPrivacyPolicyData = {
|
||||||
}
|
privacyAndPolicyContent: content,
|
||||||
|
addedBy: req.user._id
|
||||||
|
}
|
||||||
|
|
||||||
|
// update the privacy policy in database
|
||||||
|
const privacyAndPolicy = await PrivacyAndPolicy.findByIdAndUpdate(
|
||||||
|
{ _id: id },
|
||||||
|
{ $set: updatedPrivacyPolicyData },
|
||||||
|
{ new: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
@ -254,15 +294,23 @@ export const getShipping = async (req, res) => {
|
|||||||
export const updateShipping = async (req, res) => {
|
export const updateShipping = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||||
// console.log(req?.user)
|
// new content
|
||||||
const { content } = req.body;
|
const { content } = req.body;
|
||||||
const shipping = await Shipping.findOneAndUpdate(
|
|
||||||
{
|
// id of the shipping policy document
|
||||||
addedBy: req.user._id,
|
const id = req.query.id;
|
||||||
},
|
|
||||||
{
|
// object for updated shipping policy data
|
||||||
shippingContent: content,
|
const updatedShippingData = {
|
||||||
}
|
shippingContent: content,
|
||||||
|
addedBy: req.user._id
|
||||||
|
}
|
||||||
|
|
||||||
|
// update the shipping policy in database
|
||||||
|
const shipping = await Shipping.findByIdAndUpdate(
|
||||||
|
{ _id: id },
|
||||||
|
{ $set: updatedShippingData },
|
||||||
|
{ new: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
updatePrivacyPolicy,
|
updatePrivacyPolicy,
|
||||||
updateShipping,
|
updateShipping,
|
||||||
updateTermsAndConditions,
|
updateTermsAndConditions,
|
||||||
|
updateRefundPolicy
|
||||||
} from "./ContentController.js";
|
} from "./ContentController.js";
|
||||||
import { isAuthenticatedUser, authorizeRoles } from "../../middlewares/auth.js";
|
import { isAuthenticatedUser, authorizeRoles } from "../../middlewares/auth.js";
|
||||||
|
|
||||||
@ -46,7 +47,10 @@ router
|
|||||||
router.route("/refund-policy").get(getRefundPolicy);
|
router.route("/refund-policy").get(getRefundPolicy);
|
||||||
router
|
router
|
||||||
.route("/refund-policy")
|
.route("/refund-policy")
|
||||||
.patch(isAuthenticatedUser, authorizeRoles("admin"), RefundPolicy);
|
.post(isAuthenticatedUser, authorizeRoles("admin"), RefundPolicy);
|
||||||
|
router
|
||||||
|
.route("/refund-policy-update")
|
||||||
|
.patch(isAuthenticatedUser, authorizeRoles("admin"), updateRefundPolicy);
|
||||||
//
|
//
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
Loading…
Reference in New Issue
Block a user