mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: Add loading toasts
This commit is contained in:
parent
0f2b8689c4
commit
c68fa66ff8
7 changed files with 34 additions and 4 deletions
|
|
@ -234,7 +234,9 @@ const DeleteUpdateButton = ({ update }: any) => {
|
|||
|
||||
const handleDelete = async () => {
|
||||
const res = await deleteCourseUpdate(course.courseStructure.course_uuid, update.courseupdate_uuid, session.data?.tokens?.access_token)
|
||||
const toast_loading = toast.loading('Deleting update...')
|
||||
if (res.status === 200) {
|
||||
toast.dismiss(toast_loading)
|
||||
toast.success('Update deleted successfully')
|
||||
mutate(`${getAPIUrl()}courses/${course?.courseStructure.course_uuid}/updates`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,10 @@ function NewAssignment({ submitActivity, chapterId, course, closeModal }: any) {
|
|||
chapter_id: chapterId,
|
||||
activity_id: activity_res?.id,
|
||||
}, session.data?.tokens?.access_token)
|
||||
const toast_loading = toast.loading('Creating assignment...')
|
||||
|
||||
if (res.success) {
|
||||
toast.dismiss(toast_loading)
|
||||
toast.success('Assignment created successfully')
|
||||
} else {
|
||||
toast.error(res.data.detail)
|
||||
|
|
|
|||
|
|
@ -76,9 +76,11 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
|
|||
thumbnail,
|
||||
session.data?.tokens?.access_token
|
||||
)
|
||||
const toast_loading = toast.loading('Creating course...')
|
||||
if (res.success) {
|
||||
await revalidateTags(['courses'], orgslug)
|
||||
setIsSubmitting(false)
|
||||
toast.dismiss(toast_loading)
|
||||
toast.success('Course created successfully')
|
||||
|
||||
if (res.data.org_id == orgId) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { useLHSession } from '@components/Contexts/LHSessionContext'
|
|||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import React, { useEffect } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
|
||||
type PropsType = {
|
||||
course: any
|
||||
|
|
@ -28,7 +29,10 @@ function CourseThumbnail(props: PropsType) {
|
|||
const session = useLHSession() as any;
|
||||
|
||||
async function deleteCourses(course_uuid: any) {
|
||||
const toast_loading = toast.loading('Deleting course...')
|
||||
await deleteCourseFromBackend(course_uuid, session.data?.tokens?.access_token)
|
||||
toast.dismiss(toast_loading)
|
||||
toast.success('Course deleted successfully')
|
||||
await revalidateTags(['courses'], props.orgslug)
|
||||
|
||||
router.refresh()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue