import { isRouteErrorResponse } from 'react-router' 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' export const loader = async ({ params }: Route.LoaderArgs) => { const { data: categoriesData } = await getCategories() const { id } = params const categoryData = categoriesData.find((category) => category.id === id) return { categoryData } } export const ErrorBoundary = ({ error }: Route.ErrorBoundaryProps) => { let message = 'Oops!' let details = 'An unexpected error occurred.' let stack: string | undefined if (isRouteErrorResponse(error)) { message = error.status === 404 ? '404' : 'Error' details = error.status === 404 ? 'The requested page could not be found.' : error.statusText || details } else if (import.meta.env.DEV && error && error instanceof Error) { details = error.message stack = error.stack } return (

{message}

{details}

{stack && (
          {stack}
        
)}
) } const DashboardCategoriesUpdateLayout = ({ loaderData, }: Route.ComponentProps) => { const { categoryData } = loaderData || {} return } export default DashboardCategoriesUpdateLayout