feat: add TColorBadge type and getStatusBadge function for status color management
This commit is contained in:
parent
8a19529230
commit
2c90d32a10
23
app/components/ui/color-badge.tsx
Normal file
23
app/components/ui/color-badge.tsx
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export type TColorBadge =
|
||||||
|
| 'baru'
|
||||||
|
| 'premium'
|
||||||
|
| 'pembayaran'
|
||||||
|
| 'active'
|
||||||
|
| 'inactive'
|
||||||
|
| 'expired'
|
||||||
|
| 1
|
||||||
|
| 0
|
||||||
|
|
||||||
|
export const getStatusBadge = (status: TColorBadge) => {
|
||||||
|
const statusColors = {
|
||||||
|
baru: 'bg-[#DFE5FF] text-[#4C5CA0]',
|
||||||
|
premium: 'bg-[#FFFCAF] text-[#DBCA6E]',
|
||||||
|
pembayaran: 'bg-[#FEC4FF] text-[#CC6EDB]',
|
||||||
|
active: 'bg-[#D1FAE5] text-[#10B981]',
|
||||||
|
inactive: 'bg-[#FEE2E2] text-[#EF4444]',
|
||||||
|
expired: 'bg-[#FEC4FF] text-[#CC6EDB]',
|
||||||
|
1: 'bg-[#DFE5FF] text-[#4C5CA0]',
|
||||||
|
0: 'bg-[#FEE2E2] text-[#EF4444]',
|
||||||
|
}
|
||||||
|
return statusColors[status] || 'bg-gray-200 text-gray-700'
|
||||||
|
}
|
||||||
@ -3,9 +3,11 @@ import DataTable from 'datatables.net-react'
|
|||||||
import { Link, useRouteLoaderData } from 'react-router'
|
import { Link, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
|
import { getStatusBadge, type TColorBadge } from '~/components/ui/color-badge'
|
||||||
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.subscribe-plan._index'
|
import type { loader } from '~/routes/_admin.lg-admin._dashboard.subscribe-plan._index'
|
||||||
|
import { formatNumberWithPeriods } from '~/utils/formatter'
|
||||||
|
|
||||||
export const SubscribePlanPage = () => {
|
export const SubscribePlanPage = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>(
|
const loaderData = useRouteLoaderData<typeof loader>(
|
||||||
@ -14,6 +16,7 @@ export const SubscribePlanPage = () => {
|
|||||||
|
|
||||||
DataTable.use(DT)
|
DataTable.use(DT)
|
||||||
const { subscriptionsData: dataTable } = loaderData || {}
|
const { subscriptionsData: dataTable } = loaderData || {}
|
||||||
|
|
||||||
const dataColumns = [
|
const dataColumns = [
|
||||||
{
|
{
|
||||||
title: 'No',
|
title: 'No',
|
||||||
@ -34,13 +37,35 @@ export const SubscribePlanPage = () => {
|
|||||||
title: 'Kode',
|
title: 'Kode',
|
||||||
data: 'code',
|
data: 'code',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Length',
|
||||||
|
data: 'length',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Price',
|
||||||
|
data: 'price',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Status',
|
||||||
|
data: 'status',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Action',
|
title: 'Action',
|
||||||
data: 'id',
|
data: 'id',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const dataSlot = {
|
const dataSlot = {
|
||||||
3: (value: string) => (
|
4: (value: number) => (
|
||||||
|
<div className="text-right">Rp. {formatNumberWithPeriods(value)}</div>
|
||||||
|
),
|
||||||
|
5: (value: number) => (
|
||||||
|
<span
|
||||||
|
className={`rounded-lg px-2 text-sm ${getStatusBadge(value as TColorBadge)}`}
|
||||||
|
>
|
||||||
|
{value === 1 ? 'Active' : 'Inactive'}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
6: (value: string) => (
|
||||||
<Button
|
<Button
|
||||||
as="a"
|
as="a"
|
||||||
href={`/lg-admin/subscribe-plan/update/${value}`}
|
href={`/lg-admin/subscribe-plan/update/${value}`}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user