Skip to content

Commit

Permalink
Fixed vehicle type selection (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlymonkai authored Jun 24, 2024
1 parent ad65b08 commit edf7ec0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export const styles: Styles = {
containerSmall: {
__media: { maxWidth: 500 },
gridTemplate: `'title' 0
'slider' 1fr
'slider' 1fr
'button' 1fr/ auto`,
},
loadingContainer: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const VehicleTypeSelection = i18nWrap((props: VehicleTypeSelectionProps)
authToken: props.authToken ?? '',
apiDomain: props.apiDomain ?? '',
});
const loading = useLoadingState(true);
const loading = useLoadingState();
const { handleError, setTags, setUserId } = useMonitoring();
const analytics = useAnalytics();
const [initialScroll, setInitialScroll] = useState(true);
Expand Down Expand Up @@ -112,17 +112,17 @@ export const VehicleTypeSelection = i18nWrap((props: VehicleTypeSelectionProps)
}, [props.inspectionId, props.authToken, analytics, setTags, setUserId]);

useEffect(() => {
loading.start();
const fetchInspection = async () => {
if (!props.inspectionId) {
loading.onSuccess();
return;
}
loading.start();
const fetchedInspection = await getInspection({
id: props.inspectionId,
});
const vehicleType = getVehicleTypeFromInspection(fetchedInspection);
if (vehicleType && props.availableVehicleTypes?.includes(vehicleType)) {
if (vehicleType && vehicleTypes.includes(vehicleType)) {
props.onSelectVehicleType?.(vehicleType);
}
loading.onSuccess();
Expand All @@ -146,8 +146,8 @@ export const VehicleTypeSelection = i18nWrap((props: VehicleTypeSelectionProps)
style={{
...rootStyles,
...styles['container'],
...loadingContainer,
...responsive(styles['containerSmall']),
...loadingContainer,
}}
>
{loading.isLoading && <Spinner size={80} />}
Expand Down

0 comments on commit edf7ec0

Please sign in to comment.