Files
qr_vitanova/src/app/fastcheck.service.ts
2026-05-05 11:23:07 +04:00

29 lines
739 B
TypeScript

import { Injectable, signal } from '@angular/core';
export interface FastcheckData {
fastcheck: string;
amount: number | null;
code: string;
expiration?: string;
}
/**
* Shared state between the home (Fastcheck) page and the create-new page.
* When a new fastcheck is created via POST /fastcheck, the create page stores
* the returned data here and the home page reads it to autofill its fields.
*/
@Injectable({ providedIn: 'root' })
export class FastcheckService {
readonly created = signal<FastcheckData | null>(null);
setCreated(data: FastcheckData): void {
this.created.set(data);
}
consume(): FastcheckData | null {
const value = this.created();
this.created.set(null);
return value;
}
}