import { PencilSquareIcon, PlusIcon, TrashIcon, } from '@heroicons/react/24/solid' import DT, { type ConfigColumns } from 'datatables.net-dt' import DataTable, { type DataTableSlots } from 'datatables.net-react' import { useState } from 'react' import { Link, useRouteLoaderData } from 'react-router' import type { TSubscribePlanResponse } from '~/apis/common/get-subscribe-plan' import { DialogDelete } from '~/components/dialog/delete' import { Button } from '~/components/ui/button' import { getStatusBadge, type TColorBadge } from '~/components/ui/color-badge' import { UiTable } from '~/components/ui/table' import { TitleDashboard } from '~/components/ui/title-dashboard' import type { loader } from '~/routes/_admin.lg-admin._dashboard.subscribe-plan._index' import { formatNumberWithPeriods } from '~/utils/formatter' export const SubscribePlanPage = () => { const loaderData = useRouteLoaderData( 'routes/_admin.lg-admin._dashboard.subscribe-plan._index', ) const [selectedSubscribePlan, setSelectedSubscribePlan] = useState() DataTable.use(DT) const { subscribePlanData: dataTable } = loaderData || {} const dataColumns: ConfigColumns[] = [ { title: 'No', render: ( _data: unknown, _type: unknown, _row: unknown, meta: { row: number }, ) => { return meta.row + 1 }, }, { title: 'Nama', data: 'name', }, { title: 'Kode', data: 'code', }, { title: 'Durasi', data: 'length', }, { title: 'Harga', data: 'price', className: 'dt-type-numeric', }, { title: 'Status', data: 'status', }, { title: 'Tindakan', data: 'id', }, ] const dataSlot: DataTableSlots = { 4: (value: number) => `Rp. ${formatNumberWithPeriods(value)}`, 5: (value: number) => ( {value === 1 ? 'Active' : 'Inactive'} ), 6: (value: string, _type: unknown, data: TSubscribePlanResponse) => data.code === 'basic' ? ( '' ) : (
), } return (
{/* TODO: Filter */}
setSelectedSubscribePlan(undefined)} title="Paket Berlangganan" fetcherAction={`/actions/admin/subscribe-plan/delete/${selectedSubscribePlan?.id}`} >

{selectedSubscribePlan?.name}

Length: {selectedSubscribePlan?.length}

Harga: Rp.{' '} {formatNumberWithPeriods(selectedSubscribePlan?.price || 0)}

) }