diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index f9b4ab1..286db93 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react'; -import { GitHub, LastFM, Twitter } from './SocialIcons'; +import { GitHub, LastFM, Twitter, Medal } from './SocialIcons'; export default function Footer() { const [mailState, setMailState] = useState(false); @@ -11,7 +11,7 @@ export default function Footer() { }, [mailState]) return ( -
+

© {new Date().getFullYear()}, Alex Frantz. All Rights Reserved

All logos & images on this page belong to their respective owners.

@@ -36,6 +36,9 @@ export default function Footer() { + + +
) diff --git a/src/components/RecentWatch.tsx b/src/components/RecentWatch.tsx new file mode 100644 index 0000000..bb80aba --- /dev/null +++ b/src/components/RecentWatch.tsx @@ -0,0 +1,91 @@ +import { useState, useEffect } from 'react'; + +type WatchDataResponse = { + result: { + data: { + json: WatchData + } + } +}; +type WatchData = { + id: number, + title: string, + description: string, + imageKey: string, + currentEpisode: string, + tmdbID: string, + finished: boolean, + startedOn: Date, + createdAt: Date, + updatedAt: Date, + createdById: string +} + +export default function RecentWatch() { + const [ data, setData ] = useState(null); + const [ loading, setLoading ] = useState(true); + const [ errorState, setErrorState ] = useState(""); + + useEffect(() => { + fetch("https://watch.alexav.gg/api/trpc/watchItem.getLatest", { + method: 'get' + }) + .then(async (res) => { + if (res.ok) { + const json = await res.json() as WatchDataResponse; + setData(json.result.data.json); + setLoading(false) + } else { + setErrorState("Failed to fetch data!"); + setLoading(false); + } + }) + .catch((e) => { + setLoading(false); + setErrorState(e.message) + }) + }, []); + + const parseDate = (date: Date) => { + const jsDate = new Date(date); + return `${jsDate.getFullYear()}/${jsDate.getMonth() + 1}/${jsDate.getDate()}`; + } + + return ( + +
+ { + loading ? ( +

Loading..

+ ) : !errorState ? ( +
+ +
+

{data?.title}

+ + { + data?.finished ? ( +

Finished!

+ ) : ( +

Started on {parseDate(new Date(data?.startedOn as Date))}

+ ) + } + +

{data?.currentEpisode}

+
+
+ ) : ( + <> +

Failed to fetch :(

+

Check out watch.alexav.gg if this isn't working.

+ + ) + } +
+ + ) + +} \ No newline at end of file diff --git a/src/components/SocialIcons.tsx b/src/components/SocialIcons.tsx index 6258fe2..9ec8788 100644 --- a/src/components/SocialIcons.tsx +++ b/src/components/SocialIcons.tsx @@ -46,4 +46,32 @@ export const Twitter = () => { 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z"/> ) +} + +export const Medal = () => { + return ( + + + + + + + + + + + + + + + + + + + + + + ) } \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index d4e55e7..2e5b12b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,6 +3,7 @@ import Header from "./components/Header"; import ListBox from "./components/ListBox"; import Project from "./components/Project"; import ContactForm from "./components/ContactForm"; +import RecentWatch from "./components/RecentWatch"; export default function Home() { return ( @@ -37,7 +38,17 @@ export default function Home() { /> -
+
+
+
+

What am I watching?

+
+
+ +
+
+
+