21 lines
731 B
TypeScript
21 lines
731 B
TypeScript
import { getNewsBySlug } from '~/apis/common/get-news-by-slug'
|
|
import { handleCookie } from '~/libs/cookies'
|
|
import { FormContentsPage } from '~/pages/form-contents'
|
|
|
|
import type { Route } from './+types/_admin.lg-admin._dashboard.contents.update.$slug'
|
|
|
|
export const loader = async ({ request, params }: Route.LoaderArgs) => {
|
|
const { staffToken } = await handleCookie(request)
|
|
const { data: newsData } = await getNewsBySlug({
|
|
accessToken: staffToken,
|
|
slug: params.slug,
|
|
})
|
|
return { newsData }
|
|
}
|
|
|
|
const DashboardContentUpdateLayout = ({ loaderData }: Route.ComponentProps) => {
|
|
const { newsData } = loaderData || {}
|
|
return <FormContentsPage newsData={newsData} />
|
|
}
|
|
export default DashboardContentUpdateLayout
|