29 lines
732 B
TypeScript
29 lines
732 B
TypeScript
import { Injectable, signal } from '@angular/core';
|
|
|
|
export interface FastcheckData {
|
|
fastcheck: string;
|
|
amount: number;
|
|
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;
|
|
}
|
|
}
|