prije gemini provjere
This commit is contained in:
32
001.FRONTEND/src/components/auth/AuthStatus.jsx
Normal file
32
001.FRONTEND/src/components/auth/AuthStatus.jsx
Normal file
@@ -0,0 +1,32 @@
|
||||
// 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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user