feat: lesson creation

This commit is contained in:
Jannat Patel
2024-03-05 23:07:58 +05:30
parent b9f6a23412
commit 0ce7c74778
11 changed files with 409 additions and 155 deletions

View File

@@ -321,6 +321,7 @@ const courseCreationResource = createResource({
})
const submitCourse = () => {
console.log(courseResource.doc?.modified)
if (courseResource.doc) {
courseResource.setValue.submit(
{
@@ -331,8 +332,11 @@ const submitCourse = () => {
validate() {
return validateMandatoryFields()
},
onSuccess() {
showToast('Success', 'Course updated successfully', 'check')
},
onError(err) {
showToast(err)
showToast('Error', err.messages?.[0] || err, 'x')
},
}
)
@@ -341,6 +345,9 @@ const submitCourse = () => {
validate() {
return validateMandatoryFields()
},
onSuccess() {
showToast('Success', 'Course created successfully', 'check')
},
onError(err) {
showToast(err)
},
@@ -392,14 +399,17 @@ const removeTag = (tag) => {
newTag.value = ''
}
const showToast = (err) => {
const showToast = (title, text, icon) => {
createToast({
title: 'Error',
text: err.messages?.[0] || err,
icon: 'x',
iconClasses: 'bg-red-600 text-white rounded-md p-px',
position: 'top-center',
timeout: 10,
title: title,
text: text,
icon: icon,
iconClasses:
icon == 'check'
? 'bg-green-600 text-white rounded-md p-px'
: 'bg-red-600 text-white rounded-md p-px',
position: icon == 'check' ? 'bottom-right' : 'top-center',
timeout: icon == 'check' ? 5 : 10,
})
}