website refactor
This commit is contained in:
@@ -36,13 +36,6 @@ export function TeamDetailPageClient({ viewData }: TeamDetailPageClientProps) {
|
||||
alert('Remove member functionality would be implemented here');
|
||||
};
|
||||
|
||||
const handleChangeRole = (driverId: string, newRole: 'owner' | 'admin' | 'member') => {
|
||||
// This would call an API to change the role
|
||||
console.log('Change role:', driverId, newRole);
|
||||
// In a real implementation, you'd have a mutation hook here
|
||||
alert('Change role functionality would be implemented here');
|
||||
};
|
||||
|
||||
const handleGoBack = () => {
|
||||
router.back();
|
||||
};
|
||||
@@ -55,7 +48,6 @@ export function TeamDetailPageClient({ viewData }: TeamDetailPageClientProps) {
|
||||
onTabChange={handleTabChange}
|
||||
onUpdate={handleUpdate}
|
||||
onRemoveMember={handleRemoveMember}
|
||||
onChangeRole={handleChangeRole}
|
||||
onGoBack={handleGoBack}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -1,56 +1,15 @@
|
||||
import { PageWrapper } from '@/components/shared/state/PageWrapper';
|
||||
import { TeamService } from '@/lib/services/teams/TeamService';
|
||||
import { Trophy } from 'lucide-react';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { routes } from '@/lib/routing/RouteConfig';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { TeamLeaderboardPageQuery } from '@/lib/page-queries/TeamLeaderboardPageQuery';
|
||||
import { TeamLeaderboardPageWrapper } from './TeamLeaderboardPageWrapper';
|
||||
import { TeamSummaryViewModel } from '@/lib/view-models/TeamSummaryViewModel';
|
||||
|
||||
// ============================================================================
|
||||
// MAIN PAGE COMPONENT
|
||||
// ============================================================================
|
||||
|
||||
export default async function TeamLeaderboardPage() {
|
||||
// Manual wiring: create dependencies
|
||||
const service = new TeamService();
|
||||
const query = new TeamLeaderboardPageQuery();
|
||||
const result = await query.execute();
|
||||
|
||||
// Fetch data through service
|
||||
const result = await service.getAllTeams();
|
||||
|
||||
// Handle result
|
||||
let data = null;
|
||||
let error = null;
|
||||
|
||||
if (result.isOk()) {
|
||||
data = result.unwrap().map(t => new TeamSummaryViewModel(t));
|
||||
} else {
|
||||
const domainError = result.getError();
|
||||
error = new Error(domainError.message);
|
||||
if (result.isErr()) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const hasData = (data?.length ?? 0) > 0;
|
||||
|
||||
// Handle loading state (should be fast since we're using async/await)
|
||||
const isLoading = false;
|
||||
const retry = () => {
|
||||
// In server components, we can't retry without a reload
|
||||
redirect(routes.team.detail('leaderboard'));
|
||||
};
|
||||
|
||||
return (
|
||||
<PageWrapper
|
||||
data={hasData ? data : null}
|
||||
isLoading={isLoading}
|
||||
error={error}
|
||||
retry={retry}
|
||||
Template={TeamLeaderboardPageWrapper}
|
||||
loading={{ variant: 'full-screen', message: 'Loading team leaderboard...' }}
|
||||
errorConfig={{ variant: 'full-screen' }}
|
||||
empty={{
|
||||
icon: Trophy,
|
||||
title: 'No teams found',
|
||||
description: 'There are no teams in the system yet.',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
const data = result.unwrap();
|
||||
return <TeamLeaderboardPageWrapper data={data.teams} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user