import { useState } from 'react'; import { Box, Button, Select, Text, TextInput, Alert, Group, Stack } from '@mantine/core'; import { apiClient } from '../../api/client'; const font = "'Montserrat', Arial, sans-serif"; const teal = '#008286'; const ROLES = [ { value: 'hr_admin', label: 'HR Admin' }, { value: 'hr_specialist', label: 'HR Specialist' }, { value: 'nursing_director', label: 'Nursing Director' }, { value: 'quality_auditor', label: 'Quality Auditor' }, { value: 'manager', label: 'Manager' }, { value: 'medic_familie', label: 'Medic Familie' }, { value: 'employee', label: 'Angajat' }, ]; interface Props { onLogin: () => void; } export function LoginPage({ onLogin }: Props) { const [username, setUsername] = useState('admin'); const [role, setRole] = useState('hr_admin'); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleLogin = async () => { setLoading(true); setError(null); try { const res = await apiClient.post<{ token: string; username: string; role: string }>( '/auth/dev-login', { username, role }, ); localStorage.setItem('kc_token', res.data.token); localStorage.setItem('kc_username', res.data.username); localStorage.setItem('kc_role', res.data.role); onLogin(); } catch { setError('Nu s-a putut autentifica. Verificați că API-ul rulează.'); } finally { setLoading(false); } }; return ( {/* Logo */} Medpark International Hospital { (e.target as HTMLImageElement).style.display = 'none'; }} /> HRM — Sistem de management HR Mod dezvoltare — autentificare locală {error && ( {error} )} setUsername(e.currentTarget.value)} placeholder="admin" styles={{ label: { fontFamily: font, fontWeight: 500, fontSize: '0.8rem' }, input: { fontFamily: font }, }} />