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
+18 -3
View File
@@ -1,21 +1,36 @@
import { useRouteLoaderData } from 'react-router'
import { Card } from '~/components/ui/card'
import { CarouselHero } from '~/components/ui/carousel-hero'
import { CarouselSection } from '~/components/ui/carousel-section'
import { Newsletter } from '~/components/ui/newsletter'
import { BERITA, SPOTLIGHT } from '~/data/contents'
import type { loader } from '~/routes/_news._index'
import type { TNews } from '~/types/news'
export const NewsPage = () => {
const loaderData = useRouteLoaderData<typeof loader>('routes/_news._index')
const spotlight: TNews = {
title: loaderData?.spotlightCategory?.name || '',
description: loaderData?.spotlightCategory?.description || '',
items: loaderData?.spotlightNews || [],
}
const berita: TNews = {
title: loaderData?.beritaCategory?.name || '',
description: loaderData?.beritaCategory?.description || '',
items: loaderData?.beritaNews || [],
}
return (
<div className="relative">
<Card>
<CarouselHero {...SPOTLIGHT} />
<CarouselHero {...spotlight} />
</Card>
<div className="min-h-[400px] sm:min-h-[300px]">
<Newsletter className="mr-0 sm:-ml-14" />
</div>
<Card>
<CarouselSection {...BERITA} />
<CarouselSection {...berita} />
</Card>
{/* <Card>
<CarouselSection {...KAJIAN} />