From 79670b4c51ebbdd242b894a5f0678618054cc2ef Mon Sep 17 00:00:00 2001 From: zwlucas Date: Mon, 31 Mar 2025 23:34:04 -0300 Subject: create eletrocast-eleicoes --- app/confirmar/loading.tsx | 4 ++ app/confirmar/page.tsx | 140 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 app/confirmar/loading.tsx create mode 100644 app/confirmar/page.tsx (limited to 'app/confirmar') 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 +
+
+
+
+ ); +} -- cgit v1.2.3