import React from 'react' import { cookies } from 'next/headers' import { headers } from 'next/headers' interface Route { id: string from_city_name: string to_city_name: string formatted_departure: string formatted_arrival: string formatted_cargo_type: string formatted_transport: string comment?: string owner_type: string } async function getRoutes() { const cookieStore = await cookies() const headersList = await headers() const protocol = headersList.get('x-forwarded-proto') || 'http' const host = headersList.get('host') || 'localhost:3000' const response = await fetch(`${protocol}://${host}/api/account/routes`, { method: 'GET', headers: { 'Content-Type': 'application/json', Cookie: cookieStore.toString(), }, }) if (!response.ok) { const error = await response.json() console.error('Error fetching routes:', error) throw new Error(error.message || 'Failed to fetch routes') } return response.json() } export default async function UserRoutes() { let routes: Route[] = [] try { routes = (await getRoutes()) || [] } catch (error) { console.error('Component error:', error) return (
У вас пока нет завершенных маршрутов
Создавайте или принимайте заявки на перевозку, чтобы они отобразились тут