code quality
Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
This commit is contained in:
@@ -1,22 +1,21 @@
|
||||
'use server';
|
||||
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { CompleteOnboardingMutation } from '@/lib/mutations/onboarding/CompleteOnboardingMutation';
|
||||
import { CompleteOnboardingInputDTO } from '@/lib/types/generated/CompleteOnboardingInputDTO';
|
||||
import { CompleteOnboardingMutation, CompleteOnboardingCommand } from '@/lib/mutations/onboarding/CompleteOnboardingMutation';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { routes } from '@/lib/routing/RouteConfig';
|
||||
|
||||
/**
|
||||
* Complete onboarding - thin wrapper around mutation
|
||||
*
|
||||
*
|
||||
* Pattern: Server Action → Mutation → Service → API Client
|
||||
*
|
||||
*
|
||||
* Authentication is handled automatically by the API via cookies.
|
||||
* The BaseApiClient includes credentials: 'include', so cookies are sent automatically.
|
||||
* If authentication fails, the API returns 401/403 which gets converted to domain errors.
|
||||
*/
|
||||
export async function completeOnboardingAction(
|
||||
input: CompleteOnboardingInputDTO
|
||||
input: CompleteOnboardingCommand
|
||||
): Promise<Result<{ success: boolean }, string>> {
|
||||
const mutation = new CompleteOnboardingMutation();
|
||||
const result = await mutation.execute(input);
|
||||
|
||||
@@ -124,16 +124,16 @@ export async function withdrawFromRaceAction(raceId: string, driverId: string, l
|
||||
}
|
||||
|
||||
// eslint-disable-next-line gridpilot-rules/server-actions-interface
|
||||
export async function navigateToEditRaceAction(leagueId: string): Promise<void> {
|
||||
export async function navigateToEditRaceAction(raceId: string, leagueId: string): Promise<void> {
|
||||
redirect(routes.league.scheduleAdmin(leagueId));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line gridpilot-rules/server-actions-interface
|
||||
export async function navigateToRescheduleRaceAction(leagueId: string): Promise<void> {
|
||||
export async function navigateToRescheduleRaceAction(raceId: string, leagueId: string): Promise<void> {
|
||||
redirect(routes.league.scheduleAdmin(leagueId));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line gridpilot-rules/server-actions-interface
|
||||
export async function navigateToRaceResultsAction(raceId: string): Promise<void> {
|
||||
export async function navigateToRaceResultsAction(raceId: string, leagueId: string): Promise<void> {
|
||||
redirect(routes.race.results(raceId));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export default async function DriverProfilePage({ params }: { params: Promise<{
|
||||
return (
|
||||
<DriverProfilePageClient
|
||||
viewData={null}
|
||||
error={error}
|
||||
error={true}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -76,4 +76,4 @@ export default async function DriverProfilePage({ params }: { params: Promise<{
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export default async function Page() {
|
||||
return (
|
||||
<DriversPageClient
|
||||
viewData={null}
|
||||
error={error}
|
||||
error={true}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,8 +59,12 @@ export default async function LeagueLayout({
|
||||
sponsorSlots: {
|
||||
main: { price: 0, status: 'occupied' },
|
||||
secondary: { price: 0, total: 0, occupied: 0 }
|
||||
}
|
||||
},
|
||||
},
|
||||
ownerId: '',
|
||||
createdAt: '',
|
||||
settings: {},
|
||||
usedSlots: 0,
|
||||
} as any,
|
||||
drivers: [],
|
||||
races: [],
|
||||
seasonProgress: { completedRaces: 0, totalRaces: 0, percentage: 0 },
|
||||
@@ -98,7 +102,7 @@ export default async function LeagueLayout({
|
||||
|
||||
// Check if user is admin or owner
|
||||
const isOwner = currentDriver && data.league.ownerId === currentDriver.id;
|
||||
const isAdmin = currentDriver && data.memberships.members?.some(m => m.driverId === currentDriver.id && m.role === 'admin');
|
||||
const isAdmin = currentDriver && data.memberships.members?.some((m: any) => m.driverId === currentDriver.id && m.role === 'admin');
|
||||
const hasAdminAccess = isOwner || isAdmin;
|
||||
|
||||
const adminTabs = hasAdminAccess ? [
|
||||
|
||||
@@ -73,7 +73,7 @@ export default async function Page({ params }: Props) {
|
||||
// Determine if current user is owner or admin
|
||||
const isOwnerOrAdmin = currentDriverId
|
||||
? currentDriverId === league.ownerId ||
|
||||
data.memberships.members?.some(m => m.driverId === currentDriverId && m.role === 'admin')
|
||||
data.memberships.members?.some((m: any) => m.driverId === currentDriverId && m.role === 'admin')
|
||||
: false;
|
||||
|
||||
// Build ViewData using the builder
|
||||
|
||||
@@ -20,7 +20,7 @@ export default async function LeagueRosterPage({ params }: Props) {
|
||||
}
|
||||
|
||||
const data = result.unwrap();
|
||||
const members = (data.memberships.members || []).map(m => ({
|
||||
const members = (data.memberships.members || []).map((m: any) => ({
|
||||
driverId: m.driverId,
|
||||
driverName: m.driver.name,
|
||||
role: m.role,
|
||||
|
||||
Reference in New Issue
Block a user