From f48f4370755452c1d98dabf84c365db5d3048391 Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Tue, 16 Apr 2024 21:24:53 +0530 Subject: [PATCH 1/3] fix: handle same start and end dates case for batch * also minor refactor --- frontend/src/components/BatchCard.vue | 9 +++------ frontend/src/components/BatchOverlay.vue | 12 +++++++----- frontend/src/pages/Batch.vue | 8 ++++---- frontend/src/pages/BatchDetail.vue | 21 ++++++++++++--------- frontend/src/utils/index.js | 10 ++++++++++ 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/frontend/src/components/BatchCard.vue b/frontend/src/components/BatchCard.vue index 071395b5..2e1e080d 100644 --- a/frontend/src/components/BatchCard.vue +++ b/frontend/src/components/BatchCard.vue @@ -34,8 +34,7 @@
- {{ dayjs(batch.start_date).format('DD MMM YYYY') }} - - {{ dayjs(batch.end_date).format('DD MMM YYYY') }} + {{ getFormattedDateRange(batch.start_date, batch.end_date) }}
@@ -48,12 +47,10 @@
diff --git a/frontend/src/pages/Batch.vue b/frontend/src/pages/Batch.vue index 99400e74..32899932 100644 --- a/frontend/src/pages/Batch.vue +++ b/frontend/src/pages/Batch.vue @@ -80,14 +80,12 @@ {{ batch.data.title }}
-
- - - {{ - getFormattedDateRange(batch.data.start_date, batch.data.end_date) - }} - -
+ +
@@ -151,7 +149,6 @@ import { Breadcrumbs, Button, createResource, Tabs, Badge } from 'frappe-ui' import { computed, inject, ref } from 'vue' import { - Calendar, Clock, LayoutDashboard, BookOpen, @@ -162,7 +159,7 @@ import { SendIcon, MessageCircle, } from 'lucide-vue-next' -import { formatTime, getFormattedDateRange } from '@/utils' +import { formatTime } from '@/utils' import BatchDashboard from '@/components/BatchDashboard.vue' import BatchCourses from '@/components/BatchCourses.vue' import LiveClass from '@/components/LiveClass.vue' @@ -171,6 +168,7 @@ import Assessments from '@/components/Assessments.vue' import Announcements from '@/components/Annoucements.vue' import AnnouncementModal from '@/components/Modals/AnnouncementModal.vue' import Discussions from '@/components/Discussions.vue' +import DateRange from '@/components/Common/DateRange.vue' const user = inject('$user') const showAnnouncementModal = ref(false) diff --git a/frontend/src/pages/BatchDetail.vue b/frontend/src/pages/BatchDetail.vue index 9483a288..78cde922 100644 --- a/frontend/src/pages/BatchDetail.vue +++ b/frontend/src/pages/BatchDetail.vue @@ -17,17 +17,10 @@ {{ batch.data?.courses?.length }} {{ __('Courses') }}
· -
- - - {{ - getFormattedDateRange( - batch.data.start_date, - batch.data.end_date - ) - }} - -
+ ·
@@ -87,10 +80,11 @@ import { computed, inject } from 'vue' import { useRouter } from 'vue-router' import { BookOpen, Calendar, Clock } from 'lucide-vue-next' -import { formatTime, getFormattedDateRange } from '@/utils' +import { formatTime } from '@/utils' import { Breadcrumbs, createResource } from 'frappe-ui' import CourseCard from '@/components/CourseCard.vue' import BatchOverlay from '@/components/BatchOverlay.vue' +import DateRange from '../components/Common/DateRange.vue' const user = inject('$user') const router = useRouter() From 5b120ad2487aead9e226470725d104b8ab10921c Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Tue, 16 Apr 2024 22:02:56 +0530 Subject: [PATCH 3/3] refactor: take format as optional argument --- frontend/src/utils/index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index 5b5b33cd..8d328dd9 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -324,11 +324,15 @@ export function getSidebarLinks() { ] } -export function getFormattedDateRange(startDate, endDate) { +export function getFormattedDateRange( + startDate, + endDate, + format = 'DD MMM YYYY' +) { if (startDate === endDate) { - return dayjs(startDate).format('DD MMM YYYY') + return dayjs(startDate).format(format) } - return `${dayjs(startDate).format('DD MMM YYYY')} - ${dayjs(endDate).format( - 'DD MMM YYYY' + return `${dayjs(startDate).format(format)} - ${dayjs(endDate).format( + format )}` }