feat: integrate news data fetching by slug and update ContentsFormPage to utilize fetched data
This commit is contained in:
@@ -1,4 +1,20 @@
|
||||
import { getNewsBySlug } from '~/apis/common/get-news-by-slug'
|
||||
import { handleCookie } from '~/libs/cookies'
|
||||
import { ContentsFormPage } from '~/pages/contents-form'
|
||||
|
||||
const DashboardContentUpdateLayout = () => <ContentsFormPage />
|
||||
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} />
|
||||
}
|
||||
export default DashboardContentUpdateLayout
|
||||
|
||||
Reference in New Issue
Block a user