feat: implement unified delete dialog component and update related pages
This commit is contained in:
parent
2c703de8e5
commit
b00adf89ec
@ -5,20 +5,31 @@ import {
|
|||||||
DialogPanel,
|
DialogPanel,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@headlessui/react'
|
} from '@headlessui/react'
|
||||||
import { useEffect, type Dispatch, type SetStateAction } from 'react'
|
import {
|
||||||
|
useEffect,
|
||||||
|
type Dispatch,
|
||||||
|
type PropsWithChildren,
|
||||||
|
type SetStateAction,
|
||||||
|
} from 'react'
|
||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
import { useFetcher } from 'react-router'
|
import { useFetcher } from 'react-router'
|
||||||
|
|
||||||
import type { TTagResponse } from '~/apis/common/get-tags'
|
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
|
|
||||||
type TProperties = {
|
type T = {
|
||||||
selectedItem?: TTagResponse
|
id: string
|
||||||
setSelectedItem: Dispatch<SetStateAction<TTagResponse | undefined>>
|
} & any // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
|
|
||||||
|
type TProperties = PropsWithChildren & {
|
||||||
|
selectedItem?: T
|
||||||
|
setSelectedItem: Dispatch<SetStateAction<T | undefined>>
|
||||||
|
title: string
|
||||||
|
fetcherAction: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DialogDelete = (properties: TProperties) => {
|
export const DialogDelete = (properties: TProperties) => {
|
||||||
const { selectedItem, setSelectedItem } = properties || {}
|
const { selectedItem, setSelectedItem, children, title, fetcherAction } =
|
||||||
|
properties || {}
|
||||||
const fetcher = useFetcher()
|
const fetcher = useFetcher()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -29,7 +40,7 @@ export const DialogDelete = (properties: TProperties) => {
|
|||||||
|
|
||||||
if (fetcher.data?.success === true) {
|
if (fetcher.data?.success === true) {
|
||||||
setSelectedItem(undefined)
|
setSelectedItem(undefined)
|
||||||
toast.success('Tag berhasil dihapus!')
|
toast.success(`${title} berhasil dihapus!`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@ -55,16 +66,17 @@ export const DialogDelete = (properties: TProperties) => {
|
|||||||
transition
|
transition
|
||||||
className="max-w-lg space-y-6 rounded-lg bg-white p-8 duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0 sm:shadow-lg"
|
className="max-w-lg space-y-6 rounded-lg bg-white p-8 duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0 sm:shadow-lg"
|
||||||
>
|
>
|
||||||
<DialogTitle className="relative flex justify-start text-xl font-bold">
|
<DialogTitle className="relative text-xl font-bold">
|
||||||
Anda akan menghapus tag berikut?
|
<span>Anda akan menghapus</span>{' '}
|
||||||
|
<span className="lowercase">{title}</span> <span>berikut?</span>
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<Description className="space-y-1 text-center text-[#565658]">
|
<Description className="space-y-1 text-center text-[#565658]">
|
||||||
<p>{selectedItem?.name}</p>
|
{children}
|
||||||
</Description>
|
</Description>
|
||||||
<div className="flex justify-end">
|
<div className="flex justify-end">
|
||||||
<fetcher.Form
|
<fetcher.Form
|
||||||
method="POST"
|
method="POST"
|
||||||
action={`/actions/admin/tags/delete/${selectedItem?.id}`}
|
action={fetcherAction}
|
||||||
className="grid"
|
className="grid"
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
@ -17,7 +17,7 @@ type ModalProperties = {
|
|||||||
description?: string
|
description?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PopupModal = ({
|
export const DialogNews = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
children,
|
children,
|
||||||
@ -33,7 +33,7 @@ const DESCRIPTIONS: DescriptionMap = {
|
|||||||
error: 'Terjadi kesalahan. Silakan coba lagi.',
|
error: 'Terjadi kesalahan. Silakan coba lagi.',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SuccessModal = ({ isOpen, onClose }: ModalProperties) => {
|
export const DialogSuccess = ({ isOpen, onClose }: ModalProperties) => {
|
||||||
const { setIsLoginOpen, setIsSubscribeOpen } = useNewsContext()
|
const { setIsLoginOpen, setIsSubscribeOpen } = useNewsContext()
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||||
const { userData } = loaderData || {}
|
const { userData } = loaderData || {}
|
||||||
@ -7,7 +7,7 @@ import {
|
|||||||
type SetStateAction,
|
type SetStateAction,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
|
|
||||||
import type { ModalProperties } from '~/components/popup/success-modal'
|
import type { ModalProperties } from '~/components/dialog/success'
|
||||||
|
|
||||||
type NewsContextProperties = {
|
type NewsContextProperties = {
|
||||||
isLoginOpen: boolean
|
isLoginOpen: boolean
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import { type PropsWithChildren } from 'react'
|
import { type PropsWithChildren } from 'react'
|
||||||
import { Toaster } from 'react-hot-toast'
|
import { Toaster } from 'react-hot-toast'
|
||||||
|
|
||||||
import { PopupModal } from '~/components/popup/modal'
|
import { DialogNews } from '~/components/dialog/news'
|
||||||
import { SuccessModal } from '~/components/popup/success-modal'
|
import { DialogSuccess } from '~/components/dialog/success'
|
||||||
import { useNewsContext } from '~/contexts/news'
|
import { useNewsContext } from '~/contexts/news'
|
||||||
import { Banner } from '~/layouts/news/banner'
|
import { Banner } from '~/layouts/news/banner'
|
||||||
import { FormForgotPassword } from '~/layouts/news/form-forgot-password'
|
import { FormForgotPassword } from '~/layouts/news/form-forgot-password'
|
||||||
@ -47,39 +47,39 @@ export const NewsDefaultLayout = (properties: PropsWithChildren) => {
|
|||||||
|
|
||||||
<Toaster />
|
<Toaster />
|
||||||
|
|
||||||
<PopupModal
|
<DialogNews
|
||||||
isOpen={isLoginOpen}
|
isOpen={isLoginOpen}
|
||||||
onClose={() => setIsLoginOpen(false)}
|
onClose={() => setIsLoginOpen(false)}
|
||||||
description="Selamat Datang, silakan daftarkan akun Anda untuk melanjutkan!"
|
description="Selamat Datang, silakan daftarkan akun Anda untuk melanjutkan!"
|
||||||
>
|
>
|
||||||
<FormLogin />
|
<FormLogin />
|
||||||
</PopupModal>
|
</DialogNews>
|
||||||
|
|
||||||
<PopupModal
|
<DialogNews
|
||||||
isOpen={isRegisterOpen}
|
isOpen={isRegisterOpen}
|
||||||
onClose={() => setIsRegisterOpen(false)}
|
onClose={() => setIsRegisterOpen(false)}
|
||||||
description="Selamat Datang, silakan isi keterangan akun Anda untuk melanjutkan!"
|
description="Selamat Datang, silakan isi keterangan akun Anda untuk melanjutkan!"
|
||||||
>
|
>
|
||||||
<FormRegister />
|
<FormRegister />
|
||||||
</PopupModal>
|
</DialogNews>
|
||||||
|
|
||||||
<PopupModal
|
<DialogNews
|
||||||
isOpen={isForgetOpen}
|
isOpen={isForgetOpen}
|
||||||
onClose={() => setIsForgetOpen(false)}
|
onClose={() => setIsForgetOpen(false)}
|
||||||
description="Selamat Datang, silakan isi keterangan akun Anda untuk melanjutkan!"
|
description="Selamat Datang, silakan isi keterangan akun Anda untuk melanjutkan!"
|
||||||
>
|
>
|
||||||
<FormForgotPassword />
|
<FormForgotPassword />
|
||||||
</PopupModal>
|
</DialogNews>
|
||||||
|
|
||||||
<PopupModal
|
<DialogNews
|
||||||
isOpen={isSubscribeOpen}
|
isOpen={isSubscribeOpen}
|
||||||
onClose={() => setIsSubscribeOpen(false)}
|
onClose={() => setIsSubscribeOpen(false)}
|
||||||
description="Selamat Datang, silakan Pilih Subscribe Plan Anda untuk melanjutkan!"
|
description="Selamat Datang, silakan Pilih Subscribe Plan Anda untuk melanjutkan!"
|
||||||
>
|
>
|
||||||
<FormSubscribePlan />
|
<FormSubscribePlan />
|
||||||
</PopupModal>
|
</DialogNews>
|
||||||
|
|
||||||
<SuccessModal
|
<DialogSuccess
|
||||||
isOpen={isSuccessOpen}
|
isOpen={isSuccessOpen}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setIsSuccessOpen(undefined)
|
setIsSuccessOpen(undefined)
|
||||||
|
|||||||
@ -1,97 +0,0 @@
|
|||||||
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<SetStateAction<TAdResponse | undefined>>
|
|
||||||
}
|
|
||||||
|
|
||||||
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 (
|
|
||||||
<Dialog
|
|
||||||
open={!!selectedItem}
|
|
||||||
onClose={() => {
|
|
||||||
if (fetcher.state === 'idle') {
|
|
||||||
setSelectedItem(undefined)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="relative z-50"
|
|
||||||
transition
|
|
||||||
>
|
|
||||||
<DialogBackdrop
|
|
||||||
className="fixed inset-0 bg-black/50 duration-300 ease-out data-[closed]:opacity-0"
|
|
||||||
transition
|
|
||||||
/>
|
|
||||||
<div className="fixed inset-0 flex w-screen justify-center overflow-y-auto p-0 max-sm:bg-white sm:items-center sm:p-4">
|
|
||||||
<DialogPanel
|
|
||||||
transition
|
|
||||||
className="max-w-lg space-y-6 rounded-lg bg-white p-8 duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0 sm:shadow-lg"
|
|
||||||
>
|
|
||||||
<DialogTitle className="relative flex justify-start text-xl font-bold">
|
|
||||||
Anda akan menghapus banner berikut?
|
|
||||||
</DialogTitle>
|
|
||||||
<Description className="space-y-1 text-center text-[#565658]">
|
|
||||||
<img
|
|
||||||
src={selectedItem?.image_url}
|
|
||||||
alt={selectedItem?.image_url}
|
|
||||||
className="aspect-[150/1] h-[50px] rounded object-contain"
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
as={Link}
|
|
||||||
to={selectedItem?.url || ''}
|
|
||||||
variant="link"
|
|
||||||
size="fit"
|
|
||||||
>
|
|
||||||
{selectedItem?.url}
|
|
||||||
</Button>
|
|
||||||
</Description>
|
|
||||||
<div className="flex justify-end">
|
|
||||||
<fetcher.Form
|
|
||||||
method="POST"
|
|
||||||
action={`/actions/admin/advertisements/delete/${selectedItem?.id}`}
|
|
||||||
className="grid"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
variant="newsDanger"
|
|
||||||
className="text-md h-[42px] rounded-md"
|
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
isLoading={fetcher.state !== 'idle'}
|
|
||||||
>
|
|
||||||
Hapus
|
|
||||||
</Button>
|
|
||||||
</fetcher.Form>
|
|
||||||
</div>
|
|
||||||
</DialogPanel>
|
|
||||||
</div>
|
|
||||||
</Dialog>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@ -9,13 +9,12 @@ import { useState } from 'react'
|
|||||||
import { Link, useRouteLoaderData } from 'react-router'
|
import { Link, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
import type { TAdResponse } from '~/apis/common/get-ads'
|
import type { TAdResponse } from '~/apis/common/get-ads'
|
||||||
|
import { DialogDelete } from '~/components/dialog/delete'
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
import { UiTable } from '~/components/ui/table'
|
import { UiTable } from '~/components/ui/table'
|
||||||
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
||||||
import type { loader } from '~/routes/_admin.lg-admin._dashboard.advertisements._index'
|
import type { loader } from '~/routes/_admin.lg-admin._dashboard.advertisements._index'
|
||||||
|
|
||||||
import { DialogDelete } from './dialog-delete'
|
|
||||||
|
|
||||||
export const AdvertisementsPage = () => {
|
export const AdvertisementsPage = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>(
|
const loaderData = useRouteLoaderData<typeof loader>(
|
||||||
'routes/_admin.lg-admin._dashboard.advertisements._index',
|
'routes/_admin.lg-admin._dashboard.advertisements._index',
|
||||||
@ -101,7 +100,23 @@ export const AdvertisementsPage = () => {
|
|||||||
<DialogDelete
|
<DialogDelete
|
||||||
selectedItem={selectedAds}
|
selectedItem={selectedAds}
|
||||||
setSelectedItem={setSelectedAds}
|
setSelectedItem={setSelectedAds}
|
||||||
/>
|
title="Banner iklan"
|
||||||
|
fetcherAction={`/actions/admin/advertisements/delete/${selectedAds?.id}`}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={selectedAds?.image_url}
|
||||||
|
alt={selectedAds?.image_url}
|
||||||
|
className="aspect-[150/1] h-[50px] rounded object-contain"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
as={Link}
|
||||||
|
to={selectedAds?.url || ''}
|
||||||
|
variant="link"
|
||||||
|
size="fit"
|
||||||
|
>
|
||||||
|
{selectedAds?.url}
|
||||||
|
</Button>
|
||||||
|
</DialogDelete>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,90 +0,0 @@
|
|||||||
import {
|
|
||||||
Description,
|
|
||||||
Dialog,
|
|
||||||
DialogBackdrop,
|
|
||||||
DialogPanel,
|
|
||||||
DialogTitle,
|
|
||||||
} from '@headlessui/react'
|
|
||||||
import { useEffect, type Dispatch, type SetStateAction } from 'react'
|
|
||||||
import toast from 'react-hot-toast'
|
|
||||||
import { useFetcher } from 'react-router'
|
|
||||||
|
|
||||||
import type { TSubscribePlanResponse } from '~/apis/common/get-subscribe-plan'
|
|
||||||
import { Button } from '~/components/ui/button'
|
|
||||||
import { formatNumberWithPeriods } from '~/utils/formatter'
|
|
||||||
|
|
||||||
type TProperties = {
|
|
||||||
selectedItem?: TSubscribePlanResponse
|
|
||||||
setSelectedItem: Dispatch<SetStateAction<TSubscribePlanResponse | undefined>>
|
|
||||||
}
|
|
||||||
|
|
||||||
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('Subscribe plan berhasil dihapus!')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [fetcher.data])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog
|
|
||||||
open={!!selectedItem}
|
|
||||||
onClose={() => {
|
|
||||||
if (fetcher.state === 'idle') {
|
|
||||||
setSelectedItem(undefined)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="relative z-50"
|
|
||||||
transition
|
|
||||||
>
|
|
||||||
<DialogBackdrop
|
|
||||||
className="fixed inset-0 bg-black/50 duration-300 ease-out data-[closed]:opacity-0"
|
|
||||||
transition
|
|
||||||
/>
|
|
||||||
<div className="fixed inset-0 flex w-screen justify-center overflow-y-auto p-0 max-sm:bg-white sm:items-center sm:p-4">
|
|
||||||
<DialogPanel
|
|
||||||
transition
|
|
||||||
className="max-w-lg space-y-6 rounded-lg bg-white p-8 duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0 sm:shadow-lg"
|
|
||||||
>
|
|
||||||
<DialogTitle className="relative flex justify-start text-xl font-bold">
|
|
||||||
Anda akan menghapus subscribe plan berikut?
|
|
||||||
</DialogTitle>
|
|
||||||
<Description className="space-y-1 text-center text-[#565658]">
|
|
||||||
<p>{selectedItem?.name}</p>
|
|
||||||
<p>Length: {selectedItem?.length}</p>
|
|
||||||
<p>
|
|
||||||
Harga: Rp. {formatNumberWithPeriods(selectedItem?.price || 0)}
|
|
||||||
</p>
|
|
||||||
</Description>
|
|
||||||
<div className="flex justify-end">
|
|
||||||
<fetcher.Form
|
|
||||||
method="POST"
|
|
||||||
action={`/actions/admin/subscribe-plan/delete/${selectedItem?.id}`}
|
|
||||||
className="grid"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
variant="newsDanger"
|
|
||||||
className="text-md h-[42px] rounded-md"
|
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
isLoading={fetcher.state !== 'idle'}
|
|
||||||
>
|
|
||||||
Hapus
|
|
||||||
</Button>
|
|
||||||
</fetcher.Form>
|
|
||||||
</div>
|
|
||||||
</DialogPanel>
|
|
||||||
</div>
|
|
||||||
</Dialog>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@ -9,6 +9,7 @@ import { useState } from 'react'
|
|||||||
import { Link, useRouteLoaderData } from 'react-router'
|
import { Link, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
import type { TSubscribePlanResponse } from '~/apis/common/get-subscribe-plan'
|
import type { TSubscribePlanResponse } from '~/apis/common/get-subscribe-plan'
|
||||||
|
import { DialogDelete } from '~/components/dialog/delete'
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
import { getStatusBadge, type TColorBadge } from '~/components/ui/color-badge'
|
import { getStatusBadge, type TColorBadge } from '~/components/ui/color-badge'
|
||||||
import { UiTable } from '~/components/ui/table'
|
import { UiTable } from '~/components/ui/table'
|
||||||
@ -16,8 +17,6 @@ import { TitleDashboard } from '~/components/ui/title-dashboard'
|
|||||||
import type { loader } from '~/routes/_admin.lg-admin._dashboard.subscribe-plan._index'
|
import type { loader } from '~/routes/_admin.lg-admin._dashboard.subscribe-plan._index'
|
||||||
import { formatNumberWithPeriods } from '~/utils/formatter'
|
import { formatNumberWithPeriods } from '~/utils/formatter'
|
||||||
|
|
||||||
import { DialogDelete } from './dialog-delete'
|
|
||||||
|
|
||||||
export const SubscribePlanPage = () => {
|
export const SubscribePlanPage = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>(
|
const loaderData = useRouteLoaderData<typeof loader>(
|
||||||
'routes/_admin.lg-admin._dashboard.subscribe-plan._index',
|
'routes/_admin.lg-admin._dashboard.subscribe-plan._index',
|
||||||
@ -132,7 +131,16 @@ export const SubscribePlanPage = () => {
|
|||||||
<DialogDelete
|
<DialogDelete
|
||||||
selectedItem={selectedSubscribePlan}
|
selectedItem={selectedSubscribePlan}
|
||||||
setSelectedItem={setSelectedSubscribePlan}
|
setSelectedItem={setSelectedSubscribePlan}
|
||||||
/>
|
title="Subscribe plan"
|
||||||
|
fetcherAction={`/actions/admin/subscribe-plan/delete/${selectedSubscribePlan?.id}`}
|
||||||
|
>
|
||||||
|
<p>{selectedSubscribePlan?.name}</p>
|
||||||
|
<p>Length: {selectedSubscribePlan?.length}</p>
|
||||||
|
<p>
|
||||||
|
Harga: Rp.{' '}
|
||||||
|
{formatNumberWithPeriods(selectedSubscribePlan?.price || 0)}
|
||||||
|
</p>
|
||||||
|
</DialogDelete>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,13 +9,12 @@ import { useState } from 'react'
|
|||||||
import { Link, useRouteLoaderData } from 'react-router'
|
import { Link, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
import type { TTagResponse } from '~/apis/common/get-tags'
|
import type { TTagResponse } from '~/apis/common/get-tags'
|
||||||
|
import { DialogDelete } from '~/components/dialog/delete'
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
import { UiTable } from '~/components/ui/table'
|
import { UiTable } from '~/components/ui/table'
|
||||||
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
||||||
import type { loader } from '~/routes/_admin.lg-admin._dashboard'
|
import type { loader } from '~/routes/_admin.lg-admin._dashboard'
|
||||||
|
|
||||||
import { DialogDelete } from './dialog-delete'
|
|
||||||
|
|
||||||
export const TagsPage = () => {
|
export const TagsPage = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>(
|
const loaderData = useRouteLoaderData<typeof loader>(
|
||||||
'routes/_admin.lg-admin._dashboard',
|
'routes/_admin.lg-admin._dashboard',
|
||||||
@ -105,7 +104,11 @@ export const TagsPage = () => {
|
|||||||
<DialogDelete
|
<DialogDelete
|
||||||
selectedItem={selectedTag}
|
selectedItem={selectedTag}
|
||||||
setSelectedItem={setSelectedTag}
|
setSelectedItem={setSelectedTag}
|
||||||
/>
|
title="Tag"
|
||||||
|
fetcherAction={`/actions/admin/tags/delete/${selectedTag?.id}`}
|
||||||
|
>
|
||||||
|
<p>{selectedTag?.name}</p>
|
||||||
|
</DialogDelete>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user