32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
// src/components/auth/AuthStatus.jsx
|
|
import { h } from 'preact';
|
|
import { useStore } from '@nanostores/preact';
|
|
import { $currentUser, logoutKorisnika } from '../../stores/appState'; // 🚀 Uvozimo i atom i akciju
|
|
import Button from '../Button.jsx';
|
|
|
|
export default function AuthStatus() {
|
|
const currentUser = useStore($currentUser);
|
|
const isLoggedIn = !!currentUser;
|
|
|
|
return isLoggedIn ? (
|
|
<Button
|
|
variant="danger"
|
|
onClick={logoutKorisnika} // 🚀 DRY: Samo pozivamo spremnu funkciju
|
|
class="!py-2 !px-4 uppercase text-[10px] tracking-widest italic font-black flex items-center space-x-2"
|
|
>
|
|
<i class="fa-solid fa-user-gear mr-1 text-red-400"></i>
|
|
<span>
|
|
Logout ({currentUser.first_name ? `${currentUser.first_name}` : 'Servis'})
|
|
</span>
|
|
</Button>
|
|
) : (
|
|
<a href="/login" class="inline-block">
|
|
<Button
|
|
variant="primary"
|
|
class="!py-2 !px-4 uppercase text-[10px] tracking-widest italic font-black"
|
|
>
|
|
Prijava
|
|
</Button>
|
|
</a>
|
|
);
|
|
} |