fix: handle same start and end dates case for batch
* also minor refactor
This commit is contained in:
@@ -34,8 +34,7 @@
|
|||||||
<div class="flex items-center mb-3">
|
<div class="flex items-center mb-3">
|
||||||
<Calendar class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
<Calendar class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
||||||
<span>
|
<span>
|
||||||
{{ dayjs(batch.start_date).format('DD MMM YYYY') }} -
|
{{ getFormattedDateRange(batch.start_date, batch.end_date) }}
|
||||||
{{ dayjs(batch.end_date).format('DD MMM YYYY') }}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
@@ -48,12 +47,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Calendar, Clock, BookOpen } from 'lucide-vue-next'
|
|
||||||
import { inject } from 'vue'
|
|
||||||
import { Badge } from 'frappe-ui'
|
import { Badge } from 'frappe-ui'
|
||||||
import { formatTime } from '../utils'
|
import { Calendar, Clock, BookOpen } from 'lucide-vue-next'
|
||||||
|
import { formatTime, getFormattedDateRange } from '../utils'
|
||||||
|
|
||||||
const dayjs = inject('$dayjs')
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
batch: {
|
batch: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|||||||
@@ -24,8 +24,7 @@
|
|||||||
<div class="flex items-center mb-3">
|
<div class="flex items-center mb-3">
|
||||||
<Calendar class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
<Calendar class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
||||||
<span>
|
<span>
|
||||||
{{ dayjs(batch.data.start_date).format('DD MMM YYYY') }} -
|
{{ getFormattedDateRange(batch.data.start_date, batch.data.end_date) }}
|
||||||
{{ dayjs(batch.data.end_date).format('DD MMM YYYY') }}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
@@ -91,12 +90,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { formatNumberIntoCurrency, formatTime } from '@/utils'
|
|
||||||
import { BookOpen, Calendar, Clock } from 'lucide-vue-next'
|
|
||||||
import { inject, computed } from 'vue'
|
import { inject, computed } from 'vue'
|
||||||
import { Badge, Button } from 'frappe-ui'
|
import { Badge, Button } from 'frappe-ui'
|
||||||
|
import { BookOpen, Calendar, Clock } from 'lucide-vue-next'
|
||||||
|
import {
|
||||||
|
formatNumberIntoCurrency,
|
||||||
|
formatTime,
|
||||||
|
getFormattedDateRange,
|
||||||
|
} from '@/utils'
|
||||||
|
|
||||||
const dayjs = inject('$dayjs')
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|||||||
@@ -83,8 +83,9 @@
|
|||||||
<div class="flex items-center mb-3">
|
<div class="flex items-center mb-3">
|
||||||
<Calendar class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
<Calendar class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
||||||
<span>
|
<span>
|
||||||
{{ dayjs(batch.data.start_date).format('DD MMMM YYYY') }} -
|
{{
|
||||||
{{ dayjs(batch.data.end_date).format('DD MMMM YYYY') }}
|
getFormattedDateRange(batch.data.start_date, batch.data.end_date)
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center mb-6">
|
<div class="flex items-center mb-6">
|
||||||
@@ -161,7 +162,7 @@ import {
|
|||||||
SendIcon,
|
SendIcon,
|
||||||
MessageCircle,
|
MessageCircle,
|
||||||
} from 'lucide-vue-next'
|
} from 'lucide-vue-next'
|
||||||
import { formatTime } from '@/utils'
|
import { formatTime, getFormattedDateRange } from '@/utils'
|
||||||
import BatchDashboard from '@/components/BatchDashboard.vue'
|
import BatchDashboard from '@/components/BatchDashboard.vue'
|
||||||
import BatchCourses from '@/components/BatchCourses.vue'
|
import BatchCourses from '@/components/BatchCourses.vue'
|
||||||
import LiveClass from '@/components/LiveClass.vue'
|
import LiveClass from '@/components/LiveClass.vue'
|
||||||
@@ -171,7 +172,6 @@ import Announcements from '@/components/Annoucements.vue'
|
|||||||
import AnnouncementModal from '@/components/Modals/AnnouncementModal.vue'
|
import AnnouncementModal from '@/components/Modals/AnnouncementModal.vue'
|
||||||
import Discussions from '@/components/Discussions.vue'
|
import Discussions from '@/components/Discussions.vue'
|
||||||
|
|
||||||
const dayjs = inject('$dayjs')
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
const showAnnouncementModal = ref(false)
|
const showAnnouncementModal = ref(false)
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,12 @@
|
|||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<Calendar class="h-4 w-4 text-gray-700 mr-2" />
|
<Calendar class="h-4 w-4 text-gray-700 mr-2" />
|
||||||
<span>
|
<span>
|
||||||
{{ dayjs(batch.data.start_date).format('DD MMM YYYY') }} -
|
{{
|
||||||
{{ dayjs(batch.data.end_date).format('DD MMM YYYY') }}
|
getFormattedDateRange(
|
||||||
|
batch.data.start_date,
|
||||||
|
batch.data.end_date
|
||||||
|
)
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-if="batch.data.start_date">·</span>
|
<span v-if="batch.data.start_date">·</span>
|
||||||
@@ -80,15 +84,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Breadcrumbs, createResource, Button } from 'frappe-ui'
|
import { computed, inject } from 'vue'
|
||||||
import { BookOpen, Calendar, Clock } from 'lucide-vue-next'
|
|
||||||
import { formatTime } from '../utils'
|
|
||||||
import { computed, inject, ref } from 'vue'
|
|
||||||
import BatchOverlay from '@/components/BatchOverlay.vue'
|
|
||||||
import CourseCard from '@/components/CourseCard.vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import { BookOpen, Calendar, Clock } from 'lucide-vue-next'
|
||||||
|
import { formatTime, getFormattedDateRange } from '@/utils'
|
||||||
|
import { Breadcrumbs, createResource } from 'frappe-ui'
|
||||||
|
import CourseCard from '@/components/CourseCard.vue'
|
||||||
|
import BatchOverlay from '@/components/BatchOverlay.vue'
|
||||||
|
|
||||||
const dayjs = inject('$dayjs')
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Paragraph from '@editorjs/paragraph'
|
|||||||
import Embed from '@editorjs/embed'
|
import Embed from '@editorjs/embed'
|
||||||
import NestedList from '@editorjs/nested-list'
|
import NestedList from '@editorjs/nested-list'
|
||||||
import { watch } from 'vue'
|
import { watch } from 'vue'
|
||||||
|
import dayjs from '@/utils/dayjs'
|
||||||
|
|
||||||
export function createToast(options) {
|
export function createToast(options) {
|
||||||
toast({
|
toast({
|
||||||
@@ -322,3 +323,12 @@ export function getSidebarLinks() {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getFormattedDateRange(startDate, endDate) {
|
||||||
|
if (startDate === endDate) {
|
||||||
|
return dayjs(startDate).format('DD MMM YYYY')
|
||||||
|
}
|
||||||
|
return `${dayjs(startDate).format('DD MMM YYYY')} - ${dayjs(endDate).format(
|
||||||
|
'DD MMM YYYY'
|
||||||
|
)}`
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user