fosrl.pangolin/src/app/auth/login/DashboardLoginForm.tsx

78 lines
2.3 KiB
TypeScript
Raw Normal View History

"use client";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle
} from "@/components/ui/card";
2025-01-01 21:41:31 -05:00
import { createApiClient } from "@app/lib/api";
2025-04-18 17:45:59 -04:00
import LoginForm, { LoginFormIDP } from "@app/components/LoginForm";
import { useEnvContext } from "@app/hooks/useEnvContext";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
2025-01-04 20:22:01 -05:00
import Image from "next/image";
import { cleanRedirect } from "@app/lib/cleanRedirect";
type DashboardLoginFormProps = {
redirect?: string;
2025-04-18 17:45:59 -04:00
idps?: LoginFormIDP[];
};
export default function DashboardLoginForm({
2025-04-18 17:45:59 -04:00
redirect,
idps
}: DashboardLoginFormProps) {
const router = useRouter();
// const api = createApiClient(useEnvContext());
//
// useEffect(() => {
// const logout = async () => {
// try {
// await api.post("/auth/logout");
// console.log("user logged out");
// } catch (e) {}
// };
//
// logout();
// });
return (
2024-11-23 20:08:56 -05:00
<Card className="w-full max-w-md">
<CardHeader>
2025-01-04 20:22:01 -05:00
<div className="flex flex-row items-center justify-center">
<Image
src={`/logo/pangolin_orange.svg`}
alt="Pangolin Logo"
2025-05-29 12:09:44 -04:00
width={100}
height={100}
2025-01-04 20:22:01 -05:00
/>
</div>
<div className="text-center space-y-1">
<h1 className="text-2xl font-bold mt-1">
Welcome to Pangolin
</h1>
2025-04-18 17:45:59 -04:00
<p className="text-sm text-muted-foreground">
Log in to get started
</p>
2025-01-04 20:22:01 -05:00
</div>
</CardHeader>
<CardContent>
<LoginForm
redirect={redirect}
2025-04-18 17:45:59 -04:00
idps={idps}
2024-11-28 00:11:13 -05:00
onLogin={() => {
if (redirect) {
const safe = cleanRedirect(redirect);
router.push(safe);
2024-11-28 00:11:13 -05:00
} else {
router.push("/");
}
}}
/>
</CardContent>
</Card>
);
}