website refactor

This commit is contained in:
2026-01-14 02:02:24 +01:00
parent 8d7c709e0c
commit 4522d41aef
291 changed files with 12763 additions and 9309 deletions

View File

@@ -0,0 +1,25 @@
'use client';
import type { Result } from '@/lib/contracts/Result';
import type { SponsorshipRequestsViewData } from '@/lib/view-data/SponsorshipRequestsViewData';
import { SponsorshipRequestsTemplate } from '@/templates/SponsorshipRequestsTemplate';
interface SponsorshipRequestsPageClientProps {
viewData: SponsorshipRequestsViewData;
onAccept: (requestId: string) => Promise<Result<void, string>>;
onReject: (requestId: string, reason?: string) => Promise<Result<void, string>>;
}
export function SponsorshipRequestsPageClient({ viewData, onAccept, onReject }: SponsorshipRequestsPageClientProps) {
return (
<SponsorshipRequestsTemplate
data={viewData.sections}
onAccept={async (requestId) => {
await onAccept(requestId);
}}
onReject={async (requestId, reason) => {
await onReject(requestId, reason);
}}
/>
);
}

View File

@@ -0,0 +1,26 @@
import { AcceptSponsorshipRequestMutation } from '@/lib/mutations/sponsors/AcceptSponsorshipRequestMutation';
import { RejectSponsorshipRequestMutation } from '@/lib/mutations/sponsors/RejectSponsorshipRequestMutation';
import type { AcceptSponsorshipRequestCommand } from '@/lib/services/sponsors/SponsorshipRequestsService';
import type { RejectSponsorshipRequestCommand } from '@/lib/services/sponsors/SponsorshipRequestsService';
export async function acceptSponsorshipRequest(
command: AcceptSponsorshipRequestCommand,
): Promise<void> {
const mutation = new AcceptSponsorshipRequestMutation();
const result = await mutation.execute(command);
if (result.isErr()) {
throw new Error('Failed to accept sponsorship request');
}
}
export async function rejectSponsorshipRequest(
command: RejectSponsorshipRequestCommand,
): Promise<void> {
const mutation = new RejectSponsorshipRequestMutation();
const result = await mutation.execute(command);
if (result.isErr()) {
throw new Error('Failed to reject sponsorship request');
}
}

View File

@@ -1,48 +1,9 @@
'use client';
import { StatefulPageWrapper } from '@/components/shared/state/StatefulPageWrapper';
import { SponsorshipRequestsTemplate } from '@/templates/SponsorshipRequestsTemplate';
import {
useSponsorshipRequestsPageData,
useSponsorshipRequestMutations
} from "@/lib/hooks/sponsor/useSponsorshipRequestsPageData";
import { useEffectiveDriverId } from "@/lib/hooks/useEffectiveDriverId";
export default function SponsorshipRequestsPage() {
const currentDriverId = useEffectiveDriverId();
// Fetch data using domain hook
const { data: sections, isLoading, error, refetch } = useSponsorshipRequestsPageData(currentDriverId);
// Mutations using domain hook
const { acceptMutation, rejectMutation } = useSponsorshipRequestMutations(currentDriverId, refetch);
// Template needs to handle mutations
const TemplateWithMutations = ({ data }: { data: any[] }) => (
<SponsorshipRequestsTemplate
data={data}
onAccept={async (requestId) => {
await acceptMutation.mutateAsync({ requestId });
}}
onReject={async (requestId, reason) => {
await rejectMutation.mutateAsync({ requestId, reason });
}}
/>
);
return (
<StatefulPageWrapper
data={sections}
isLoading={isLoading}
error={error as Error | null}
retry={refetch}
Template={TemplateWithMutations}
loading={{ variant: 'skeleton', message: 'Loading sponsorship requests...' }}
errorConfig={{ variant: 'full-screen' }}
empty={{
title: 'No Pending Requests',
description: 'You don\'t have any pending sponsorship requests at the moment.',
}}
/>
);
}
export default async function SponsorshipRequestsPage({
searchParams,
}: {
searchParams: Record<string, string>;
}) {
return <SponsorshipRequestsTemplate searchParams={searchParams} />;
}