refactor: update subscription data loading and clean up unused imports in dashboard components
This commit is contained in:
parent
5b83c3f8dd
commit
a9a350fdb2
@ -5,24 +5,22 @@ import { Link, useRouteLoaderData } from 'react-router'
|
|||||||
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.subscribe-plan._index'
|
||||||
|
|
||||||
export const SubscribePlanPage = () => {
|
export const SubscribePlanPage = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>(
|
const loaderData = useRouteLoaderData<typeof loader>(
|
||||||
'routes/_admin.lg-admin._dashboard',
|
'routes/_admin.lg-admin._dashboard.subscribe-plan._index',
|
||||||
)
|
)
|
||||||
|
|
||||||
DataTable.use(DT)
|
DataTable.use(DT)
|
||||||
|
|
||||||
const { subscriptionsData: dataTable } = loaderData || {}
|
const { subscriptionsData: dataTable } = loaderData || {}
|
||||||
|
|
||||||
const dataColumns = [
|
const dataColumns = [
|
||||||
{
|
{
|
||||||
title: 'No',
|
title: 'No',
|
||||||
render: (
|
render: (
|
||||||
data: unknown,
|
_data: unknown,
|
||||||
type: unknown,
|
_type: unknown,
|
||||||
row: unknown,
|
_row: unknown,
|
||||||
meta: { row: number },
|
meta: { row: number },
|
||||||
) => {
|
) => {
|
||||||
return meta.row + 1
|
return meta.row + 1
|
||||||
@ -41,7 +39,6 @@ export const SubscribePlanPage = () => {
|
|||||||
data: 'id',
|
data: 'id',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const dataSlot = {
|
const dataSlot = {
|
||||||
3: (value: string) => (
|
3: (value: string) => (
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import DT from 'datatables.net-dt'
|
|||||||
import DataTable from 'datatables.net-react'
|
import DataTable from 'datatables.net-react'
|
||||||
|
|
||||||
import { SearchIcon } from '~/components/icons/search'
|
import { SearchIcon } from '~/components/icons/search'
|
||||||
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'
|
||||||
|
|
||||||
@ -61,15 +60,6 @@ export const SubscriptionsPage = () => {
|
|||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button
|
|
||||||
as="a"
|
|
||||||
className="rounded-md"
|
|
||||||
size="lg"
|
|
||||||
href="#"
|
|
||||||
>
|
|
||||||
Subscription Settings
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UiTable
|
<UiTable
|
||||||
|
|||||||
@ -1,4 +1,11 @@
|
|||||||
|
import { getSubscriptions } from '~/apis/common/get-subscriptions'
|
||||||
import { SubscribePlanPage } from '~/pages/dashboard-plan-subscribe'
|
import { SubscribePlanPage } from '~/pages/dashboard-plan-subscribe'
|
||||||
|
|
||||||
|
import type { Route } from './+types/_admin.lg-admin._dashboard.contents._index'
|
||||||
|
|
||||||
|
export const loader = async ({}: Route.LoaderArgs) => {
|
||||||
|
const { data: subscriptionsData } = await getSubscriptions()
|
||||||
|
return { subscriptionsData }
|
||||||
|
}
|
||||||
const DashboardSubscriptionsSettingsLayout = () => <SubscribePlanPage />
|
const DashboardSubscriptionsSettingsLayout = () => <SubscribePlanPage />
|
||||||
export default DashboardSubscriptionsSettingsLayout
|
export default DashboardSubscriptionsSettingsLayout
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { Outlet } from 'react-router'
|
import { Outlet } from 'react-router'
|
||||||
|
|
||||||
import { getCategories } from '~/apis/common/get-categories'
|
import { getCategories } from '~/apis/common/get-categories'
|
||||||
import { getSubscriptions } from '~/apis/common/get-subscriptions'
|
|
||||||
import { getTags } from '~/apis/common/get-tags'
|
import { getTags } from '~/apis/common/get-tags'
|
||||||
import { AdminDashboardLayout } from '~/layouts/admin/dashboard'
|
import { AdminDashboardLayout } from '~/layouts/admin/dashboard'
|
||||||
|
|
||||||
@ -10,12 +9,10 @@ import type { Route } from './+types/_admin.lg-admin._dashboard'
|
|||||||
export const loader = async ({}: Route.LoaderArgs) => {
|
export const loader = async ({}: Route.LoaderArgs) => {
|
||||||
const { data: categoriesData } = await getCategories()
|
const { data: categoriesData } = await getCategories()
|
||||||
const { data: tagsData } = await getTags()
|
const { data: tagsData } = await getTags()
|
||||||
const { data: subscriptionsData } = await getSubscriptions()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
categoriesData,
|
categoriesData,
|
||||||
tagsData,
|
tagsData,
|
||||||
subscriptionsData,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user