From 3a33f047f57e16d4b14c73136d63ca6a9a10434a Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Fri, 5 Jan 2024 18:22:03 +0530 Subject: [PATCH] feat: batch details --- .pre-commit-config.yaml | 2 +- frontend/src/components/AppSidebar.vue | 99 ++-- frontend/src/components/BatchCard.vue | 124 ++-- frontend/src/components/BatchOverlay.vue | 81 +++ frontend/src/components/CourseCard.vue | 241 +++++--- frontend/src/components/CourseCardOverlay.vue | 203 ++++--- frontend/src/components/CourseOutline.vue | 141 +++-- frontend/src/pages/Batch.vue | 70 +++ frontend/src/pages/BatchDetail.vue | 126 +++- frontend/src/pages/CourseDetail.vue | 205 ++++--- frontend/src/pages/Lesson.vue | 542 +++++++++++------- frontend/src/router.js | 9 +- frontend/src/utils/index.js | 28 + lms/lms/api.py | 5 +- lms/lms/utils.py | 1 + 15 files changed, 1215 insertions(+), 662 deletions(-) create mode 100644 frontend/src/components/BatchOverlay.vue create mode 100644 frontend/src/pages/Batch.vue diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b2ac7630..26145761 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: rev: v2.7.1 hooks: - id: prettier - types_or: [javascript] + types_or: [javascript, vue] # Ignore any files that might contain jinja / bundles exclude: | (?x)^( diff --git a/frontend/src/components/AppSidebar.vue b/frontend/src/components/AppSidebar.vue index bfb56346..2a192cd1 100644 --- a/frontend/src/components/AppSidebar.vue +++ b/frontend/src/components/AppSidebar.vue @@ -1,23 +1,37 @@ diff --git a/frontend/src/components/BatchCard.vue b/frontend/src/components/BatchCard.vue index e21941fd..23ab8981 100644 --- a/frontend/src/components/BatchCard.vue +++ b/frontend/src/components/BatchCard.vue @@ -1,71 +1,65 @@ \ No newline at end of file + diff --git a/frontend/src/components/BatchOverlay.vue b/frontend/src/components/BatchOverlay.vue new file mode 100644 index 00000000..cd32fcea --- /dev/null +++ b/frontend/src/components/BatchOverlay.vue @@ -0,0 +1,81 @@ + + diff --git a/frontend/src/components/CourseCard.vue b/frontend/src/components/CourseCard.vue index 43438150..135c88d5 100644 --- a/frontend/src/components/CourseCard.vue +++ b/frontend/src/components/CourseCard.vue @@ -1,97 +1,156 @@ \ No newline at end of file + diff --git a/frontend/src/components/CourseCardOverlay.vue b/frontend/src/components/CourseCardOverlay.vue index 5f8d82c4..b02ad176 100644 --- a/frontend/src/components/CourseCardOverlay.vue +++ b/frontend/src/components/CourseCardOverlay.vue @@ -1,101 +1,132 @@ \ No newline at end of file + diff --git a/frontend/src/router.js b/frontend/src/router.js index 775ba88e..483fce14 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -32,9 +32,16 @@ const routes = [ component: () => import('@/pages/Batches.vue'), }, { - path: '/batches/:batchName', + path: '/batches/details/:batchName', name: 'BatchDetail', component: () => import('@/pages/BatchDetail.vue'), + props: true, + }, + { + path: '/batches/:batchName', + name: 'Batch', + component: () => import('@/pages/Batch.vue'), + props: true, }, ] diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index 6f23afe5..a103dcf7 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -11,3 +11,31 @@ export function createToast(options) { export function timeAgo(date) { return useTimeAgo(date).value } + +export function formatTime(timeString) { + if (!timeString) return '' + const [hour, minute] = timeString.split(':').map(Number) + + // Create a Date object with dummy values for day, month, and year + const dummyDate = new Date(0, 0, 0, hour, minute) + + // Use Intl.DateTimeFormat to format the time in 12-hour format + const formattedTime = new Intl.DateTimeFormat('en-US', { + hour: 'numeric', + minute: 'numeric', + hour12: true, + }).format(dummyDate) + + return formattedTime +} + +export function formatNumberIntoCurrency(number, currency) { + if (number) { + return number.toLocaleString('en-IN', { + maximumFractionDigits: 0, + style: 'currency', + currency: currency, + }) + } + return '' +} diff --git a/lms/lms/api.py b/lms/lms/api.py index 5c475262..c681c900 100644 --- a/lms/lms/api.py +++ b/lms/lms/api.py @@ -39,10 +39,7 @@ def save_current_lesson(course_name, lesson_name): ) if not name: return - doc = frappe.get_doc("LMS Enrollment", name) - doc.current_lesson = lesson_name - doc.save() - return {"current_lesson": doc.current_lesson} + frappe.db.set_value("LMS Enrollment", name, "current_lesson", lesson_name) @frappe.whitelist() diff --git a/lms/lms/utils.py b/lms/lms/utils.py index d9577b28..eb4b29eb 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -1322,6 +1322,7 @@ def get_lesson(course, chapter, lesson): neighbours = get_neighbour_lesson(course, chapter, lesson) lesson_details.next = neighbours["next"] lesson_details.prev = neighbours["prev"] + lesson_details.membership = membership return lesson_details