From 54883d34c0638e44ba4ddb5946860268a15a1dbd Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Sun, 3 Aug 2025 10:12:12 +0200 Subject: [PATCH] quota update. endpoint cleanup --- frontend/src/components/Quota.tsx | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 frontend/src/components/Quota.tsx diff --git a/frontend/src/components/Quota.tsx b/frontend/src/components/Quota.tsx new file mode 100644 index 0000000..71def44 --- /dev/null +++ b/frontend/src/components/Quota.tsx @@ -0,0 +1,37 @@ +import Link from "next/link"; +import { useAuth } from "react-oidc-context"; +import { useEffect, useState } from "react"; +import { Nunito } from "next/font/google"; +import { api, Profile } from "muzak/data/fetcher"; +const nunito = Nunito({ + subsets: ["latin"], +}); + +export default function Quota({ + quota, + setQuota, +}: { + quota: number | null; + setQuota: React.Dispatch>; +}) { + const auth = useAuth(); + async function getProfile() { + if (!auth.isLoading && !auth.error && auth.isAuthenticated) { + const { data: profile } = await api?.profiles?.me({}); + setQuota(profile?.quota); + } + } + useEffect(() => { + getProfile(); + }, [auth]); + + if (!auth.isLoading && !auth.error && auth.isAuthenticated) { + return ( +

+ {quota} +

+ ); + } +}