Spaces:
Sleeping
Sleeping
Download frontend/src/components/stillwave/AuthForm.tsx from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 4.97 kB
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/frontend/src/components/stillwave/AuthForm.tsx
- Command line
-
hf download hf://spaces/kishankrish19/Chat/frontend/src/components/stillwave/AuthForm.tsx
-
curl -L -o AuthForm.tsx https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/frontend/src/components/stillwave/AuthForm.tsx
4.97 kB
| "use client"; | |
| import { useState } from "react"; | |
| import { useRouter } from "next/navigation"; | |
| import Link from "next/link"; | |
| import { AudioLines, ArrowRight, Leaf } from "lucide-react"; | |
| import { api } from "@/lib/api/apiClient"; | |
| export default function AuthForm({ signup = false }: { signup?: boolean }) { | |
| const router = useRouter(), | |
| [email, setEmail] = useState(""), | |
| [password, setPassword] = useState(""), | |
| [name, setName] = useState(""), | |
| [username, setUsername] = useState(""), | |
| [error, setError] = useState(""), | |
| [busy, setBusy] = useState(false); | |
| return ( | |
| <div className="auth-page"> | |
| <Link href="/" className="brand"> | |
| <span className="brand-mark"> | |
| <AudioLines size={22} /> | |
| </span> | |
| stillwave. | |
| </Link> | |
| <div className="auth-grid"> | |
| <div className="auth-copy"> | |
| <span className="eyebrow">YOUR MUSIC. YOUR MOMENT.</span> | |
| <h1> | |
| A little less noise. | |
| <br />A little more you. | |
| </h1> | |
| <p> | |
| A thoughtful home for the songs you love, and the ones you haven’t | |
| met yet. | |
| </p> | |
| <div className="auth-decoration"> | |
| <div className="hero-disc"> | |
| <div className="disc-grooves" /> | |
| <div className="disc-label"> | |
| <Leaf size={30} /> | |
| <span>STILLWAVE</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <form | |
| className="auth-card" | |
| onSubmit={async (e) => { | |
| e.preventDefault(); | |
| setBusy(true); | |
| setError(""); | |
| try { | |
| if (signup) | |
| await api.signup({ | |
| email: email.trim(), | |
| password, | |
| username: username.trim(), | |
| display_name: name.trim(), | |
| }); | |
| else await api.login({ email: email.trim(), password }); | |
| await api.getMe(); | |
| router.replace("/"); | |
| router.refresh(); | |
| } catch (e) { | |
| setError((e as Error).message); | |
| } finally { | |
| setBusy(false); | |
| } | |
| }} | |
| > | |
| <span className="eyebrow"> | |
| {signup ? "COME ON IN" : "WELCOME BACK"} | |
| </span> | |
| <h2> | |
| {signup ? "Make yourself at home." : "Your music is waiting."} | |
| </h2> | |
| <p> | |
| {signup | |
| ? "Create your own quiet corner." | |
| : "Sign in and pick up where you left off."} | |
| </p> | |
| {error && ( | |
| <div className="notice error" role="alert"> | |
| {error} | |
| </div> | |
| )} | |
| {signup && ( | |
| <> | |
| <label className="field"> | |
| Your name | |
| <input | |
| autoComplete="name" | |
| required | |
| maxLength={100} | |
| value={name} | |
| onChange={(e) => setName(e.target.value)} | |
| placeholder="What should we call you?" | |
| /> | |
| </label> | |
| <label className="field"> | |
| Username | |
| <input | |
| autoComplete="username" | |
| required | |
| minLength={3} | |
| maxLength={30} | |
| value={username} | |
| onChange={(e) => setUsername(e.target.value)} | |
| placeholder="A name of your own" | |
| /> | |
| </label> | |
| </> | |
| )} | |
| <label className="field"> | |
| Email address | |
| <input | |
| type="email" | |
| autoComplete="email" | |
| required | |
| value={email} | |
| onChange={(e) => setEmail(e.target.value)} | |
| placeholder="you@example.com" | |
| /> | |
| </label> | |
| <label className="field"> | |
| Password | |
| <input | |
| type="password" | |
| autoComplete={signup ? "new-password" : "current-password"} | |
| required | |
| minLength={signup ? 8 : 1} | |
| maxLength={72} | |
| value={password} | |
| onChange={(e) => setPassword(e.target.value)} | |
| placeholder={signup ? "At least 8 characters" : "Your password"} | |
| /> | |
| </label> | |
| <button className="button full" disabled={busy}> | |
| {busy ? "Just a moment…" : signup ? "Create account" : "Sign in"} | |
| <ArrowRight size={17} /> | |
| </button> | |
| <p className="auth-switch"> | |
| {signup ? "Already at home here?" : "New to Stillwave?"}{" "} | |
| <Link href={signup ? "/login" : "/signup"}> | |
| {signup ? "Sign in" : "Make an account"} | |
| </Link> | |
| </p> | |
| </form> | |
| </div> | |
| <p className="auth-footer">Take your time. The music will be here.</p> | |
| </div> | |
| ); | |
| } | |