quota context hook

This commit is contained in:
2025-08-03 19:59:01 +02:00
parent 3eadd5c15d
commit 67d8dac8c0
4 changed files with 24 additions and 23 deletions
+3 -1
View File
@@ -3,6 +3,7 @@ import { useState } from "react";
import { Nunito } from "next/font/google";
import { api } from "muzak/data/fetcher";
import { useAnimation } from "muzak/contexts/AnimationContext";
import { useQuota } from "muzak/contexts/QuotaContext";
const nunito = Nunito({
weight: "900",
@@ -16,7 +17,7 @@ export default function Nominations() {
const [message, setMessage] = useState("");
const isSpotifyURL =
/^https:\/\/open\.spotify\.com\/track\/[a-zA-Z0-9]{22}/.test(songURL);
const { quota, setQuota } = useQuota();
async function nominate(spotifyLink: string) {
try {
setIsAnimate(false);
@@ -25,6 +26,7 @@ export default function Nominations() {
});
console.log("Nomination successful:", response);
setIsAnimate(true);
setQuota(quota - 1);
return { success: true, data: response.data };
} catch (error) {
console.error("Nomination failed:", error);