fix : added print for login
This commit is contained in:
parent
f93bbe840f
commit
c319a96fb3
@ -240,6 +240,14 @@ async onSubmit(): Promise<void> {
|
||||
const btid = this.btcService.btid;
|
||||
console.log("📦 BTID from file (via service):", btid);
|
||||
|
||||
|
||||
const printData = {
|
||||
name: userName,
|
||||
employeeId: employeeId,
|
||||
action: 'login',
|
||||
type: 'login'
|
||||
};
|
||||
|
||||
// ✅ Store in localStorage
|
||||
localStorage.setItem('userName', userName);
|
||||
localStorage.setItem('employeeId', employeeId);
|
||||
@ -265,6 +273,26 @@ async onSubmit(): Promise<void> {
|
||||
this.loginError = "Could not load race card.";
|
||||
}
|
||||
});
|
||||
// ✅ Print first — login only if printing succeeds
|
||||
fetch('http://localhost:9100/print', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(printData),
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error('Print failed');
|
||||
console.log('🖨️ Print successful');
|
||||
|
||||
// ✅ Only here we allow login
|
||||
(window as any).electronAPI?.openSecondScreen?.();
|
||||
this.router.navigate(['/home']);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('‼️ Print failed', err);
|
||||
this.loginError = 'Login failed: printing service unavailable.';
|
||||
this.passwordStatus = false; // reset status
|
||||
});
|
||||
|
||||
},
|
||||
error: () => {
|
||||
this.loginError = 'Invalid login credentials';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user