feat: allow same date live class creation
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -5,6 +5,8 @@ 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)
|
||||
@@ -12,5 +14,7 @@ dayjs.extend(localizedFormat)
|
||||
dayjs.extend(isToday)
|
||||
dayjs.extend(isSameOrBefore)
|
||||
dayjs.extend(isSameOrAfter)
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
export default dayjs
|
||||
|
||||
Reference in New Issue
Block a user