2025-03-07 13:50:16 +08:00
|
|
|
import { getNewsBySlug } from '~/apis/common/get-news-by-slug'
|
|
|
|
|
import { handleCookie } from '~/libs/cookies'
|
2025-03-07 12:42:45 +08:00
|
|
|
import { ContentsFormPage } from '~/pages/contents-form'
|
2025-03-07 12:11:48 +08:00
|
|
|
|
2025-03-07 13:50:16 +08:00
|
|
|
import type { Route } from './+types/_admin.lg-admin._dashboard.contents.update.$slug'
|
|
|
|
|
|
|
|
|
|
export const loader = async ({ request }: Route.LoaderArgs) => {
|
|
|
|
|
const { staffToken } = await handleCookie(request)
|
|
|
|
|
const { data: newsData } = await getNewsBySlug({
|
|
|
|
|
accessToken: staffToken,
|
|
|
|
|
slug: request.url.split('/').pop() ?? '',
|
|
|
|
|
})
|
|
|
|
|
return { newsData }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DashboardContentUpdateLayout = ({ loaderData }: Route.ComponentProps) => {
|
|
|
|
|
const newsData = loaderData.newsData
|
|
|
|
|
return <ContentsFormPage newsData={newsData} />
|
|
|
|
|
}
|
2025-03-07 12:11:48 +08:00
|
|
|
export default DashboardContentUpdateLayout
|