dynamic routes for main page

This commit is contained in:
2025-05-23 11:48:45 +03:00
parent efccb591ff
commit 45e5e78df2
10 changed files with 234 additions and 141 deletions

View File

@@ -3,16 +3,17 @@ import Image from 'next/image'
import AddressSelector from '@/components/AddressSelector'
import SearchCard from '@/app/(urls)/search/components/SearchCard'
import FAQ from '@/components/FAQ'
import { data } from '@/app/constants'
import { routes } from '@/app/constants'
import Button from '@/components/ui/Button'
import News from '@/components/News'
import { getFAQs } from '@/lib/main/fetchFAQ'
import { getNews } from '@/lib/main/fetchNews'
import { getFirstRoutes } from '@/lib/main/fetchFirstRoutes'
export default async function Home() {
const faqs = await getFAQs()
const news = await getNews()
const latestRoutes = await getFirstRoutes()
return (
<div className="mx-auto flex max-w-[93%] flex-col items-center justify-center">
@@ -69,9 +70,11 @@ export default async function Home() {
{/* первые пять серч карточек -- бекенд??? */}
<div className="mx-auto w-full max-w-[1250px]">
<div className="grid w-full grid-cols-1 gap-4">
{data.map(card => (
<SearchCard key={card.id} {...card} />
))}
{Array.isArray(latestRoutes) && latestRoutes.length > 0 ? (
latestRoutes.map(card => <SearchCard key={card.id} {...card} />)
) : (
<div className="py-4 text-center text-gray-600">Нет доступных маршрутов</div>
)}
</div>
<div className="flex justify-center py-4">
<Button