feat: allow same date live class creation
This commit is contained in:
@@ -161,21 +161,30 @@ const submitLiveClass = (close) => {
|
|||||||
if (!liveClass.date) {
|
if (!liveClass.date) {
|
||||||
return 'Please select a date.'
|
return 'Please select a date.'
|
||||||
}
|
}
|
||||||
if (dayjs(liveClass.date).isSameOrBefore(dayjs(), 'day')) {
|
|
||||||
return 'Please select a future date.'
|
|
||||||
}
|
|
||||||
if (!liveClass.time) {
|
if (!liveClass.time) {
|
||||||
return 'Please select a time.'
|
return 'Please select a time.'
|
||||||
}
|
}
|
||||||
|
if (!liveClass.timezone) {
|
||||||
|
return 'Please select a timezone.'
|
||||||
|
}
|
||||||
if (!valideTime()) {
|
if (!valideTime()) {
|
||||||
return 'Please enter a valid time in the format HH:mm.'
|
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) {
|
if (!liveClass.duration) {
|
||||||
return 'Please select a duration.'
|
return 'Please select a duration.'
|
||||||
}
|
}
|
||||||
if (!liveClass.timezone) {
|
|
||||||
return 'Please select a timezone.'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
liveClasses.value.reload()
|
liveClasses.value.reload()
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import updateLocale from 'dayjs/esm/plugin/updateLocale'
|
|||||||
import isToday from 'dayjs/esm/plugin/isToday'
|
import isToday from 'dayjs/esm/plugin/isToday'
|
||||||
import isSameOrBefore from 'dayjs/esm/plugin/isSameOrBefore'
|
import isSameOrBefore from 'dayjs/esm/plugin/isSameOrBefore'
|
||||||
import isSameOrAfter from 'dayjs/esm/plugin/isSameOrAfter'
|
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(updateLocale)
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
@@ -12,5 +14,7 @@ dayjs.extend(localizedFormat)
|
|||||||
dayjs.extend(isToday)
|
dayjs.extend(isToday)
|
||||||
dayjs.extend(isSameOrBefore)
|
dayjs.extend(isSameOrBefore)
|
||||||
dayjs.extend(isSameOrAfter)
|
dayjs.extend(isSameOrAfter)
|
||||||
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
|
||||||
export default dayjs
|
export default dayjs
|
||||||
|
|||||||
Reference in New Issue
Block a user