From a871cf8d8339f5dea203f9fc17d978ee1932c8e0 Mon Sep 17 00:00:00 2001 From: zwlucas Date: Tue, 1 Apr 2025 08:19:35 -0300 Subject: new vote audio and vote list page --- app/listagem/loading.tsx | 3 ++ app/listagem/page.tsx | 104 +++++++++++++++++++++++++++++++++++++++++++++++ app/votar/page.tsx | 33 +++++++++------ package.json | 5 ++- public/confirma.mp3 | Bin 0 -> 33849 bytes 5 files changed, 130 insertions(+), 15 deletions(-) create mode 100644 app/listagem/loading.tsx create mode 100644 app/listagem/page.tsx create mode 100644 public/confirma.mp3 diff --git a/app/listagem/loading.tsx b/app/listagem/loading.tsx new file mode 100644 index 0000000..4349ac3 --- /dev/null +++ b/app/listagem/loading.tsx @@ -0,0 +1,3 @@ +export default function Loading() { + return null; +} diff --git a/app/listagem/page.tsx b/app/listagem/page.tsx new file mode 100644 index 0000000..10f0bcc --- /dev/null +++ b/app/listagem/page.tsx @@ -0,0 +1,104 @@ +"use client"; + +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { getSupabaseClient } from "@/lib/supabase"; +import { useEffect, useState } from "react"; + +export default function ListVotes() { + const [numberVotes, setNumberVotes] = useState(); + const [sieNumberVotes, setSieNumberVotes] = useState(); + const [ljNumberVotes, setLjNumberVotes] = useState(); + + const [saveStatus, setSaveStatus] = useState<"loading" | "success" | "error">( + "loading" + ); + const [errorMessage, setErrorMessage] = useState(""); + + useEffect(() => { + const listVotes = async () => { + const supabase = getSupabaseClient(); + + const { data, error } = await supabase.from("votes").select(); + + if (error) { + console.error("Erro ao procurar votos:", error); + setSaveStatus("error"); + + setErrorMessage( + "Ocorreu um erro ao procurar votos. Por favor, informe ao responsável." + ); + return; + } + + setNumberVotes(data.length); + + const sieData = data.filter((vote) => vote.option_voted == "SIE"); + setSieNumberVotes(sieData.length); + + const ljData = data.filter( + (vote) => vote.option_voted == "Liderança Jovem" + ); + setLjNumberVotes(ljData.length); + }; + + listVotes(); + }); + + return ( +
+
+
+
+
+ JUSTIÇA ELEITORAL +
+
+
+
+ + + + VOTOS ATUAIS + + CHAPA DO GREMIO ESTUDANTIL + + + +
+ + +
+
+ Todos os dados são em tempo real! +
+
+
+ +
+
+ © {new Date().getFullYear()} Justiça Eleitoral Estudantil +
+
+
+
+ ); +} diff --git a/app/votar/page.tsx b/app/votar/page.tsx index 8946f73..62c1bb1 100644 --- a/app/votar/page.tsx +++ b/app/votar/page.tsx @@ -19,6 +19,7 @@ export default function VotarPage() { const cpf = searchParams.get("cpf") || ""; const [selectedOption, setSelectedOption] = useState(null); const [audioContext, setAudioContext] = useState(null); + const [audioElement, setAudioElement] = useState() useEffect(() => { if (!rm || !nome || !cpf) { @@ -26,28 +27,34 @@ export default function VotarPage() { return; } - setAudioContext( - new (window.AudioContext || (window as any).webkitContext)() - ); + // setAudioContext( + // new (window.AudioContext || (window as any).webkitContext)() + // ); + + const audio = new Audio('/confirma.mp3') + setAudioElement(audio) }, [rm, nome, cpf, router]); const handleVote = (option: string) => { setSelectedOption(option); - if (!audioContext) return; + if (!audioElement) return; + audioElement.play() + + // if (!audioContext) return; - const oscillator = audioContext.createOscillator(); - const gainNode = audioContext.createGain(); + // const oscillator = audioContext.createOscillator(); + // const gainNode = audioContext.createGain(); - oscillator.type = "sine"; - oscillator.frequency.setValueAtTime(1000, audioContext.currentTime); - gainNode.gain.setValueAtTime(0.5, audioContext.currentTime); + // oscillator.type = "sine"; + // oscillator.frequency.setValueAtTime(1000, audioContext.currentTime); + // gainNode.gain.setValueAtTime(0.5, audioContext.currentTime); - oscillator.connect(gainNode); - gainNode.connect(audioContext.destination); + // oscillator.connect(gainNode); + // gainNode.connect(audioContext.destination); - oscillator.start(); - oscillator.stop(audioContext.currentTime + 0.2); + // oscillator.start(); + // oscillator.stop(audioContext.currentTime + 0.2); setTimeout(() => { router.push( diff --git a/package.json b/package.json index 972064e..8a108e2 100644 --- a/package.json +++ b/package.json @@ -67,5 +67,6 @@ "postcss": "^8", "tailwindcss": "^3.4.17", "typescript": "^5" - } -} \ No newline at end of file + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" +} diff --git a/public/confirma.mp3 b/public/confirma.mp3 new file mode 100644 index 0000000..e56bd4c Binary files /dev/null and b/public/confirma.mp3 differ -- cgit v1.2.3