idk even know anymore

i think i added games
This commit is contained in:
2026-02-15 21:48:01 +03:00
parent 7ced62517a
commit c357e78003
18 changed files with 568 additions and 14 deletions

33
web/src/api/games.ts Normal file
View File

@@ -0,0 +1,33 @@
import { useMutation, useQuery } from "@tanstack/react-query";
export type SearchGame = {
name: string;
steamAppId: number;
image: string;
releaseDate: string;
};
export const useSearchGamesQuery = (params: { search: string }) => {
return useQuery({
queryKey: ["search-games", params],
queryFn: async () => {
const q = new URLSearchParams();
q.set("q", params.search);
const resp = await fetch(`/api/search/games?${q.toString()}`);
return (await resp.json()) as SearchGame[];
},
});
};
export const useAddGameMutation = () => {
return useMutation({
mutationFn: async (data: { steamAppId: number }) => {
const resp = await fetch("/api/user/games", {
method: "POST",
body: JSON.stringify(data),
});
return await resp.json();
},
});
};