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