refactor: update button styles and improve delete dialog properties in dashboard pages
This commit is contained in:
@@ -13,12 +13,12 @@ import type { TAdResponse } from '~/apis/common/get-ads'
|
||||
import { Button } from '~/components/ui/button'
|
||||
|
||||
type TProperties = {
|
||||
selectedAds?: TAdResponse
|
||||
setSelectedAds: Dispatch<SetStateAction<TAdResponse | undefined>>
|
||||
selectedItem?: TAdResponse
|
||||
setSelectedItem: Dispatch<SetStateAction<TAdResponse | undefined>>
|
||||
}
|
||||
|
||||
export const DialogDelete = (properties: TProperties) => {
|
||||
const { selectedAds, setSelectedAds } = properties || {}
|
||||
const { selectedItem, setSelectedItem } = properties || {}
|
||||
const fetcher = useFetcher()
|
||||
|
||||
useEffect(() => {
|
||||
@@ -28,7 +28,7 @@ export const DialogDelete = (properties: TProperties) => {
|
||||
}
|
||||
|
||||
if (fetcher.data?.success === true) {
|
||||
setSelectedAds(undefined)
|
||||
setSelectedItem(undefined)
|
||||
toast.success('Banner iklan berhasil dihapus!')
|
||||
return
|
||||
}
|
||||
@@ -37,10 +37,10 @@ export const DialogDelete = (properties: TProperties) => {
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={!!selectedAds}
|
||||
open={!!selectedItem}
|
||||
onClose={() => {
|
||||
if (fetcher.state === 'idle') {
|
||||
setSelectedAds(undefined)
|
||||
setSelectedItem(undefined)
|
||||
}
|
||||
}}
|
||||
className="relative z-50"
|
||||
@@ -60,23 +60,23 @@ export const DialogDelete = (properties: TProperties) => {
|
||||
</DialogTitle>
|
||||
<Description className="space-y-1 text-center text-[#565658]">
|
||||
<img
|
||||
src={selectedAds?.image_url}
|
||||
alt={selectedAds?.image_url}
|
||||
src={selectedItem?.image_url}
|
||||
alt={selectedItem?.image_url}
|
||||
className="aspect-[150/1] h-[50px] rounded object-contain"
|
||||
/>
|
||||
<Button
|
||||
as={Link}
|
||||
to={selectedAds?.url || ''}
|
||||
to={selectedItem?.url || ''}
|
||||
variant="link"
|
||||
size="fit"
|
||||
>
|
||||
{selectedAds?.url}
|
||||
{selectedItem?.url}
|
||||
</Button>
|
||||
</Description>
|
||||
<div className="flex justify-end">
|
||||
<fetcher.Form
|
||||
method="POST"
|
||||
action={`/actions/admin/advertisements/delete/${selectedAds?.id}`}
|
||||
action={`/actions/admin/advertisements/delete/${selectedItem?.id}`}
|
||||
className="grid"
|
||||
>
|
||||
<Button
|
||||
|
||||
@@ -57,7 +57,6 @@ export const AdvertisementsPage = () => {
|
||||
<Button
|
||||
as="a"
|
||||
href={`/lg-admin/advertisements/update/${value}`}
|
||||
className=""
|
||||
size="icon"
|
||||
title="Update Banner Iklan"
|
||||
>
|
||||
@@ -86,6 +85,7 @@ export const AdvertisementsPage = () => {
|
||||
as={Link}
|
||||
to="/lg-admin/advertisements/create"
|
||||
size="lg"
|
||||
className="text-md h-[42px] px-4"
|
||||
>
|
||||
<PlusIcon className="h-8 w-8" /> Buat Banner Iklan
|
||||
</Button>
|
||||
@@ -99,8 +99,8 @@ export const AdvertisementsPage = () => {
|
||||
/>
|
||||
|
||||
<DialogDelete
|
||||
selectedAds={selectedAds}
|
||||
setSelectedAds={setSelectedAds}
|
||||
selectedItem={selectedAds}
|
||||
setSelectedItem={setSelectedAds}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user