App NAme Copiright message
This commit is contained in:
parent
5559fa8b45
commit
fff6384aac
23
app.js
23
app.js
@ -22,33 +22,34 @@ app.use(fileUpload({
|
||||
|
||||
//auth
|
||||
import user from "./resources/user/userRoute.js"
|
||||
import ProductRouter from "./resources/Products/ProductRoute.js";
|
||||
import orderRoute from './resources/Orders/orderRoute.js'
|
||||
import DepartureRouter from "./resources/Departure/DepartureRoute.js";
|
||||
import InformationRoute from "./resources/Informations/InformationRoute.js";
|
||||
import ComplaintRoute from "./resources/Complaints/ComplaintRoute.js";
|
||||
|
||||
import StateRouter from "./resources/setting/state/state_routes.js";
|
||||
import CityRouter from "./resources/setting/city/city_routes.js";
|
||||
import ConfigRouter from "./resources/setting/Configration/Config_routes.js";
|
||||
import TaxRouter from "./resources/Tax/tax_routes.js";
|
||||
app.use("/api/v1/", user);
|
||||
//Product
|
||||
import ProductRouter from "./resources/Products/ProductRoute.js";
|
||||
app.use("/api", ProductRouter);
|
||||
//Order
|
||||
import orderRoute from './resources/Orders/orderRoute.js'
|
||||
app.use("/api", orderRoute);
|
||||
|
||||
//Departure
|
||||
import DepartureRouter from "./resources/Departure/DepartureRoute.js";
|
||||
app.use("/api/departure/", DepartureRouter);
|
||||
//Information
|
||||
import InformationRoute from "./resources/Informations/InformationRoute.js";
|
||||
app.use("/api/information/", InformationRoute);
|
||||
//Complaints
|
||||
app.use("/api/complaint/", ComplaintRoute);
|
||||
//state
|
||||
import StateRouter from "./resources/setting/state/state_routes.js";
|
||||
app.use("/api/state", StateRouter);
|
||||
|
||||
//city
|
||||
import CityRouter from "./resources/setting/city/city_routes.js";
|
||||
app.use("/api/city", CityRouter);
|
||||
//Tax
|
||||
import TaxRouter from "./resources/Tax/tax_routes.js";
|
||||
app.use("/api/tax", TaxRouter);
|
||||
//config
|
||||
import ConfigRouter from "./resources/setting/Configration/Config_routes.js";
|
||||
|
||||
app.use("/api/config", ConfigRouter)
|
||||
|
||||
export default app;
|
53
resources/Complaints/ComplaintController.js
Normal file
53
resources/Complaints/ComplaintController.js
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
import { Complaint } from "./ComplaintModel.js"
|
||||
export const AddNewComplaint = async (req, res) => {
|
||||
try {
|
||||
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||
// console.log(req?.user)
|
||||
|
||||
|
||||
// req.body.user = req.user._id
|
||||
const complaint = await Complaint.create(req.body);
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
complaint,
|
||||
message: 'Complaint Added',
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: error.message ? error.message : 'Something went Wrong',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const FindAllComplaint = async (req, res) => {
|
||||
try {
|
||||
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||
// console.log(req?.user)
|
||||
|
||||
|
||||
const complaint = await Complaint.find().sort({ createdAt: -1 });
|
||||
if (complaint) {
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
complaint,
|
||||
message: 'Fetched All Complaint',
|
||||
});
|
||||
}
|
||||
else {
|
||||
return res.status(404).json({
|
||||
success: true,
|
||||
|
||||
message: 'No Complaint till Now',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: error.message ? error.message : 'Something went Wrong',
|
||||
});
|
||||
}
|
||||
}
|
23
resources/Complaints/ComplaintModel.js
Normal file
23
resources/Complaints/ComplaintModel.js
Normal file
@ -0,0 +1,23 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const { Schema, model } = mongoose;
|
||||
|
||||
const ComplaintSchema = new mongoose.Schema(
|
||||
{
|
||||
|
||||
MobileOrEmail: {
|
||||
type: String,
|
||||
maxLength: [150, "Mobile Or Email cannot exceed 25 characters"],
|
||||
required: [true, "Please Enter Mobile Or Email "],
|
||||
},
|
||||
Complaint: {
|
||||
type: String,
|
||||
maxLength: [1000, "Complaint cannot exceed 1000 characters"],
|
||||
required: [true, "Please Enter Complaint"],
|
||||
},
|
||||
|
||||
},
|
||||
{ timestamps: true, versionKey: false }
|
||||
);
|
||||
|
||||
export const Complaint = mongoose.model("Complaint", ComplaintSchema);
|
18
resources/Complaints/ComplaintRoute.js
Normal file
18
resources/Complaints/ComplaintRoute.js
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
import express from 'express'
|
||||
import { isAuthenticatedUser, authorizeRoles } from "../../middlewares/auth.js";
|
||||
import { AddNewComplaint, FindAllComplaint } from './ComplaintController.js';
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
router.route("/new").post(isAuthenticatedUser, AddNewComplaint)
|
||||
router.route("/getAll").get(isAuthenticatedUser, authorizeRoles("admin"), FindAllComplaint)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// router.route("/product/getAll/").get(getAllProduct)
|
||||
|
||||
export default router
|
@ -13,7 +13,7 @@ const informationSchema = new mongoose.Schema(
|
||||
description: {
|
||||
type: String,
|
||||
maxLength: [500, "description cannot exceed 500 characters"],
|
||||
required: [true, "Please Enter product description"],
|
||||
required: [true, "Please Enter description"],
|
||||
},
|
||||
user: {
|
||||
type: Schema.Types.ObjectId,
|
||||
|
@ -1,50 +1,105 @@
|
||||
import { Config } from "./Config_model.js";
|
||||
import cloudinary from "../../../Utils/cloudinary.js";
|
||||
// // Add GST
|
||||
// const addGST = async (req, res) => {
|
||||
// const { gst } = req.body;
|
||||
// try {
|
||||
// if (!gst) {
|
||||
// return res.status(400).json({
|
||||
// status: "failed",
|
||||
// message: "Please Provide Valid GST Value",
|
||||
// });
|
||||
// }
|
||||
// const configuration = await Config.find();
|
||||
|
||||
// if (configuration.length === 0) {
|
||||
// const createGst = await Config.create({
|
||||
// gst,
|
||||
// });
|
||||
//Add app Name
|
||||
// Add Social Media
|
||||
|
||||
// if (createGst) {
|
||||
// return res.status(201).json({
|
||||
// status: "success",
|
||||
// message: "GST Created",
|
||||
// });
|
||||
// }
|
||||
// } else {
|
||||
// const updateGst = await Config.updateOne(
|
||||
// {},
|
||||
// {
|
||||
// $set: {
|
||||
// gst,
|
||||
// },
|
||||
// }
|
||||
// );
|
||||
export const addApplicationName = async (req, res) => {
|
||||
|
||||
// if (updateGst) {
|
||||
// return res.status(200).json({
|
||||
// status: "success",
|
||||
// message: "Updated GST Successfully",
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
// };
|
||||
|
||||
try {
|
||||
if (req.body === '') {
|
||||
return res.status(201).json({
|
||||
status: "false",
|
||||
message: "please enter application Name",
|
||||
});
|
||||
}
|
||||
const { appName } =
|
||||
req.body;
|
||||
|
||||
|
||||
const applicationNam = await Config.find()
|
||||
if (applicationNam.length === 0) {
|
||||
const applicationName = await Config.create({
|
||||
appName
|
||||
});
|
||||
|
||||
if (applicationName) {
|
||||
return res.status(201).json({
|
||||
status: "success",
|
||||
message: "Added application Name Successfully",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const updateApp = await Config.updateOne({
|
||||
|
||||
appName:
|
||||
appName
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
if (updateApp) {
|
||||
return res.status(200).json({
|
||||
status: "success",
|
||||
message: "Updated Application Name Successfully",
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
export const addCopyRightMessage = async (req, res) => {
|
||||
|
||||
|
||||
try {
|
||||
if (req.body === '') {
|
||||
return res.status(201).json({
|
||||
status: "false",
|
||||
message: "please enter CopyRight Message",
|
||||
});
|
||||
}
|
||||
const { copyright } =
|
||||
req.body;
|
||||
|
||||
|
||||
const application = await Config.find()
|
||||
if (application.length === 0) {
|
||||
const applicationName = await Config.create({
|
||||
copyrightMessage: copyright
|
||||
});
|
||||
|
||||
if (applicationName) {
|
||||
return res.status(201).json({
|
||||
status: "success",
|
||||
message: "Added copyright message Successfully",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const updateApp = await Config.updateOne({
|
||||
|
||||
copyrightMessage:
|
||||
copyright
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
if (updateApp) {
|
||||
return res.status(200).json({
|
||||
status: "success",
|
||||
message: "Updated copyright message Successfully",
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
// Add Social Media
|
||||
|
||||
const addSocialMedia = async (req, res) => {
|
||||
|
@ -3,7 +3,8 @@ import mongoose from "mongoose";
|
||||
const { Schema, model } = mongoose;
|
||||
|
||||
const configSchema = new Schema({
|
||||
// gst: { type: Number },
|
||||
appName: { type: String, default: "" },
|
||||
copyrightMessage: { type: String, default: "" },
|
||||
// scrollText: { type: String },
|
||||
socialMedia: { type: Array, default: [] },
|
||||
address: { type: Array, default: [] },
|
||||
|
@ -8,7 +8,9 @@ import {
|
||||
getConfig,
|
||||
// addScrollText,
|
||||
addTermsOfUse,
|
||||
addApplicationName,
|
||||
getTermsOfUse,
|
||||
addCopyRightMessage,
|
||||
} from "./Config_controller.js";
|
||||
import { upload } from "../../../Utils/cloudinary.js";
|
||||
|
||||
@ -25,10 +27,15 @@ const router = Router();
|
||||
|
||||
// router.route("/gst").post(isAuthenticatedUser, authorizeRoles("admin"), addGST);
|
||||
router.route("/social").post(isAuthenticatedUser, authorizeRoles("admin"), addSocialMedia);
|
||||
router.route("/application/name").post(isAuthenticatedUser, authorizeRoles("admin"), addApplicationName);
|
||||
router.route("/copyright/message").post(isAuthenticatedUser, authorizeRoles("admin"), addCopyRightMessage);
|
||||
|
||||
|
||||
|
||||
router.route("/address").post(isAuthenticatedUser, authorizeRoles("admin"), addAddress);
|
||||
// router.route("/scrollText").post(isAuthenticatedUser, authorizeRoles("admin"), addScrollText);
|
||||
router.route("/logo").post(isAuthenticatedUser, authorizeRoles("admin"), addLogo);
|
||||
router.route("/").get(getConfig).delete(isAuthenticatedUser, authorizeRoles("admin"), deleteConfig);
|
||||
router.route("/").get(getConfig).delete(isAuthenticatedUser, authorizeRoles("admin"), deleteConfig)
|
||||
|
||||
router
|
||||
.route("/termsofuse")
|
||||
|
Loading…
Reference in New Issue
Block a user