resolve todos in website
This commit is contained in:
@@ -8,10 +8,8 @@ import { useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import DriverSummaryPill from '@/components/profile/DriverSummaryPill';
|
||||
import { useEffectiveDriverId } from '@/hooks/useEffectiveDriverId';
|
||||
import type { DriverDTO } from '@core/racing/application/dto/DriverDTO';
|
||||
import { EntityMappers } from '@core/racing/application/mappers/EntityMappers';
|
||||
|
||||
// TODO EntityMapper is legacy. Must use ´useServices` hook.
|
||||
import type { DriverDTO } from '@/lib/types/generated/DriverDTO';
|
||||
import { useServices } from '@/lib/services/ServiceProvider';
|
||||
|
||||
// Hook to detect sponsor mode
|
||||
function useSponsorMode(): boolean {
|
||||
@@ -84,6 +82,7 @@ function SponsorSummaryPill({
|
||||
|
||||
export default function UserPill() {
|
||||
const { session } = useAuth();
|
||||
const { driverService, mediaService } = useServices();
|
||||
const [driver, setDriver] = useState<DriverDTO | null>(null);
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
const isSponsorMode = useSponsorMode();
|
||||
@@ -103,19 +102,18 @@ export default function UserPill() {
|
||||
return;
|
||||
}
|
||||
|
||||
const repo = getDriverRepository();
|
||||
const entity = await repo.findById(primaryDriverId);
|
||||
const dto = await driverService.findById(primaryDriverId);
|
||||
if (!cancelled) {
|
||||
setDriver(EntityMappers.toDriverDTO(entity));
|
||||
setDriver(dto);
|
||||
}
|
||||
}
|
||||
|
||||
loadDriver();
|
||||
void loadDriver();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [primaryDriverId]);
|
||||
}, [primaryDriverId, driverService]);
|
||||
|
||||
const data = useMemo(() => {
|
||||
if (!session?.user || !primaryDriverId || !driver) {
|
||||
@@ -153,7 +151,7 @@ export default function UserPill() {
|
||||
}
|
||||
}
|
||||
|
||||
const avatarSrc = getImageService().getDriverAvatar(primaryDriverId);
|
||||
const avatarSrc = mediaService.getDriverAvatar(primaryDriverId);
|
||||
|
||||
return {
|
||||
driver,
|
||||
@@ -161,7 +159,7 @@ export default function UserPill() {
|
||||
rating,
|
||||
rank,
|
||||
};
|
||||
}, [session, driver, primaryDriverId]);
|
||||
}, [session, driver, primaryDriverId, mediaService]);
|
||||
|
||||
// Close menu when clicking outside
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user