feat: sort categories by sequence and update category description handling in news pages
This commit is contained in:
parent
40a3553f9d
commit
87156e93ee
@ -7,7 +7,11 @@ import { HeaderSearch } from './header-search'
|
||||
|
||||
export const HeaderMenu = () => {
|
||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||
const menu = loaderData?.categoriesData
|
||||
const menu = loaderData?.categoriesData?.sort((a, b) => {
|
||||
if (a.sequence === null) return 1
|
||||
if (b.sequence === null) return -1
|
||||
return a.sequence - b.sequence
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
import { useLocation, useRouteLoaderData } from 'react-router'
|
||||
import { useParams, useRouteLoaderData } from 'react-router'
|
||||
|
||||
import { Card } from '~/components/ui/card'
|
||||
import { CategorySection } from '~/components/ui/category-section'
|
||||
import { DUMMY_DESCRIPTION } from '~/data/contents'
|
||||
import type { loader } from '~/routes/_news'
|
||||
|
||||
import { BERITA } from './data'
|
||||
|
||||
export const NewsCategoriesPage = () => {
|
||||
const { pathname } = useLocation()
|
||||
const code = pathname.split('/')[2]
|
||||
const parameters = useParams()
|
||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||
const { name } =
|
||||
loaderData?.categoriesData.find((item) => item.code === code) || {}
|
||||
const { name, description } =
|
||||
loaderData?.categoriesData.find((item) => item.code === parameters.code) ||
|
||||
{}
|
||||
const { items } = BERITA
|
||||
|
||||
return (
|
||||
@ -20,7 +19,7 @@ export const NewsCategoriesPage = () => {
|
||||
<Card>
|
||||
<CategorySection
|
||||
title={name || ''}
|
||||
description={DUMMY_DESCRIPTION}
|
||||
description={description || ''}
|
||||
items={items}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user