add website tests

This commit is contained in:
2025-12-28 21:02:32 +01:00
parent 6edf12fda8
commit 2f6657f56d
20 changed files with 1868 additions and 97 deletions

View File

@@ -269,10 +269,14 @@ export default function ProfilePage() {
const isOwnProfile = true; // This page is always your own profile
useEffect(() => {
if (!effectiveDriverId) {
return;
}
const loadData = async () => {
setLoading(true);
try {
const currentDriverId = effectiveDriverId;
const profileViewModel = await driverService.getDriverProfile(currentDriverId);
const profileViewModel = await driverService.getDriverProfile(effectiveDriverId);
setProfileData(profileViewModel);
} catch (error) {
console.error('Failed to load profile:', error);
@@ -280,6 +284,7 @@ export default function ProfilePage() {
setLoading(false);
}
};
void loadData();
}, [effectiveDriverId, driverService]);

View File

@@ -22,7 +22,9 @@ interface EntitySection {
export default function SponsorshipRequestsPage() {
const currentDriverId = useEffectiveDriverId();
const { sponsorshipService, driverService, leagueService, teamService, leagueMembershipService } = useServices();
const [sections, setSections] = useState<EntitySection[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
@@ -32,7 +34,10 @@ export default function SponsorshipRequestsPage() {
setError(null);
try {
const { sponsorshipService, driverService, leagueService, teamService, leagueMembershipService } = useServices();
if (!currentDriverId) {
setSections([]);
return;
}
const allSections: EntitySection[] = [];
@@ -107,20 +112,20 @@ export default function SponsorshipRequestsPage() {
} finally {
setLoading(false);
}
}, [currentDriverId]);
}, [currentDriverId, sponsorshipService, driverService, leagueService, teamService, leagueMembershipService]);
useEffect(() => {
loadAllRequests();
}, [loadAllRequests]);
const handleAccept = async (requestId: string) => {
const { sponsorshipService } = useServices();
if (!currentDriverId) return;
await sponsorshipService.acceptSponsorshipRequest(requestId, currentDriverId);
await loadAllRequests();
};
const handleReject = async (requestId: string, reason?: string) => {
const { sponsorshipService } = useServices();
if (!currentDriverId) return;
await sponsorshipService.rejectSponsorshipRequest(requestId, currentDriverId, reason);
await loadAllRequests();
};