From 79670b4c51ebbdd242b894a5f0678618054cc2ef Mon Sep 17 00:00:00 2001 From: zwlucas Date: Mon, 31 Mar 2025 23:34:04 -0300 Subject: create eletrocast-eleicoes --- .env.example | 2 + .gitignore | 20 +- README.md | 36 - app/confirmar/loading.tsx | 4 + app/confirmar/page.tsx | 140 + app/favicon.ico | Bin 25931 -> 0 bytes app/globals.css | 100 +- app/layout.tsx | 26 +- app/obrigado/loading.tsx | 3 + app/obrigado/page.tsx | 169 ++ app/page.tsx | 317 +- app/votar/loading.tsx | 3 + app/votar/page.tsx | 113 + components.json | 21 + components/theme-provider.tsx | 11 + components/ui/accordion.tsx | 58 + components/ui/alert-dialog.tsx | 141 + components/ui/alert.tsx | 59 + components/ui/aspect-ratio.tsx | 7 + components/ui/avatar.tsx | 50 + components/ui/badge.tsx | 36 + components/ui/breadcrumb.tsx | 115 + components/ui/button.tsx | 56 + components/ui/calendar.tsx | 66 + components/ui/card.tsx | 79 + components/ui/carousel.tsx | 262 ++ components/ui/chart.tsx | 365 +++ components/ui/checkbox.tsx | 30 + components/ui/collapsible.tsx | 11 + components/ui/command.tsx | 153 + components/ui/context-menu.tsx | 200 ++ components/ui/dialog.tsx | 122 + components/ui/drawer.tsx | 118 + components/ui/dropdown-menu.tsx | 200 ++ components/ui/form.tsx | 178 ++ components/ui/hover-card.tsx | 29 + components/ui/input-otp.tsx | 71 + components/ui/input.tsx | 22 + components/ui/label.tsx | 26 + components/ui/menubar.tsx | 236 ++ components/ui/navigation-menu.tsx | 128 + components/ui/pagination.tsx | 117 + components/ui/popover.tsx | 31 + components/ui/progress.tsx | 28 + components/ui/radio-group.tsx | 44 + components/ui/resizable.tsx | 45 + components/ui/scroll-area.tsx | 48 + components/ui/select.tsx | 160 ++ components/ui/separator.tsx | 31 + components/ui/sheet.tsx | 140 + components/ui/sidebar.tsx | 763 +++++ components/ui/skeleton.tsx | 15 + components/ui/slider.tsx | 28 + components/ui/sonner.tsx | 31 + components/ui/switch.tsx | 29 + components/ui/table.tsx | 117 + components/ui/tabs.tsx | 55 + components/ui/textarea.tsx | 22 + components/ui/toast.tsx | 129 + components/ui/toaster.tsx | 35 + components/ui/toggle-group.tsx | 61 + components/ui/toggle.tsx | 45 + components/ui/tooltip.tsx | 30 + components/ui/use-mobile.tsx | 19 + components/ui/use-toast.ts | 194 ++ database.sql | 11 + eslint.config.mjs | 16 - hooks/use-mobile.tsx | 19 + hooks/use-toast.ts | 194 ++ lib/supabase.ts | 13 + lib/utils.ts | 6 + next.config.mjs | 48 + next.config.ts | 7 - package-lock.json | 5757 ------------------------------------- package.json | 70 +- postcss.config.mjs | 5 +- public/file.svg | 1 - public/globe.svg | 1 - public/next.svg | 1 - public/placeholder-logo.png | Bin 0 -> 958 bytes public/placeholder-logo.svg | 1 + public/placeholder-user.jpg | Bin 0 -> 2615 bytes public/placeholder.jpg | Bin 0 -> 1596 bytes public/placeholder.svg | 1 + public/vercel.svg | 1 - public/window.svg | 1 - styles/globals.css | 94 + tailwind.config.ts | 96 + tsconfig.json | 2 +- yarn.lock | 2285 +++++++++++++++ 90 files changed, 8649 insertions(+), 5981 deletions(-) create mode 100644 .env.example delete mode 100644 README.md create mode 100644 app/confirmar/loading.tsx create mode 100644 app/confirmar/page.tsx delete mode 100644 app/favicon.ico create mode 100644 app/obrigado/loading.tsx create mode 100644 app/obrigado/page.tsx create mode 100644 app/votar/loading.tsx create mode 100644 app/votar/page.tsx create mode 100644 components.json create mode 100644 components/theme-provider.tsx create mode 100644 components/ui/accordion.tsx create mode 100644 components/ui/alert-dialog.tsx create mode 100644 components/ui/alert.tsx create mode 100644 components/ui/aspect-ratio.tsx create mode 100644 components/ui/avatar.tsx create mode 100644 components/ui/badge.tsx create mode 100644 components/ui/breadcrumb.tsx create mode 100644 components/ui/button.tsx create mode 100644 components/ui/calendar.tsx create mode 100644 components/ui/card.tsx create mode 100644 components/ui/carousel.tsx create mode 100644 components/ui/chart.tsx create mode 100644 components/ui/checkbox.tsx create mode 100644 components/ui/collapsible.tsx create mode 100644 components/ui/command.tsx create mode 100644 components/ui/context-menu.tsx create mode 100644 components/ui/dialog.tsx create mode 100644 components/ui/drawer.tsx create mode 100644 components/ui/dropdown-menu.tsx create mode 100644 components/ui/form.tsx create mode 100644 components/ui/hover-card.tsx create mode 100644 components/ui/input-otp.tsx create mode 100644 components/ui/input.tsx create mode 100644 components/ui/label.tsx create mode 100644 components/ui/menubar.tsx create mode 100644 components/ui/navigation-menu.tsx create mode 100644 components/ui/pagination.tsx create mode 100644 components/ui/popover.tsx create mode 100644 components/ui/progress.tsx create mode 100644 components/ui/radio-group.tsx create mode 100644 components/ui/resizable.tsx create mode 100644 components/ui/scroll-area.tsx create mode 100644 components/ui/select.tsx create mode 100644 components/ui/separator.tsx create mode 100644 components/ui/sheet.tsx create mode 100644 components/ui/sidebar.tsx create mode 100644 components/ui/skeleton.tsx create mode 100644 components/ui/slider.tsx create mode 100644 components/ui/sonner.tsx create mode 100644 components/ui/switch.tsx create mode 100644 components/ui/table.tsx create mode 100644 components/ui/tabs.tsx create mode 100644 components/ui/textarea.tsx create mode 100644 components/ui/toast.tsx create mode 100644 components/ui/toaster.tsx create mode 100644 components/ui/toggle-group.tsx create mode 100644 components/ui/toggle.tsx create mode 100644 components/ui/tooltip.tsx create mode 100644 components/ui/use-mobile.tsx create mode 100644 components/ui/use-toast.ts create mode 100644 database.sql delete mode 100644 eslint.config.mjs create mode 100644 hooks/use-mobile.tsx create mode 100644 hooks/use-toast.ts create mode 100644 lib/supabase.ts create mode 100644 lib/utils.ts create mode 100644 next.config.mjs delete mode 100644 next.config.ts delete mode 100644 package-lock.json delete mode 100644 public/file.svg delete mode 100644 public/globe.svg delete mode 100644 public/next.svg create mode 100644 public/placeholder-logo.png create mode 100644 public/placeholder-logo.svg create mode 100644 public/placeholder-user.jpg create mode 100644 public/placeholder.jpg create mode 100644 public/placeholder.svg delete mode 100644 public/vercel.svg delete mode 100644 public/window.svg create mode 100644 styles/globals.css create mode 100644 tailwind.config.ts create mode 100644 yarn.lock diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..787a424 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +NEXT_PUBLIC_SUPABASE_URL= +NEXT_PUBLIC_SUPABASE_ANON_KEY= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ef6a52..fdb1b48 100644 --- a/.gitignore +++ b/.gitignore @@ -2,16 +2,6 @@ # dependencies /node_modules -/.pnp -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/versions - -# testing -/coverage # next.js /.next/ @@ -20,22 +10,18 @@ # production /build -# misc -.DS_Store -*.pem - # debug npm-debug.log* yarn-debug.log* yarn-error.log* .pnpm-debug.log* -# env files (can opt-in for committing if needed) -.env* +# env files +.env.local # vercel .vercel # typescript *.tsbuildinfo -next-env.d.ts +next-env.d.ts \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index e215bc4..0000000 --- a/README.md +++ /dev/null @@ -1,36 +0,0 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). - -## Getting Started - -First, run the development server: - -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev -``` - -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/app/confirmar/loading.tsx b/app/confirmar/loading.tsx new file mode 100644 index 0000000..cec067b --- /dev/null +++ b/app/confirmar/loading.tsx @@ -0,0 +1,4 @@ +export default function Loading() { + return null +} + diff --git a/app/confirmar/page.tsx b/app/confirmar/page.tsx new file mode 100644 index 0000000..61c7773 --- /dev/null +++ b/app/confirmar/page.tsx @@ -0,0 +1,140 @@ +"use client"; + +import { useEffect } from "react"; +import { useRouter, useSearchParams } from "next/navigation"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { AlertTriangle } from "lucide-react"; + +export default function ConfirmPage() { + const router = useRouter(); + const searchParams = useSearchParams(); + const rm = searchParams.get("rm") || ""; + const nome = searchParams.get("nome") || ""; + const cpf = searchParams.get("cpf") || ""; + + useEffect(() => { + if (!rm || !nome || !cpf) { + router.push("/"); + return; + } + }, [rm, nome, cpf, router]); + + const handleConfirm = () => { + router.push(`/votar?rm=${rm}&nome=${encodeURIComponent(nome)}&cpf=${cpf}`); + }; + + const handleCancel = () => { + router.push("/"); + }; + + const formatCPFDisplay = (cpf: string) => { + if (cpf.includes(".") || cpf.includes("-")) return cpf; + + const cpfClean = cpf.replace(/\D/g, ""); + + if (cpfClean.length === 11) { + return `${cpfClean.substring(0, 3)}.${cpfClean.substring( + 3, + 6 + )}.${cpfClean.substring(6, 9)}-${cpfClean.substring(9, 11)}`; + } + + return cpf; + }; + + const maskCPF = (cpf: string) => { + const formatted = formatCPFDisplay(cpf); + const parts = formatted.split("."); + if (parts.length === 3) { + const lastPart = parts[2].split("-"); + if (lastPart.length === 2) { + return `${parts[0]}.${parts[1]}.${"***"}-${lastPart[1]}`; + } + } + return formatted; + }; + + return ( +
+
+
+
+
+ JUSTIÇA ELEITORAL +
+
+
+
+ + + + CONFIRME SEUS DADOS + + Verifique se as informações estão corretas + + + +
+
+
RM:
+
{rm}
+ +
Nome:
+
{nome}
+ +
CPF:
+
+ {maskCPF(cpf)} +
+
+
+ +
+
+ +
+ ATENÇÃO: Verifique se seus dados estão + corretos. Caso as informações estejam incorretas, seu voto não + será computado. +
+
+
+ +
+ Estas informações estão corretas? +
+
+ + + + +
+ +
+
+ © {new Date().getFullYear()} Justiça Eleitoral Estudantil +
+
+
+
+ ); +} diff --git a/app/favicon.ico b/app/favicon.ico deleted file mode 100644 index 718d6fe..0000000 Binary files a/app/favicon.ico and /dev/null differ diff --git a/app/globals.css b/app/globals.css index a2dc41e..ac68442 100644 --- a/app/globals.css +++ b/app/globals.css @@ -1,26 +1,94 @@ -@import "tailwindcss"; +@tailwind base; +@tailwind components; +@tailwind utilities; -:root { - --background: #ffffff; - --foreground: #171717; +body { + font-family: Arial, Helvetica, sans-serif; } -@theme inline { - --color-background: var(--background); - --color-foreground: var(--foreground); - --font-sans: var(--font-geist-sans); - --font-mono: var(--font-geist-mono); +@layer utilities { + .text-balance { + text-wrap: balance; + } } -@media (prefers-color-scheme: dark) { +@layer base { :root { - --background: #0a0a0a; - --foreground: #ededed; + --background: 0 0% 100%; + --foreground: 0 0% 3.9%; + --card: 0 0% 100%; + --card-foreground: 0 0% 3.9%; + --popover: 0 0% 100%; + --popover-foreground: 0 0% 3.9%; + --primary: 0 0% 9%; + --primary-foreground: 0 0% 98%; + --secondary: 0 0% 96.1%; + --secondary-foreground: 0 0% 9%; + --muted: 0 0% 96.1%; + --muted-foreground: 0 0% 45.1%; + --accent: 0 0% 96.1%; + --accent-foreground: 0 0% 9%; + --destructive: 0 84.2% 60.2%; + --destructive-foreground: 0 0% 98%; + --border: 0 0% 89.8%; + --input: 0 0% 89.8%; + --ring: 0 0% 3.9%; + --chart-1: 12 76% 61%; + --chart-2: 173 58% 39%; + --chart-3: 197 37% 24%; + --chart-4: 43 74% 66%; + --chart-5: 27 87% 67%; + --radius: 0.5rem; + --sidebar-background: 0 0% 98%; + --sidebar-foreground: 240 5.3% 26.1%; + --sidebar-primary: 240 5.9% 10%; + --sidebar-primary-foreground: 0 0% 98%; + --sidebar-accent: 240 4.8% 95.9%; + --sidebar-accent-foreground: 240 5.9% 10%; + --sidebar-border: 220 13% 91%; + --sidebar-ring: 217.2 91.2% 59.8%; + } + .dark { + --background: 0 0% 3.9%; + --foreground: 0 0% 98%; + --card: 0 0% 3.9%; + --card-foreground: 0 0% 98%; + --popover: 0 0% 3.9%; + --popover-foreground: 0 0% 98%; + --primary: 0 0% 98%; + --primary-foreground: 0 0% 9%; + --secondary: 0 0% 14.9%; + --secondary-foreground: 0 0% 98%; + --muted: 0 0% 14.9%; + --muted-foreground: 0 0% 63.9%; + --accent: 0 0% 14.9%; + --accent-foreground: 0 0% 98%; + --destructive: 0 62.8% 30.6%; + --destructive-foreground: 0 0% 98%; + --border: 0 0% 14.9%; + --input: 0 0% 14.9%; + --ring: 0 0% 83.1%; + --chart-1: 220 70% 50%; + --chart-2: 160 60% 45%; + --chart-3: 30 80% 55%; + --chart-4: 280 65% 60%; + --chart-5: 340 75% 55%; + --sidebar-background: 240 5.9% 10%; + --sidebar-foreground: 240 4.8% 95.9%; + --sidebar-primary: 224.3 76.3% 48%; + --sidebar-primary-foreground: 0 0% 100%; + --sidebar-accent: 240 3.7% 15.9%; + --sidebar-accent-foreground: 240 4.8% 95.9%; + --sidebar-border: 240 3.7% 15.9%; + --sidebar-ring: 217.2 91.2% 59.8%; } } -body { - background: var(--background); - color: var(--foreground); - font-family: Arial, Helvetica, sans-serif; +@layer base { + * { + @apply border-border; + } + body { + @apply bg-background text-foreground; + } } diff --git a/app/layout.tsx b/app/layout.tsx index f7fa87e..cc5ccbe 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,20 +1,16 @@ +import type React from "react"; import type { Metadata } from "next"; -import { Geist, Geist_Mono } from "next/font/google"; +import { Roboto } from "next/font/google"; import "./globals.css"; -const geistSans = Geist({ - variable: "--font-geist-sans", - subsets: ["latin"], -}); - -const geistMono = Geist_Mono({ - variable: "--font-geist-mono", +const roboto = Roboto({ + weight: ["400", "500", "700", "900"], subsets: ["latin"], }); export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", + title: "Justiça Eleitoral - Sistema de Votação", + description: "Eleições Estudantis", }; export default function RootLayout({ @@ -23,12 +19,10 @@ export default function RootLayout({ children: React.ReactNode; }>) { return ( - - - {children} - + + {children} ); } + +import "./globals.css"; diff --git a/app/obrigado/loading.tsx b/app/obrigado/loading.tsx new file mode 100644 index 0000000..4349ac3 --- /dev/null +++ b/app/obrigado/loading.tsx @@ -0,0 +1,3 @@ +export default function Loading() { + return null; +} diff --git a/app/obrigado/page.tsx b/app/obrigado/page.tsx new file mode 100644 index 0000000..718e122 --- /dev/null +++ b/app/obrigado/page.tsx @@ -0,0 +1,169 @@ +"use client"; + +import { useEffect, useRef, useState } from "react"; +import { useSearchParams } from "next/navigation"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { CheckCircle2, AlertTriangle } from "lucide-react"; +import { getSupabaseClient } from "@/lib/supabase"; + +export default function ObrigadoPage() { + const searchParams = useSearchParams(); + const rm = searchParams.get("rm") || ""; + const name = searchParams.get("nome") || ""; + const cpf = searchParams.get("cpf") || ""; + const option = searchParams.get("option") || ""; + + const [countdown, setCountdown] = useState(5); + const [saveStatus, setSaveStatus] = useState<"loading" | "success" | "error">( + "loading" + ); + const [errorMessage, setErrorMessage] = useState(""); + + const hasRun = useRef(false); + + useEffect(() => { + if (!rm || !name || !cpf || !option) { + window.location.href = "/"; + return; + } + + const saveVote = async () => { + try { + const supabase = getSupabaseClient(); + + const { error } = await supabase.from("votes").insert([ + { + rm, + name, + cpf: cpf.replace(/\D/g, ""), + option_voted: option, + }, + ]); + + if (error) { + console.error("Erro ao salvar voto:", error); + setSaveStatus("error"); + + if (error.code === "23505") { + setErrorMessage( + "Você já votou anteriormente. Cada eleitor pode votar apenas uma vez." + ); + } else { + setErrorMessage( + "Ocorreu um erro ao registrar seu voto. Por favor, informe ao responsável." + ); + } + return; + } + + setSaveStatus("success"); + } catch (error) { + console.error("Erro ao salvar voto:", error); + setSaveStatus("error"); + setErrorMessage( + "Ocorreu um erro ao registrar seu voto. Por favor, informe ao responsável." + ); + } + }; + + if (!hasRun.current) { + hasRun.current = true; + saveVote(); + } + + const timer = setInterval(() => { + setCountdown((prev) => { + if (prev <= 1) { + clearInterval(timer); + window.location.href = "/"; + return 0; + } + return prev - 1; + }); + }, 1000); + + return () => clearInterval(timer); + }, [rm, name, cpf, option]); + + return ( +
+
+
+
+
+ JUSTIÇA ELEITORAL +
+
+
+
+ + + +
+ {saveStatus === "loading" ? ( +
+ ) : saveStatus === "success" ? ( + + ) : ( + + )} +
+ + {saveStatus === "loading" + ? "PROCESSANDO SEU VOTO..." + : saveStatus === "success" + ? "VOTO REGISTRADO COM SUCESSO!" + : "ERRO AO REGISTRAR VOTO"} + + + {saveStatus === "success" ? "FIM" : ""} + +
+ + {saveStatus === "loading" ? ( +

+ Aguarde enquanto registramos seu voto... +

+ ) : saveStatus === "success" ? ( + <> +

+ Você votou em:{" "} + {option} +

+

+ Obrigado por participar das eleições. +

+

+ Retornando à tela inicial em {countdown} segundos... +

+ + ) : ( + <> +

{errorMessage}

+

+ Retornando à tela inicial em {countdown} segundos... +

+ + )} +
+
+ +
+
+ © {new Date().getFullYear()} Justiça Eleitoral Estudantil +
+
+
+
+ ); +} diff --git a/app/page.tsx b/app/page.tsx index 88f0cc9..56ac851 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,103 +1,228 @@ -import Image from "next/image"; +"use client"; + +import type React from "react"; + +import { useState } from "react"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { useRouter } from "next/navigation"; export default function Home() { + const [rm, setRm] = useState(""); + const [nome, setNome] = useState(""); + const [cpf, setCpf] = useState(""); + const [errors, setErrors] = useState<{ + rm?: string; + nome?: string; + cpf?: string; + }>({}); + const router = useRouter(); + + function validateCPF(cpf: string): boolean { + cpf = cpf.replace(/\D/g, ""); + + if (cpf.length !== 11 || /^(\d)\1{10}$/.test(cpf)) return false; + + const calc = (factor: number) => + cpf + .split("") + .slice(0, factor - 1) + .reduce( + (sum, num, index) => sum + parseInt(num) * (factor - index), + 0 + ) % + 11 < + 2 + ? 0 + : 11 - + (cpf + .split("") + .slice(0, factor - 1) + .reduce( + (sum, num, index) => sum + parseInt(num) * (factor - index), + 0 + ) % + 11); + + return calc(10) === parseInt(cpf[9]) && calc(11) === parseInt(cpf[10]); + } + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + + const newErrors: { rm?: string; nome?: string; cpf?: string } = {}; + + if (!/^\d{5}$/.test(rm)) { + newErrors.rm = "O RM deve conter exatamente 5 dígitos numéricos."; + } + + if (!nome || nome.trim().length < 3) { + newErrors.nome = "Por favor, insira seu nome completo."; + } + + if (!validateCPF(cpf)) { + newErrors.cpf = "CPF inválido. Insira um CPF válido com 11 dígitos."; + } + + if (Object.keys(newErrors).length > 0) { + setErrors(newErrors); + return; + } + + setErrors({}); + + router.push( + `/confirmar?rm=${rm}&nome=${encodeURIComponent(nome)}&cpf=${cpf}` + ); + }; + + const formatCPF = (value: string) => { + const cpfClean = value.replace(/\D/g, ""); + let formatted = cpfClean; + + if (cpfClean.length > 3) { + formatted = cpfClean.substring(0, 3) + "." + cpfClean.substring(3); + } + if (cpfClean.length > 6) { + formatted = formatted.substring(0, 7) + "." + cpfClean.substring(6, 9); + } + if (cpfClean.length > 9) { + formatted = formatted.substring(0, 11) + "-" + cpfClean.substring(9, 11); + } + + return formatted; + }; + + const handleCPFChange = (e: React.ChangeEvent) => { + const value = e.target.value; + const formatted = formatCPF(value); + setCpf(formatted); + + if (errors.cpf) { + setErrors((prev) => ({ ...prev, cpf: undefined })); + } + }; + return ( -
-
- Next.js logo -
    -
  1. - Get started by editing{" "} - - app/page.tsx - - . -
  2. -
  3. - Save and see your changes instantly. -
  4. -
- -
- - Vercel logomark - Deploy now - - - Read our docs - +
+
+
+
+
+ JUSTIÇA ELEITORAL +
+
+
+
+ + + + ELEIÇÕES ESTUDANTIS + + Identificação do Eleitor + + + +
+
+ + { + setRm(e.target.value); + if (errors.rm) { + setErrors((prev) => ({ ...prev, rm: undefined })); + } + }} + placeholder="Digite os 5 dígitos do seu RM" + className="border-2 border-[#004a93]" + maxLength={5} + /> + {errors.rm && ( +

{errors.rm}

+ )} +
+ +
+ + { + setNome(e.target.value); + if (errors.nome) { + setErrors((prev) => ({ ...prev, nome: undefined })); + } + }} + placeholder="Digite seu nome completo" + className="border-2 border-[#004a93]" + /> + {errors.nome && ( +

{errors.nome}

+ )} +
+ +
+ + + {errors.cpf && ( +

{errors.cpf}

+ )} +
+ + +
+
+ + Seu voto é secreto e seguro. + +
+ +
+
+ © {new Date().getFullYear()} Justiça Eleitoral Estudantil +
-
- +
); } diff --git a/app/votar/loading.tsx b/app/votar/loading.tsx new file mode 100644 index 0000000..4349ac3 --- /dev/null +++ b/app/votar/loading.tsx @@ -0,0 +1,3 @@ +export default function Loading() { + return null; +} diff --git a/app/votar/page.tsx b/app/votar/page.tsx new file mode 100644 index 0000000..8946f73 --- /dev/null +++ b/app/votar/page.tsx @@ -0,0 +1,113 @@ +"use client"; + +import { useState, useEffect } from "react"; +import { useRouter, useSearchParams } from "next/navigation"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; + +export default function VotarPage() { + const router = useRouter(); + const searchParams = useSearchParams(); + const rm = searchParams.get("rm") || ""; + const nome = searchParams.get("nome") || ""; + const cpf = searchParams.get("cpf") || ""; + const [selectedOption, setSelectedOption] = useState(null); + const [audioContext, setAudioContext] = useState(null); + + useEffect(() => { + if (!rm || !nome || !cpf) { + router.push("/"); + return; + } + + setAudioContext( + new (window.AudioContext || (window as any).webkitContext)() + ); + }, [rm, nome, cpf, router]); + + const handleVote = (option: string) => { + setSelectedOption(option); + + if (!audioContext) return; + + 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.connect(gainNode); + gainNode.connect(audioContext.destination); + + oscillator.start(); + oscillator.stop(audioContext.currentTime + 0.2); + + setTimeout(() => { + router.push( + `/obrigado?rm=${rm}&nome=${encodeURIComponent( + nome + )}&cpf=${cpf}&option=${option}` + ); + }, 500); + }; + + return ( +
+
+
+
+
+ JUSTIÇA ELEITORAL +
+
+
+
+ + + + SEU VOTO PARA + + CHAPA DO GREMIO ESTUDANTIL + + + +
+ + +
+
+ Toque no quadro correspondente para VOTAR +
+
+
+ +
+
+ © {new Date().getFullYear()} Justiça Eleitoral Estudantil +
+
+
+
+ ); +} diff --git a/components.json b/components.json new file mode 100644 index 0000000..d9ef0ae --- /dev/null +++ b/components.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "default", + "rsc": true, + "tsx": true, + "tailwind": { + "config": "tailwind.config.ts", + "css": "app/globals.css", + "baseColor": "neutral", + "cssVariables": true, + "prefix": "" + }, + "aliases": { + "components": "@/components", + "utils": "@/lib/utils", + "ui": "@/components/ui", + "lib": "@/lib", + "hooks": "@/hooks" + }, + "iconLibrary": "lucide" +} \ No newline at end of file diff --git a/components/theme-provider.tsx b/components/theme-provider.tsx new file mode 100644 index 0000000..1a44ac3 --- /dev/null +++ b/components/theme-provider.tsx @@ -0,0 +1,11 @@ +"use client"; + +import * as React from "react"; +import { + ThemeProvider as NextThemesProvider, + type ThemeProviderProps, +} from "next-themes"; + +export function ThemeProvider({ children, ...props }: ThemeProviderProps) { + return {children}; +} diff --git a/components/ui/accordion.tsx b/components/ui/accordion.tsx new file mode 100644 index 0000000..24c788c --- /dev/null +++ b/components/ui/accordion.tsx @@ -0,0 +1,58 @@ +"use client" + +import * as React from "react" +import * as AccordionPrimitive from "@radix-ui/react-accordion" +import { ChevronDown } from "lucide-react" + +import { cn } from "@/lib/utils" + +const Accordion = AccordionPrimitive.Root + +const AccordionItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AccordionItem.displayName = "AccordionItem" + +const AccordionTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + svg]:rotate-180", + className + )} + {...props} + > + {children} + + + +)) +AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName + +const AccordionContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + +
{children}
+
+)) + +AccordionContent.displayName = AccordionPrimitive.Content.displayName + +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } diff --git a/components/ui/alert-dialog.tsx b/components/ui/alert-dialog.tsx new file mode 100644 index 0000000..25e7b47 --- /dev/null +++ b/components/ui/alert-dialog.tsx @@ -0,0 +1,141 @@ +"use client" + +import * as React from "react" +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" + +import { cn } from "@/lib/utils" +import { buttonVariants } from "@/components/ui/button" + +const AlertDialog = AlertDialogPrimitive.Root + +const AlertDialogTrigger = AlertDialogPrimitive.Trigger + +const AlertDialogPortal = AlertDialogPrimitive.Portal + +const AlertDialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName + +const AlertDialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + +)) +AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName + +const AlertDialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +AlertDialogHeader.displayName = "AlertDialogHeader" + +const AlertDialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +AlertDialogFooter.displayName = "AlertDialogFooter" + +const AlertDialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName + +const AlertDialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogDescription.displayName = + AlertDialogPrimitive.Description.displayName + +const AlertDialogAction = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName + +const AlertDialogCancel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName + +export { + AlertDialog, + AlertDialogPortal, + AlertDialogOverlay, + AlertDialogTrigger, + AlertDialogContent, + AlertDialogHeader, + AlertDialogFooter, + AlertDialogTitle, + AlertDialogDescription, + AlertDialogAction, + AlertDialogCancel, +} diff --git a/components/ui/alert.tsx b/components/ui/alert.tsx new file mode 100644 index 0000000..41fa7e0 --- /dev/null +++ b/components/ui/alert.tsx @@ -0,0 +1,59 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const alertVariants = cva( + "relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground", + { + variants: { + variant: { + default: "bg-background text-foreground", + destructive: + "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +const Alert = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes & VariantProps +>(({ className, variant, ...props }, ref) => ( +
+)) +Alert.displayName = "Alert" + +const AlertTitle = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +AlertTitle.displayName = "AlertTitle" + +const AlertDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +AlertDescription.displayName = "AlertDescription" + +export { Alert, AlertTitle, AlertDescription } diff --git a/components/ui/aspect-ratio.tsx b/components/ui/aspect-ratio.tsx new file mode 100644 index 0000000..d6a5226 --- /dev/null +++ b/components/ui/aspect-ratio.tsx @@ -0,0 +1,7 @@ +"use client" + +import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio" + +const AspectRatio = AspectRatioPrimitive.Root + +export { AspectRatio } diff --git a/components/ui/avatar.tsx b/components/ui/avatar.tsx new file mode 100644 index 0000000..51e507b --- /dev/null +++ b/components/ui/avatar.tsx @@ -0,0 +1,50 @@ +"use client" + +import * as React from "react" +import * as AvatarPrimitive from "@radix-ui/react-avatar" + +import { cn } from "@/lib/utils" + +const Avatar = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +Avatar.displayName = AvatarPrimitive.Root.displayName + +const AvatarImage = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarImage.displayName = AvatarPrimitive.Image.displayName + +const AvatarFallback = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName + +export { Avatar, AvatarImage, AvatarFallback } diff --git a/components/ui/badge.tsx b/components/ui/badge.tsx new file mode 100644 index 0000000..f000e3e --- /dev/null +++ b/components/ui/badge.tsx @@ -0,0 +1,36 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const badgeVariants = cva( + "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", + secondary: + "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", + destructive: + "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", + outline: "text-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +export interface BadgeProps + extends React.HTMLAttributes, + VariantProps {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ( +
+ ) +} + +export { Badge, badgeVariants } diff --git a/components/ui/breadcrumb.tsx b/components/ui/breadcrumb.tsx new file mode 100644 index 0000000..60e6c96 --- /dev/null +++ b/components/ui/breadcrumb.tsx @@ -0,0 +1,115 @@ +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { ChevronRight, MoreHorizontal } from "lucide-react" + +import { cn } from "@/lib/utils" + +const Breadcrumb = React.forwardRef< + HTMLElement, + React.ComponentPropsWithoutRef<"nav"> & { + separator?: React.ReactNode + } +>(({ ...props }, ref) =>