Skip to content

Commit

Permalink
Merge pull request #95 from AVtheking/wallet
Browse files Browse the repository at this point in the history
Wallet
  • Loading branch information
AVtheking authored Nov 26, 2023
2 parents 2a95192 + bf50e9e commit 0455518
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 10 additions & 4 deletions controllers/course_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const courseCtrl = {
const course = await Course.findById(courseId, {
isPublished: true,
isPublished: 0,
reviews: 0,

__v: 0,
ratings: 0,
})
Expand All @@ -113,6 +113,10 @@ const courseCtrl = {
path: "preview",
select:
"_id videoTitle videoUrl videoDuration videoUrl_144p videoUrl_360p videoUrl_720p",
})
.populate({
path: "reviews.user",
select: "_id username name profileimg",
});

if (!course) {
Expand All @@ -122,6 +126,7 @@ const courseCtrl = {
const courseIdIndex = user.ownedCourse.findIndex((course) =>
course.courseId.equals(courseId)
);

const cartIdIndex = user.cart.findIndex((course) =>
course.equals(courseId)
);
Expand Down Expand Up @@ -215,6 +220,7 @@ const courseCtrl = {
duration: 1,
totalStudents: 1,
category: 1,
weightedRating: 1,
rating: 1,
thumbnail: 1,
createdAt: 1,
Expand Down Expand Up @@ -289,7 +295,7 @@ const courseCtrl = {
.populate({
path: "courses",
select:
"_id title description category price thumbnail rating duration createdAt updatedAt ",
"_id title description category price thumbnail rating weightedRating duration createdAt updatedAt ",
options: {
limit: limit ? limit : pageSize,
},
Expand Down Expand Up @@ -323,7 +329,7 @@ const courseCtrl = {
.sort({ count: -1 })
.select({ search: 1, _id: 0 })
.limit(5);

res.json({
success: true,
message: "List of popular searches",
Expand Down Expand Up @@ -454,7 +460,7 @@ const courseCtrl = {
thumbnail: 1,
createdAt: 1,
updatedAt: 1,
weightedRating:1,
weightedRating: 1,
createdBy: { _id: 1, username: 1, name: 1 },
},
},
Expand Down
8 changes: 5 additions & 3 deletions controllers/payment_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ const paymentCtrl = {
try {
const user = req.user;
const amount = parseInt(req.params.amount);
const result = amountSchema.validateAsync(amount)
console.log(amount)
const result = await amountSchema.validateAsync({amount})
const price = result.amount
console.log(price)
if (user.cart.length == 0) {
return next(new ErrorHandler(404, "No course in cart"));
}
Expand Down Expand Up @@ -156,7 +158,7 @@ const paymentCtrl = {
try {
// const user = req.user;
const amount = parseInt(req.params.amount);
const result = amountSchema.validateAsync(amount)
const result =await amountSchema.validateAsync({amount})
const price = result.amount
const razorpayInstance = new Razorpay({
key_id: process.env.KEY_ID,
Expand Down Expand Up @@ -189,7 +191,7 @@ const paymentCtrl = {
checkPayment: async (req, res, next) => {
try {
const amount = parseInt(req.params.amount);
const result =amountSchema.validateAsync(amount)
const result =await amountSchema.validateAsync({amount})
const price = result.amount

const user = req.user;
Expand Down

0 comments on commit 0455518

Please sign in to comment.