wip
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useState, useEffect, use } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { useRouter, useParams } from 'next/navigation';
|
||||
import { getDriverRepository } from '@/lib/di-container';
|
||||
@@ -14,7 +14,7 @@ import type { DriverDTO } from '@gridpilot/racing/application/dto/DriverDTO';
|
||||
export default function DriverDetailPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams?: { [key: string]: string | string[] | undefined };
|
||||
searchParams: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const params = useParams();
|
||||
@@ -24,14 +24,36 @@ export default function DriverDetailPage({
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const unwrappedSearchParams = use(searchParams) as URLSearchParams | undefined;
|
||||
|
||||
const from =
|
||||
typeof searchParams?.from === 'string' ? searchParams.from : undefined;
|
||||
const leagueId =
|
||||
typeof searchParams?.leagueId === 'string'
|
||||
? searchParams.leagueId
|
||||
typeof unwrappedSearchParams?.get === 'function'
|
||||
? unwrappedSearchParams.get('from') ?? undefined
|
||||
: undefined;
|
||||
const backLink =
|
||||
from === 'league' && leagueId ? `/leagues/${leagueId}` : null;
|
||||
|
||||
const leagueId =
|
||||
typeof unwrappedSearchParams?.get === 'function'
|
||||
? unwrappedSearchParams.get('leagueId') ?? undefined
|
||||
: undefined;
|
||||
|
||||
const raceId =
|
||||
typeof unwrappedSearchParams?.get === 'function'
|
||||
? unwrappedSearchParams.get('raceId') ?? undefined
|
||||
: undefined;
|
||||
|
||||
let backLink: string | null = null;
|
||||
|
||||
if (from === 'league-standings' && leagueId) {
|
||||
backLink = `/leagues/${leagueId}/standings`;
|
||||
} else if (from === 'league' && leagueId) {
|
||||
backLink = `/leagues/${leagueId}`;
|
||||
} else if (from === 'league-members' && leagueId) {
|
||||
backLink = `/leagues/${leagueId}`;
|
||||
} else if (from === 'league-race' && leagueId && raceId) {
|
||||
backLink = `/leagues/${leagueId}/races/${raceId}`;
|
||||
} else {
|
||||
backLink = null;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadDriver();
|
||||
@@ -119,7 +141,7 @@ export default function DriverDetailPage({
|
||||
/>
|
||||
|
||||
{/* Driver Profile Component */}
|
||||
<DriverProfile driver={driver} />
|
||||
<DriverProfile driver={driver} isOwnProfile={false} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user