mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-06-02 22:26:57 -05:00
* Initial * Search users from API * Better feeling search * Fix TODO * Search via url, discord id & id * Load initial user * UserSearch on admin page * UserSearch on tournaments page * UserSearch for badges * Plus suggestions * Vod page * Remove unused code * Fix test
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import useSWRImmutable from "swr/immutable";
|
|
import type { WeaponUsageLoaderData } from "~/features/sendouq/routes/weapon-usage";
|
|
import type { ModeShort, StageId } from "~/modules/in-game-lists";
|
|
import type { EventsWithMapPoolsLoaderData } from "~/routes/calendar/map-pool-events";
|
|
import {
|
|
GET_ALL_EVENTS_WITH_MAP_POOLS_ROUTE,
|
|
getWeaponUsage,
|
|
} from "~/utils/urls";
|
|
|
|
const fetcher = async (url: string) => {
|
|
const res = await fetch(url);
|
|
return res.json();
|
|
};
|
|
|
|
export function useAllEventsWithMapPools() {
|
|
const { data, error } = useSWRImmutable<EventsWithMapPoolsLoaderData>(
|
|
GET_ALL_EVENTS_WITH_MAP_POOLS_ROUTE,
|
|
fetcher
|
|
);
|
|
|
|
return {
|
|
events: data?.events,
|
|
isLoading: !error && !data,
|
|
isError: error,
|
|
};
|
|
}
|
|
|
|
export function useWeaponUsage(args: {
|
|
userId: number;
|
|
season: number;
|
|
modeShort: ModeShort;
|
|
stageId: StageId;
|
|
}) {
|
|
const { data, error } = useSWRImmutable<WeaponUsageLoaderData>(
|
|
getWeaponUsage(args),
|
|
fetcher
|
|
);
|
|
|
|
return {
|
|
weaponUsage: data?.usage,
|
|
isLoading: !error && !data,
|
|
isError: error,
|
|
};
|
|
}
|