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

View File

@ -178,8 +178,8 @@ export const deleteOneDirectory = async (req, res) => {
export const getSelfDirectory = async (req, res) => { export const getSelfDirectory = async (req, res) => {
try { try {
const directory = await directoryModel.findOne({ userId: req.user.id }); const directory = await directoryModel.find({ userId: req.user.id });
// console.log(category)
if (!directory) { if (!directory) {
return res.status(400).json({ message: 'No self directory exist ' }); 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) // 7.Get single user (admin)
export const getSingleUser = catchAsyncErrors(async (req, res, next) => { 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); const user = await User.findById(req.params.id);
if (!user) { if (!user) {
return next( 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: { section: {
type: String, type: String,
required: true
}, },
subSection: { subSection: {
type: String, type: String,