feat: add API endpoints for fetching staff profiles and staff list

This commit is contained in:
Ardeman
2025-03-25 19:07:29 +08:00
parent dce745f53d
commit 84451f1fd4
8 changed files with 82 additions and 72 deletions
+43 -60
View File
@@ -1,67 +1,50 @@
import { PlusIcon } from '@heroicons/react/24/solid'
import { Link } from 'react-router'
import DT, { type ConfigColumns } from 'datatables.net-dt'
import DataTable, { type DataTableSlots } from 'datatables.net-react'
import { Link, useRouteLoaderData } from 'react-router'
import type { TStaffResponse } from '~/apis/admin/get-staffs'
import { Button } from '~/components/ui/button'
import { UiTable } from '~/components/ui/table'
import { TitleDashboard } from '~/components/ui/title-dashboard'
import type { loader } from '~/routes/_admin.lg-admin._dashboard.staffs._index'
export const StaffsPage = () => {
// const loaderData = useRouteLoaderData<typeof loader>(
// 'routes/_admin.lg-admin._dashboard.staffs._index',
// )
const loaderData = useRouteLoaderData<typeof loader>(
'routes/_admin.lg-admin._dashboard.staffs._index',
)
// DataTable.use(DT)
// const dataTable =
// loaderData?.usersData?.sort(
// (a, b) =>
// new Date(b.subscribe.start_date).getTime() -
// new Date(a.subscribe.start_date).getTime(),
// ) || []
DataTable.use(DT)
const { staffsData: dataTable } = loaderData || {}
// const dataColumns: ConfigColumns[] = [
// {
// title: 'No',
// render: (
// _data: unknown,
// _type: unknown,
// _row: unknown,
// meta: { row: number },
// ) => {
// return meta.row + 1
// },
// },
// {
// title: 'Tanggal Daftar',
// data: 'created_at',
// },
// {
// title: 'User',
// },
// {
// title: 'Phone',
// data: 'phone',
// },
// {
// title: 'Status',
// data: 'subscribe.subscribe_plan.name',
// },
// ]
// const dataSlot: DataTableSlots = {
// 1: (value: string) => formatDate(value),
// 2: (_value: unknown, _type: unknown, data: TUserResponse) => (
// <div>
// <div>{data.email}</div>
// <div className="text-sm text-[#7C7C7C]">ID: {data.id.slice(0, 8)}</div>
// </div>
// ),
// 3: (value: string) => <span>{value}</span>,
// 4: (value: TColorBadge, _type: unknown, data: TUserResponse) => (
// <span
// className={`rounded-lg px-2 text-sm ${getStatusBadge(data.subscribe.status as TColorBadge)}`}
// >
// {value}
// </span>
// ),
// }
const dataColumns: ConfigColumns[] = [
{
title: 'No',
render: (
_data: unknown,
_type: unknown,
_row: unknown,
meta: { row: number },
) => {
return meta.row + 1
},
},
{
title: 'Staf',
},
{
title: 'Email',
data: 'email',
},
]
const dataSlot: DataTableSlots = {
1: (_value: unknown, _type: unknown, data: TStaffResponse) => (
<div>
<div>{data.name}</div>
<div className="text-sm text-[#7C7C7C]">ID: {data.id.slice(0, 8)}</div>
</div>
),
}
return (
<div className="relative">
@@ -78,12 +61,12 @@ export const StaffsPage = () => {
</Button>
</div>
{/* <UiTable
data={dataTable || []}
<UiTable
data={dataTable}
columns={dataColumns}
slots={dataSlot}
title="Daftar Users"
/> */}
title="Daftar Staf"
/>
</div>
)
}