feat: add toast notifications for delete actions and update button titles in advertisements page
This commit is contained in:
@@ -5,7 +5,8 @@ import {
|
||||
DialogPanel,
|
||||
DialogTitle,
|
||||
} from '@headlessui/react'
|
||||
import type { Dispatch, SetStateAction } from 'react'
|
||||
import { useEffect, type Dispatch, type SetStateAction } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import { Link, useFetcher } from 'react-router'
|
||||
|
||||
import type { TAdResponse } from '~/apis/common/get-ads'
|
||||
@@ -20,6 +21,20 @@ export const DialogDelete = (properties: TProperties) => {
|
||||
const { selectedAds, setSelectedAds } = properties || {}
|
||||
const fetcher = useFetcher()
|
||||
|
||||
useEffect(() => {
|
||||
if (fetcher.data?.success === false) {
|
||||
toast.error(fetcher.data?.message)
|
||||
return
|
||||
}
|
||||
|
||||
if (fetcher.data?.success === true) {
|
||||
setSelectedAds(undefined)
|
||||
toast.success('Banner iklan berhasil dihapus!')
|
||||
return
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [fetcher.data])
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={!!selectedAds}
|
||||
|
||||
Reference in New Issue
Block a user