daphnis/app/(password-reset)/password-reset/[token]/page.tsx
2024-06-29 01:22:22 -04:00

46 lines
1.5 KiB
TypeScript

"use client";
import Link from "next/link";
import { useState } from "react";
import { ArrowLeft } from "lucide-react";
import { Card } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { resetPassword } from "./token";
export default function ({ params }: { params: { token: string } }) {
const [error, setError] = useState<string>("");
async function submit(data: FormData) {
const { error } = await resetPassword(params.token, data);
setError(error || "");
}
return (
<main className="max-w-xl px-4 mx-auto flex flex-col justify-center h-screen ">
<Card className="gap-4 flex flex-col p-6 ">
<form action={submit} className="flex flex-col gap-4">
{" "}
<h1 className="text-2xl font-light">Choose a new password</h1>
<p>You can reset your password here.</p>
<Input name="password" type="password" placeholder="Password" />
<Input
name="confirm"
type="password"
placeholder="Confirm password"
/>
{error && <p className="text-red-500 text-sm">{error}</p>}
<Button type="submit">Reset Password</Button>
<Link
href="/"
className="text-sm text-neutral-700/80 flex items-center"
>
<ArrowLeft />
<span>Return to Login</span>
</Link>
</form>
</Card>
</main>
);
}