|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { |
| 4 | + useState, |
| 5 | + ChangeEvent, |
| 6 | + FormEvent, |
| 7 | + MouseEvent, |
| 8 | +} from "react"; |
| 9 | +import { verifyPeople } from "@/data/verify-data"; |
| 10 | + |
| 11 | +export default function VerifyPage() { |
| 12 | + const [inputValue, setInputValue] = useState(""); |
| 13 | + const [result, setResult] = useState<string | null>(null); |
| 14 | + const [status, setStatus] = useState<StatusType>(null); |
| 15 | + const [showHowModal, setShowHowModal] = useState(false); |
| 16 | + |
| 17 | + type StatusType = "success" | "error" | "warning" | null; |
| 18 | + |
| 19 | + |
| 20 | + const handleChange = (e: ChangeEvent<HTMLInputElement>) => { |
| 21 | + setInputValue(e.target.value); |
| 22 | + setResult(null); |
| 23 | + }; |
| 24 | + |
| 25 | + const handleSubmit = (e: FormEvent) => { |
| 26 | + e.preventDefault(); |
| 27 | + const trimmed = inputValue.trim(); |
| 28 | + |
| 29 | + if (!trimmed) { |
| 30 | + setResult("Please enter a Discord user ID."); |
| 31 | + setStatus("warning"); |
| 32 | + return; |
| 33 | + } |
| 34 | + |
| 35 | + const person = verifyPeople.find((p) => p.ids.includes(trimmed)); |
| 36 | + |
| 37 | + if (person) { |
| 38 | + setResult(`This Discord ID belongs to ${person.name}.`); |
| 39 | + setStatus("success"); |
| 40 | + } else { |
| 41 | + setResult( |
| 42 | + "Unknown ID. If this is an impersonator, please report this in the Discord server!" |
| 43 | + ); |
| 44 | + setStatus("error"); |
| 45 | + } |
| 46 | + }; |
| 47 | + |
| 48 | + const statusColor = |
| 49 | + status === "success" |
| 50 | + ? "text-emerald-400" |
| 51 | + : status === "warning" |
| 52 | + ? "text-amber-300" |
| 53 | + : status === "error" |
| 54 | + ? "text-red-400" |
| 55 | + : ""; |
| 56 | + |
| 57 | + const openModal = (e: MouseEvent<HTMLButtonElement>) => { |
| 58 | + e.preventDefault(); |
| 59 | + setShowHowModal(true); |
| 60 | + }; |
| 61 | + |
| 62 | + const closeModal = () => setShowHowModal(false); |
| 63 | + |
| 64 | + return ( |
| 65 | + <main className="min-h-[calc(100vh-4rem)] flex items-center justify-center px-4"> |
| 66 | + <div className="max-w-md w-full"> |
| 67 | + <div className="mb-6 text-center space-y-2"> |
| 68 | + <p className="text-xs uppercase tracking-[0.25em] text-muted-foreground"> |
| 69 | + Cobalt |
| 70 | + </p> |
| 71 | + <h1 className="text-2xl font-semibold">Discord ID Verification</h1> |
| 72 | + </div> |
| 73 | + |
| 74 | + <form |
| 75 | + onSubmit={handleSubmit} |
| 76 | + className="rounded-xl border border-border/60 bg-card/60 backdrop-blur-sm p-4 space-y-4" |
| 77 | + > |
| 78 | + <div className="space-y-2"> |
| 79 | + <div className="flex items-center justify-between gap-3"> |
| 80 | + <label |
| 81 | + htmlFor="verify-id" |
| 82 | + className="text-xs font-medium text-muted-foreground uppercase tracking-[0.2em]" |
| 83 | + > |
| 84 | + Discord user ID |
| 85 | + </label> |
| 86 | + <button |
| 87 | + onClick={openModal} |
| 88 | + className="text-[11px] text-muted-foreground hover:text-foreground underline-offset-4 hover:underline" |
| 89 | + type="button" |
| 90 | + > |
| 91 | + How do I find this? |
| 92 | + </button> |
| 93 | + </div> |
| 94 | + |
| 95 | + <input |
| 96 | + id="verify-id" |
| 97 | + type="text" |
| 98 | + autoComplete="off" |
| 99 | + value={inputValue} |
| 100 | + onChange={handleChange} |
| 101 | + className="w-full rounded-lg border border-input bg-background/60 px-3 py-2 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-ring transition" |
| 102 | + placeholder="e.g. 855798460593733652" |
| 103 | + /> |
| 104 | + </div> |
| 105 | + |
| 106 | + <div className="flex items-center justify-between gap-3"> |
| 107 | + <button |
| 108 | + type="submit" |
| 109 | + className="inline-flex items-center justify-center px-4 py-2 text-sm font-medium rounded-lg bg-foreground text-background hover:bg-foreground/90 transition-colors" |
| 110 | + > |
| 111 | + Verify |
| 112 | + </button> |
| 113 | + |
| 114 | + {result !== null && ( |
| 115 | + <p className={`text-xs font-medium tracking-wide ${statusColor}`}> |
| 116 | + {result} |
| 117 | + </p> |
| 118 | + )} |
| 119 | + </div> |
| 120 | + </form> |
| 121 | + |
| 122 | + <p className="mt-3 text-[11px] text-muted-foreground text-center"> |
| 123 | + Always use common sense. |
| 124 | + </p> |
| 125 | + <p className="text-[11px] text-muted-foreground text-center"> |
| 126 | + Only use Discord IDs you obtain by yourself. |
| 127 | + </p> |
| 128 | + |
| 129 | + {showHowModal && ( |
| 130 | + <div |
| 131 | + className="fixed inset-0 z-40 flex items-center justify-center bg-black/60" |
| 132 | + onClick={closeModal} |
| 133 | + > |
| 134 | + <div |
| 135 | + className="w-full max-w-md rounded-xl border border-border bg-card p-4 space-y-3" |
| 136 | + onClick={(e) => e.stopPropagation()} |
| 137 | + > |
| 138 | + <div className="flex items-center justify-between"> |
| 139 | + <h2 className="text-sm font-semibold"> |
| 140 | + Getting a Discord user ID |
| 141 | + </h2> |
| 142 | + <button |
| 143 | + type="button" |
| 144 | + onClick={closeModal} |
| 145 | + className="text-xs text-muted-foreground hover:text-foreground" |
| 146 | + > |
| 147 | + Close |
| 148 | + </button> |
| 149 | + </div> |
| 150 | + |
| 151 | + <div className="space-y-2 text-sm text-muted-foreground"> |
| 152 | + <ol className="list-decimal list-inside space-y-1"> |
| 153 | + <li> |
| 154 | + Open Discord settings > Advanced and enable |
| 155 | + <span className="font-medium"> Developer Mode</span>. |
| 156 | + </li> |
| 157 | + <li> |
| 158 | + Right‑click the user's name or avatar (or long‑press on |
| 159 | + mobile) and choose |
| 160 | + <span className="font-medium"> Copy User ID</span>. |
| 161 | + </li> |
| 162 | + <li> |
| 163 | + Paste that numeric ID here to verify you are talking to the |
| 164 | + correct account. |
| 165 | + </li> |
| 166 | + </ol> |
| 167 | + </div> |
| 168 | + </div> |
| 169 | + </div> |
| 170 | + )} |
| 171 | + </div> |
| 172 | + </main> |
| 173 | + ); |
| 174 | +} |
0 commit comments