2025-04-21 11:29:49 -05:00
|
|
|
// NOTE: This file is stable and usually should not be modified.
|
|
|
|
// It is important that all functionality in this file is preserved, and should only be modified if explicitly requested.
|
|
|
|
|
2025-04-18 15:36:58 -05:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
import { User } from 'lucide-react';
|
|
|
|
import { Button } from '@/components/ui/button.tsx';
|
|
|
|
import LoginDialog from './LoginDialog';
|
|
|
|
import SignupDialog from './SignupDialog';
|
|
|
|
import { useLoggedInAccounts } from '@/hooks/useLoggedInAccounts';
|
|
|
|
import { AccountSwitcher } from './AccountSwitcher';
|
|
|
|
|
|
|
|
export function LoginArea() {
|
|
|
|
const { currentUser } = useLoggedInAccounts();
|
|
|
|
const [loginDialogOpen, setLoginDialogOpen] = useState(false);
|
|
|
|
const [signupDialogOpen, setSignupDialogOpen] = useState(false);
|
|
|
|
|
|
|
|
const handleLogin = () => {
|
|
|
|
setLoginDialogOpen(false);
|
|
|
|
setSignupDialogOpen(false);
|
|
|
|
};
|
|
|
|
|
2025-04-18 15:39:03 -05:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{currentUser ? (
|
|
|
|
<AccountSwitcher onAddAccountClick={() => setLoginDialogOpen(true)} />
|
|
|
|
) : (
|
2025-04-18 15:36:58 -05:00
|
|
|
<Button
|
|
|
|
onClick={() => setLoginDialogOpen(true)}
|
|
|
|
className='flex items-center gap-2 px-4 py-2 rounded-full bg-primary text-primary-foreground w-full font-medium transition-all hover:bg-primary/90 animate-scale-in'
|
|
|
|
>
|
|
|
|
<User className='w-4 h-4' />
|
|
|
|
<span>Log in</span>
|
|
|
|
</Button>
|
2025-04-18 15:39:03 -05:00
|
|
|
)}
|
2025-04-18 15:36:58 -05:00
|
|
|
|
|
|
|
<LoginDialog
|
|
|
|
isOpen={loginDialogOpen}
|
|
|
|
onClose={() => setLoginDialogOpen(false)}
|
|
|
|
onLogin={handleLogin}
|
|
|
|
onSignup={() => setSignupDialogOpen(true)}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<SignupDialog
|
|
|
|
isOpen={signupDialogOpen}
|
|
|
|
onClose={() => setSignupDialogOpen(false)}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|