mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
tier plans improving
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -146,12 +146,18 @@ exports.getUnits = async (req, res) => {
|
||||
const is_locked = (row.subscription || Number(row.course_count) > 0)
|
||||
? !(await coursesCtrl.canAccessUnit(req.user.user_id, row.unit_id))
|
||||
: false;
|
||||
const product = productById.get(String(row.unit_id)) ?? null;
|
||||
const has_purchased = purchasedIds.has(String(row.unit_id));
|
||||
const purchase_eligible = (is_locked && product && !has_purchased)
|
||||
? await coursesCtrl.isPurchaseEligible(req.user.user_id, row.subscription, "unit", row.unit_id)
|
||||
: true;
|
||||
result.push({
|
||||
...row,
|
||||
courses: coursesByUnit.get(row.unit_id) ?? [],
|
||||
is_locked,
|
||||
product: productById.get(String(row.unit_id)) ?? null,
|
||||
has_purchased: purchasedIds.has(String(row.unit_id)),
|
||||
product,
|
||||
has_purchased,
|
||||
purchase_eligible,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -208,12 +214,18 @@ exports.getLessons = async (req, res) => {
|
||||
const is_locked = (row.subscription || Number(row.unit_count) > 0)
|
||||
? !(await coursesCtrl.canAccessLesson(req.user.user_id, row.lesson_id))
|
||||
: false;
|
||||
const product = productById.get(String(row.lesson_id)) ?? null;
|
||||
const has_purchased = purchasedIds.has(String(row.lesson_id));
|
||||
const purchase_eligible = (is_locked && product && !has_purchased)
|
||||
? await coursesCtrl.isPurchaseEligible(req.user.user_id, row.subscription, "lesson", row.lesson_id)
|
||||
: true;
|
||||
result.push({
|
||||
...row,
|
||||
courses: coursesByLesson.get(row.lesson_id) ?? [],
|
||||
is_locked,
|
||||
product: productById.get(String(row.lesson_id)) ?? null,
|
||||
has_purchased: purchasedIds.has(String(row.lesson_id)),
|
||||
product,
|
||||
has_purchased,
|
||||
purchase_eligible,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user