2025-03-08 01:32:25 +08:00
|
|
|
import { getCategories } from '~/apis/common/get-categories'
|
|
|
|
|
import { FormCategoryPage } from '~/pages/form-category'
|
|
|
|
|
|
|
|
|
|
import type { Route } from './+types/_admin.lg-admin._dashboard.categories.update.$id'
|
|
|
|
|
|
2025-03-09 09:32:51 +08:00
|
|
|
export const loader = async ({ params }: Route.LoaderArgs) => {
|
|
|
|
|
const { data: categoriesData } = await getCategories()
|
2025-03-08 01:32:25 +08:00
|
|
|
const categoryData = categoriesData.find(
|
|
|
|
|
(category) => category.id === params.id,
|
|
|
|
|
)
|
|
|
|
|
return { categoryData }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DashboardCategoriesUpdateLayout = ({
|
|
|
|
|
loaderData,
|
|
|
|
|
}: Route.ComponentProps) => {
|
2025-03-09 09:32:51 +08:00
|
|
|
const { categoryData } = loaderData || {}
|
2025-03-08 01:32:25 +08:00
|
|
|
return <FormCategoryPage categoryData={categoryData} />
|
|
|
|
|
}
|
|
|
|
|
export default DashboardCategoriesUpdateLayout
|