2025-03-09 09:49:06 +08:00
|
|
|
import { useRouteLoaderData } from 'react-router'
|
2025-03-02 12:37:19 +08:00
|
|
|
|
2025-02-20 22:20:27 +07:00
|
|
|
import { Card } from '~/components/ui/card'
|
2025-03-01 15:44:23 +07:00
|
|
|
import { CategorySection } from '~/components/ui/category-section'
|
2025-03-09 09:49:06 +08:00
|
|
|
import type { loader } from '~/routes/_news.category.$code'
|
2025-02-20 22:20:27 +07:00
|
|
|
|
|
|
|
|
export const NewsCategoriesPage = () => {
|
2025-03-09 09:49:06 +08:00
|
|
|
const loaderData = useRouteLoaderData<typeof loader>(
|
|
|
|
|
'routes/_news.category.$code',
|
|
|
|
|
)
|
2025-03-09 11:36:47 +08:00
|
|
|
const { categoryData, newsData } = loaderData || {}
|
|
|
|
|
const { name, description } = categoryData || {}
|
2025-03-02 12:37:19 +08:00
|
|
|
|
2025-02-20 22:20:27 +07:00
|
|
|
return (
|
2025-02-28 18:59:27 +07:00
|
|
|
<div className="relative">
|
2025-02-20 22:20:27 +07:00
|
|
|
<Card>
|
2025-03-02 12:37:19 +08:00
|
|
|
<CategorySection
|
|
|
|
|
title={name || ''}
|
2025-03-08 02:14:36 +08:00
|
|
|
description={description || ''}
|
2025-03-20 12:10:38 +08:00
|
|
|
items={newsData || Promise.resolve({ data: [] })}
|
2025-03-02 12:37:19 +08:00
|
|
|
/>
|
2025-02-20 22:20:27 +07:00
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|