import { Description, Dialog, DialogBackdrop, DialogPanel, DialogTitle, } from '@headlessui/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' import { Button } from '~/components/ui/button' type TProperties = { selectedItem?: TAdResponse setSelectedItem: Dispatch> } export const DialogDelete = (properties: TProperties) => { const { selectedItem, setSelectedItem } = properties || {} const fetcher = useFetcher() useEffect(() => { if (fetcher.data?.success === false) { toast.error(fetcher.data?.message) return } if (fetcher.data?.success === true) { setSelectedItem(undefined) toast.success('Banner iklan berhasil dihapus!') return } // eslint-disable-next-line react-hooks/exhaustive-deps }, [fetcher.data]) return ( { if (fetcher.state === 'idle') { setSelectedItem(undefined) } }} className="relative z-50" transition >
Anda akan menghapus banner berikut? {selectedItem?.image_url}
) }