diff --git a/app/pages/dashboard-categories/index.tsx b/app/pages/dashboard-categories/index.tsx index 0028062..c45e645 100644 --- a/app/pages/dashboard-categories/index.tsx +++ b/app/pages/dashboard-categories/index.tsx @@ -6,15 +6,12 @@ import type { TCategoryResponse } from '~/apis/common/get-categories' 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.categories._index' +import type { loader } from '~/routes/_admin.lg-admin' export const CategoriesPage = () => { - const loaderData = useRouteLoaderData( - 'routes/_admin.lg-admin._dashboard.categories._index', - ) - const { dataCategories: categoriesData } = loaderData || {} + const loaderData = useRouteLoaderData('routes/_admin.lg-admin') DataTable.use(DT) - const dataTable = categoriesData?.sort((a, b) => { + const dataTable = loaderData?.categoriesData?.sort((a, b) => { if (a.sequence === null) return 1 if (b.sequence === null) return -1 return a.sequence - b.sequence diff --git a/app/pages/dashboard-contents/index.tsx b/app/pages/dashboard-contents/index.tsx index b046eb6..61ed5a7 100644 --- a/app/pages/dashboard-contents/index.tsx +++ b/app/pages/dashboard-contents/index.tsx @@ -15,10 +15,9 @@ export const ContentsPage = () => { const loaderData = useRouteLoaderData( 'routes/_admin.lg-admin._dashboard.contents._index', ) - const { newsData } = loaderData || {} DataTable.use(DT) - const dataTable = newsData?.sort( + const dataTable = loaderData?.newsData?.sort( (a, b) => new Date(b.live_at).getTime() - new Date(a.live_at).getTime(), ) const dataColumns = [ diff --git a/app/routes/_admin.lg-admin._dashboard.categories._index.tsx b/app/routes/_admin.lg-admin._dashboard.categories._index.tsx index 0a82712..b4514e7 100644 --- a/app/routes/_admin.lg-admin._dashboard.categories._index.tsx +++ b/app/routes/_admin.lg-admin._dashboard.categories._index.tsx @@ -1,16 +1,4 @@ -import { getCategories } from '~/apis/common/get-categories' -import { handleCookie } from '~/libs/cookies' import { CategoriesPage } from '~/pages/dashboard-categories' -import type { Route } from './+types/_admin.lg-admin._dashboard.categories._index' - -export const loader = async ({ request }: Route.LoaderArgs) => { - const { staffToken } = await handleCookie(request) - const { data: dataCategories } = await getCategories({ - accessToken: staffToken, - }) - return { dataCategories } -} - const DashboardCategoriesIndexLayout = () => export default DashboardCategoriesIndexLayout