import {apiFetch} from './api_client.js';
async function handleSubmit(e){
    e.preventDefault();
    const identifier=document.getElementById('identifier').value;
    const password=document.getElementById('password').value;
    const res = await fetch('/api/auth/login.php',{method:'POST',body:JSON.stringify({identifier,password})});
    const j = await res.json();
    if (res.ok){ localStorage.setItem('atulya_token', j.token); const role=j.role; if(role==='Admin') window.location='/admin/dashboard.php'; else window.location='/pwa/index.html'; }
    else alert(j.error || 'Login failed');
}
window.handleSubmit = handleSubmit;
