mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-27 22:25:58 +02:00
added signup and verify email forms
This commit is contained in:
parent
41cbde1474
commit
f3eb76fd5e
14 changed files with 882 additions and 11 deletions
|
@ -22,10 +22,10 @@ import {
|
|||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";
|
||||
import { LoginResponse } from "@server/routers/auth";
|
||||
import { api } from "@app/api";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { AxiosResponse } from "axios";
|
||||
|
||||
type LoginFormProps = {
|
||||
redirect?: string;
|
||||
|
@ -54,7 +54,7 @@ export default function LoginForm({ redirect }: LoginFormProps) {
|
|||
async function onSubmit(values: z.infer<typeof formSchema>) {
|
||||
const { email, password } = values;
|
||||
const res = await api
|
||||
.post<LoginResponse>("/auth/login", {
|
||||
.post<AxiosResponse<LoginResponse>>("/auth/login", {
|
||||
email,
|
||||
password,
|
||||
})
|
||||
|
@ -68,6 +68,14 @@ export default function LoginForm({ redirect }: LoginFormProps) {
|
|||
|
||||
if (res && res.status === 200) {
|
||||
setError(null);
|
||||
|
||||
console.log(res)
|
||||
|
||||
if (res.data?.data?.emailVerificationRequired) {
|
||||
router.push("/auth/verify-email");
|
||||
return;
|
||||
}
|
||||
|
||||
if (redirect && typeof redirect === "string") {
|
||||
window.location.href = redirect;
|
||||
} else {
|
||||
|
@ -79,7 +87,7 @@ export default function LoginForm({ redirect }: LoginFormProps) {
|
|||
return (
|
||||
<Card className="w-full max-w-md mx-auto">
|
||||
<CardHeader>
|
||||
<CardTitle>Secure Login</CardTitle>
|
||||
<CardTitle>Login</CardTitle>
|
||||
<CardDescription>
|
||||
Enter your credentials to access your dashboard
|
||||
</CardDescription>
|
||||
|
@ -124,8 +132,7 @@ export default function LoginForm({ redirect }: LoginFormProps) {
|
|||
)}
|
||||
/>
|
||||
{error && (
|
||||
<Alert variant="destructive">
|
||||
<ExclamationTriangleIcon className="h-4 w-4" />
|
||||
<Alert>
|
||||
<AlertDescription>{error}</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue