11"use client" ;
22
3- import { signIn } from "@databuddy/auth/client" ;
3+ import { authClient , signIn } from "@databuddy/auth/client" ;
44import {
55 EyeIcon ,
66 EyeSlashIcon ,
@@ -12,7 +12,7 @@ import {
1212import Link from "next/link" ;
1313import { useRouter } from "next/navigation" ;
1414import { parseAsString , useQueryState } from "nuqs" ;
15- import { Suspense , useEffect , useState } from "react" ;
15+ import { Suspense , useState } from "react" ;
1616import { toast } from "sonner" ;
1717import { Badge } from "@/components/ui/badge" ;
1818import { Button } from "@/components/ui/button" ;
@@ -30,13 +30,9 @@ function LoginPage() {
3030 const [ email , setEmail ] = useState ( "" ) ;
3131 const [ password , setPassword ] = useState ( "" ) ;
3232 const [ showPassword , setShowPassword ] = useState ( false ) ;
33- const [ lastUsed , setLastUsed ] = useState < string | null > ( null ) ;
3433
3534 const defaultCallbackUrl = callback ;
36-
37- useEffect ( ( ) => {
38- setLastUsed ( localStorage . getItem ( "lastUsedLogin" ) ) ;
39- } , [ ] ) ;
35+ const lastUsed = authClient . getLastUsedLoginMethod ( ) ;
4036
4137 const handleSocialLogin = ( provider : "github" | "google" ) => {
4238 setIsLoading ( true ) ;
@@ -50,7 +46,6 @@ function LoginPage() {
5046 newUserCallbackURL : "/onboarding" ,
5147 fetchOptions : {
5248 onSuccess : ( ) => {
53- localStorage . setItem ( "lastUsedLogin" , provider ) ;
5449 if ( callbackUrl ) {
5550 router . push ( callbackUrl ) ;
5651 }
@@ -80,7 +75,6 @@ function LoginPage() {
8075 callbackURL : defaultCallbackUrl ,
8176 fetchOptions : {
8277 onSuccess : ( ) => {
83- localStorage . setItem ( "lastUsedLogin" , "email" ) ;
8478 const callbackUrl = callback ;
8579 if ( callbackUrl ) {
8680 router . push ( callbackUrl ) ;
@@ -172,7 +166,7 @@ function LoginPage() {
172166 Sign in with Magic Link
173167 </ Link >
174168 </ Button >
175- { lastUsed === "magic" && (
169+ { lastUsed === "magic-link " && (
176170 < Badge
177171 className = "-top-3 -right-0.5 absolute z-10 rounded-full px-1 py-0 text-[10px]"
178172 variant = "secondary"
0 commit comments