Skip to content

Commit

Permalink
feat: allow same date live class creation
Browse files Browse the repository at this point in the history
  • Loading branch information
iamejaaz committed Nov 10, 2024
1 parent c5f091f commit e25f161
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 15 additions & 6 deletions frontend/src/components/Modals/LiveClassModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,30 @@ const submitLiveClass = (close) => {
if (!liveClass.date) {
return 'Please select a date.'
}
if (dayjs(liveClass.date).isSameOrBefore(dayjs(), 'day')) {
return 'Please select a future date.'
}
if (!liveClass.time) {
return 'Please select a time.'
}
if (!liveClass.timezone) {
return 'Please select a timezone.'
}
if (!valideTime()) {
return 'Please enter a valid time in the format HH:mm.'
}
const liveClassDateTime = dayjs(`${liveClass.date}T${liveClass.time}`).tz(
liveClass.timezone,
true
)
if (
liveClassDateTime.isSameOrBefore(
dayjs().tz(liveClass.timezone, false),
'minute'
)
) {
return 'Please select a future date and time.'
}
if (!liveClass.duration) {
return 'Please select a duration.'
}
if (!liveClass.timezone) {
return 'Please select a timezone.'
}
},
onSuccess() {
liveClasses.value.reload()
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/utils/dayjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import updateLocale from 'dayjs/esm/plugin/updateLocale'
import isToday from 'dayjs/esm/plugin/isToday'
import isSameOrBefore from 'dayjs/esm/plugin/isSameOrBefore'
import isSameOrAfter from 'dayjs/esm/plugin/isSameOrAfter'
import utc from 'dayjs/esm/plugin/utc'
import timezone from 'dayjs/esm/plugin/timezone'

dayjs.extend(updateLocale)
dayjs.extend(relativeTime)
dayjs.extend(localizedFormat)
dayjs.extend(isToday)
dayjs.extend(isSameOrBefore)
dayjs.extend(isSameOrAfter)
dayjs.extend(utc)
dayjs.extend(timezone)

export default dayjs

0 comments on commit e25f161

Please sign in to comment.