refactor: update news types and enhance news data handling in components

This commit is contained in:
Ardeman
2025-03-09 12:32:36 +08:00
parent 9f82779456
commit 7afabdaa03
8 changed files with 101 additions and 148 deletions
+10
View File
@@ -1,3 +1,5 @@
import { getCategories } from '~/apis/common/get-categories'
import { getNews } from '~/apis/common/get-news'
import { getNewsBySlug } from '~/apis/common/get-news-by-slug'
import { APP } from '~/configs/meta'
import { handleCookie } from '~/libs/cookies'
@@ -11,9 +13,17 @@ export const loader = async ({ request, params }: Route.LoaderArgs) => {
slug: params.slug,
accessToken: userToken,
})
const { data: categoriesData } = await getCategories()
const beritaCode = 'berita'
const beritaCategory = categoriesData.find(
(category) => category.code === beritaCode,
)
const { data: beritaNews } = await getNews({ categories: [beritaCode] })
return {
newsDetailData,
beritaCategory,
beritaNews,
}
}