fix / await promise before use

This commit is contained in:
2025-05-27 10:11:19 +03:00
parent 24d277c499
commit 46cd984395
2 changed files with 20 additions and 23 deletions

View File

@@ -1,14 +1,7 @@
import React, { Suspense } from 'react'
import type { Metadata } from 'next'
import SearchCard from '../../components/SearchCard'
import { SearchCardProps } from '@/app/types'
interface SearchPageProps {
params: {
category: string
route: string
}
}
import { SearchCardProps, RouteSearchPageProps } from '@/app/types'
async function fetchSearch(category: string, from: string, to: string) {
const response = await fetch(
@@ -32,17 +25,17 @@ async function fetchSearch(category: string, from: string, to: string) {
export async function generateMetadata({
params,
}: {
params: SearchPageProps['params']
params: RouteSearchPageProps['params']
}): Promise<Metadata> {
const [fromCity, toCity] = params.route.split('-')
const [fromCity, toCity] = (await params).route.split('-')
return {
title: `Поиск ${params.category === 'mover' ? 'перевозчика' : 'посылки'} ${fromCity}${toCity} | Tripwb`,
description: `Найдите ${params.category === 'mover' ? 'перевозчика' : 'посылку'} по маршруту ${fromCity}${toCity} | Tripwb`,
title: `Поиск ${(await params).category === 'mover' ? 'перевозчика' : 'посылки'} ${fromCity}${toCity} | Tripwb`,
description: `Найдите ${(await params).category === 'mover' ? 'перевозчика' : 'посылку'} по маршруту ${fromCity}${toCity} | Tripwb`,
openGraph: {
title: `Поиск ${params.category === 'mover' ? 'перевозчика' : 'посылки'} ${fromCity}${toCity} | Tripwb`,
description: `Найдите ${params.category === 'mover' ? 'перевозчика' : 'посылку'} по маршруту ${fromCity}${toCity}`,
url: `https://tripwb.com/search/${params.category}/${params.route}`,
title: `Поиск ${(await params).category === 'mover' ? 'перевозчика' : 'посылки'} ${fromCity}${toCity} | Tripwb`,
description: `Найдите ${(await params).category === 'mover' ? 'перевозчика' : 'посылку'} по маршруту ${fromCity}${toCity}`,
url: `https://tripwb.com/search/${(await params).category}/${(await params).route}`,
siteName: 'TripWB',
images: [
{
@@ -56,7 +49,7 @@ export async function generateMetadata({
type: 'website',
},
alternates: {
canonical: `https://tripwb.com/search/${params.category}/${params.route}`,
canonical: `https://tripwb.com/search/${(await params).category}/${(await params).route}`,
},
robots: {
index: true,
@@ -65,7 +58,7 @@ export async function generateMetadata({
}
}
export default async function SearchPage(props: SearchPageProps) {
export default async function SearchPage(props: RouteSearchPageProps) {
const params = await props.params
const { category, route } = params
const [fromCity, toCity] = route.split('-')
@@ -75,13 +68,10 @@ export default async function SearchPage(props: SearchPageProps) {
return (
<div className="container mx-auto p-4">
<h1 className="mb-4 text-2xl font-bold">
{category === 'mover' ? 'Поиск перевозчика' : 'Поиск посылки'}
{category === 'mover'
? `Поиск перевозчика по маршруту : ${fromCity}${toCity}`
: `Поиск посылки по маршруту : ${fromCity}${toCity}`}
</h1>
<div className="mb-4">
<p>
Маршрут: {fromCity} {toCity}
</p>
</div>
<Suspense fallback={<div>Загрузка результатов...</div>}>
<div className="space-y-4">

View File

@@ -260,3 +260,10 @@ export interface LeadPageProps extends Lead {
owner_name: string
owner_email: string
}
export interface RouteSearchPageProps {
params: Promise<{
category: string
route: string
}>
}