self directory

This commit is contained in:
pawan-dot 2022-10-28 13:08:59 +05:30
parent 5999a86702
commit 79ab25e447
4 changed files with 16 additions and 10 deletions

View File

@ -13,7 +13,7 @@ export const createBanner = async (req, res) => {
},
function (error, result) { (result, error) });
const { title, section, startDate, subSection, endDate, subTitle } = req.body;
const { title, startDate, endDate, subTitle } = req.body;
const data = await Banners.create({
title,
subTitle,
@ -21,10 +21,10 @@ export const createBanner = async (req, res) => {
public_id: myCloud.public_id,
url: myCloud.secure_url,
},
section,
// section,
startDate,
endDate,
subSection
// subSection
});
@ -85,12 +85,13 @@ export const getOneBanner = async (req, res) => {
// 3.update Event
export const updateBanner = async (req, res) => {
try {
const newBannerData = {
title: req.body.title,
subTitle: req.body.subTitle,
section: req.body.section,
subSection: req.body.subSection,
// section: req.body.section,
// subSection: req.body.subSection,
startDate: req.body.startDate,
endDate: req.body.endDate,
};
@ -130,7 +131,7 @@ export const updateBanner = async (req, res) => {
});
} catch (error) {
// console.log(error)
console.log(error)
res.status(500).json({
success: false,
msg: "Failled to UpDate Banner!!"

View File

@ -178,8 +178,8 @@ export const deleteOneDirectory = async (req, res) => {
export const getSelfDirectory = async (req, res) => {
try {
const directory = await directoryModel.findOne({ userId: req.user.id });
// console.log(category)
const directory = await directoryModel.find({ userId: req.user.id });
if (!directory) {
return res.status(400).json({ message: 'No self directory exist ' });
}

View File

@ -197,11 +197,16 @@ export const getUserDetails = catchAsyncErrors(async (req, res, next) => {
// 7.Get single user (admin)
export const getSingleUser = catchAsyncErrors(async (req, res, next) => {
if (!req.params.id) {
return next(
new ErrorHander(`please send User ID`, 404)
);
}
const user = await User.findById(req.params.id);
if (!user) {
return next(
new ErrorHander(`User does not exist with Id: ${req.params.id}`)
new ErrorHander(`User does not exist with Id: ${req.params.id}`, 404)
);
}

View File

@ -22,7 +22,7 @@ const bannerSchema = new mongoose.Schema(
},
section: {
type: String,
required: true
},
subSection: {
type: String,