diff --git a/sigap-website/app/(pages)/(admin)/dashboard/page.tsx b/sigap-website/app/(pages)/(admin)/dashboard/page.tsx index 73f05a1..9802361 100644 --- a/sigap-website/app/(pages)/(admin)/dashboard/page.tsx +++ b/sigap-website/app/(pages)/(admin)/dashboard/page.tsx @@ -6,10 +6,10 @@ export default async function DashboardPage() { const supabase = await createClient(); const { - data: { user }, - } = await supabase.auth.getUser(); + data: { session }, + } = await supabase.auth.getSession(); - if (!user) { + if (!session) { return redirect("/sign-in"); } @@ -20,7 +20,7 @@ export default async function DashboardPage() {
-              {JSON.stringify(user, null, 2)}
+              {JSON.stringify(session, null, 2)}
             
diff --git a/sigap-website/app/(pages)/(auth)/_components/signin-form.tsx b/sigap-website/app/(pages)/(auth)/_components/signin-form.tsx index 7e92a6e..174900c 100644 --- a/sigap-website/app/(pages)/(auth)/_components/signin-form.tsx +++ b/sigap-website/app/(pages)/(auth)/_components/signin-form.tsx @@ -8,13 +8,33 @@ import { SubmitButton } from "@/app/_components/submit-button"; import Link from "next/link"; import { FormField } from "@/app/_components/form-field"; import { useSignInController } from "@/src/interface-adapters/controllers/auth/sign-in-controller"; +import { useState } from "react"; +import { signIn } from "../action"; export function SignInForm({ className, ...props }: React.ComponentPropsWithoutRef<"form">) { - const { register, isPending, handleSubmit, errors } = useSignInController(); + const [error, setError] = useState(); + const [loading, setLoading] = useState(false); + + const onSubmit = async (event: React.FormEvent) => { + event.preventDefault(); + if (loading) return; + + const formData = new FormData(event.currentTarget); + + setLoading(true); + const res = await signIn(formData); + if (res && res.error) { + setError(res.error); + } + setLoading(false); + }; + + + // const { register, isPending, handleSubmit, errors } = useSignInController(); return (
@@ -41,7 +61,7 @@ export function SignInForm({ variant="outline" className="w-full bg-[#1C1C1C] text-white border-gray-800 hover:bg-[#2C2C2C] hover:border-gray-700" size="lg" - disabled={isPending} + disabled={loading} > Continue with SSO @@ -57,28 +77,28 @@ export function SignInForm({
-
+ } - error={errors.email ? errors.email.message : undefined} + error={error ? error : undefined} />