Skip to content

Commit

Permalink
chore: code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
Lombardoc4 committed Apr 13, 2024
1 parent d0eafa1 commit bcaa543
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/app/api/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const fetchAPI = async (endpoint: string) => {
},
};

// Check if any fetching is in queue

// If so add to queue

// Need mechanism to tell code to go to next fetch

// Fetch from server
const data = await fetch(`${serverUrl}/${endpoint}`, { ...options })
.then(
Expand Down
11 changes: 7 additions & 4 deletions src/components/QueryNav/DropdownGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { useCallback } from 'react';

import { driverDefault, eventDefault, sessionDefault } from '@/lib/constants';
import { updateSearchParams } from '@/lib/helpers';

import { fetchDriverList } from '@/app/api/fetchDriversAndSessions';
import { fetchEventList } from '@/app/api/fetchEvents';
Expand Down Expand Up @@ -33,8 +34,7 @@ export const DropdownGroup = () => {
const searchParams = useSearchParams();

// *** Param variables
const seasonParam =
searchParams.get('season') || new Date().getFullYear().toString();
const seasonParam = searchParams.get('season') || '';
const eventParam = searchParams.get('event') || '';
const sessionParam = searchParams.get('session') || '';
const driversParam = searchParams.get('drivers') || '';
Expand Down Expand Up @@ -147,14 +147,17 @@ export const DropdownGroup = () => {

params.set(name, value);

return params.toString();
return params;
// .toString();
},
[searchParams, session, season],
);

const dropdownAction = (name: string, value: string) => {
updateState(name, value);
router.push(pathname + '?' + createQueryString(name, value));
const newQueryString = createQueryString(name, value);
const newQueryView = updateSearchParams(newQueryString, 'view', name);
router.push(pathname + '?' + newQueryView);
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/Selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const Selection = ({
? '#'
: `${pathname}?${updateSearchParams(params, 'view', title)}`
}
tabIndex={disabled ? -1 : undefined}
className={cn(
buttonVariants({ variant: 'ghost', size: 'sm' }),
active &&
Expand All @@ -40,7 +41,6 @@ export const Selection = ({
disabled && 'text-muted-foreground',
className,
)}
tabIndex={disabled ? -1 : undefined}
>
{title}
{label && (
Expand Down
10 changes: 5 additions & 5 deletions src/lib/transformers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const formatRaceEventName = (val: string) =>
export const formatSessionUrl = (session: string) =>
sessionUrlParams[session as keyof typeof sessionUrlParams];

export const formatSessionName = (val: string) =>
Object.keys(sessionUrlParams).find(
(key) => sessionUrlParams[key as keyof typeof sessionUrlParams] === val,
);
// export const formatSessionName = (val: string) =>
// Object.keys(sessionUrlParams).find(
// (key) => sessionUrlParams[key as keyof typeof sessionUrlParams] === val,
// );

export const formatConstructorResults = (drivers: DriverResult[]) =>
drivers
Expand Down Expand Up @@ -69,7 +69,7 @@ export const formatNextEvent = (data: ScheduleSchema) => {
key.match(/Session[1-5]DateUtc/g),
);

// Find the next session
// Find the Next Session Time
const nextSessionTime = sessionTimes.find((session) => {
const sessionName = data[
session.slice(0, 8) as keyof ScheduleSchema
Expand Down

0 comments on commit bcaa543

Please sign in to comment.