diff --git a/src/components/ProjectComponents/RecentGame.tsx b/src/components/ProjectComponents/RecentGame.tsx index c39ce3d..2365872 100644 --- a/src/components/ProjectComponents/RecentGame.tsx +++ b/src/components/ProjectComponents/RecentGame.tsx @@ -1,35 +1,31 @@ import { useState, useEffect } from 'react'; import ProjectComponent from '../ProjectComponent'; -type SteamAPIResponse = { - data: GameItem[] +type GameAPIResponse = { + data: GameData } -type GameItem = { - appid: number, +type GameData = { name: string, - playtime_forever: number, - img_icon_url: string, + location: string, + startedOn: number } - export default function RecentGame() { - const [ data, setData ] = useState(); + const [ data, setData ] = useState(); const [ errorState, setErrorState ] = useState(""); const [ loading, setLoading ] = useState(true); - const translateToAppStorePage = (appId: number) => { - return "https://store.steampowered.com/app/" + appId - } - const buildMediaUrl = (appId: number, hash: string) => { - return "https://media.steampowered.com/steamcommunity/public/images/apps/" + appId + "/" + hash + ".jpg" + const getTime = (time: number) => { + const date = new Date(time*1000); + return `${date.toLocaleDateString()} at ${date.toLocaleTimeString()}` } useEffect(() => { - fetch("https://api.alexav.gg/v4/social/steam", { + fetch("https://api.alexav.gg/v4/game", { method: "get" }) .then(async (res) => { if (res.ok) { - const data = await res.json() as SteamAPIResponse + const data = await res.json() as GameAPIResponse setData(data.data); } else { setErrorState("Failed to load! :(") @@ -45,11 +41,11 @@ export default function RecentGame() { if (!loading && data) { return ( )