quota context hook
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user