Skip to content

Commit

Permalink
Fix sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ru Chern Chong committed Jul 28, 2024
1 parent 266b72b commit f46641b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/cars/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { API_URL, FUEL_TYPE } from "@/config";
import { fetchApi } from "@/utils/fetchApi";
import { formatDateToMonthYear } from "@/utils/formatDateToMonthYear";
import { formatPercent } from "@/utils/formatPercent";
import type { Car, VEHICLE_TYPE } from "@/types";
import type { Car } from "@/types";
import Typography from "@/components/Typography";
import { UnreleasedFeature } from "@/components/UnreleasedFeature";

Expand Down Expand Up @@ -93,10 +93,13 @@ const CarsPage = async ({ searchParams }: CarsPageProps) => {
return acc;
}, {});

const findTopEntry = (data: Record<string, number>) =>
Object.entries(data).reduce((max, entry) =>
entry[1] > max[1] ? entry : max,
const findTopEntry = (data: Record<string, number>) => {
const entries = Object.entries(data);
return entries.reduce(
(max, entry) => (entry[1] > max[1] ? entry : max),
entries[0],
);
};

const numberByFuelType = aggregateData(cars, "fuel_type");
const [topFuelType, topFuelTypeValue] = findTopEntry(numberByFuelType);
Expand Down

0 comments on commit f46641b

Please sign in to comment.