This commit is contained in:
x2Skyz
2025-11-25 21:11:57 +07:00
parent 291485f7b7
commit 368f2ef5e6
19 changed files with 1014 additions and 811 deletions

View File

@@ -1,32 +1,26 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { IProjectSearchResponse, ITransactionSearchResponse } from '../../interfaces/dashboard.interface';
import { IPrjMst } from '../../interfaces/main.interface';
@Injectable({
providedIn: 'root'
})
export class ProjectStateService {
private projectState = new BehaviorSubject<IProjectSearchResponse | null>(null);
private transactionState = new BehaviorSubject<ITransactionSearchResponse | null>(null);
// ประกาศ BehaviorSubject ด้วย Interface
private projectState = new BehaviorSubject<IPrjMst[] | null>(null);
getProjectState(): Observable<IProjectSearchResponse | null> {
// ส่ง Observable ไปให้ components subscribe
getStateResult(): Observable<IPrjMst[] | null> {
return this.projectState.asObservable();
}
setProjectState(project: IProjectSearchResponse): void {
this.projectState.next(project);
}
getTransactionState(): Observable<ITransactionSearchResponse | null> {
return this.transactionState.asObservable();
}
setTransactionState(transaction: ITransactionSearchResponse): void {
this.transactionState.next(transaction);
// เซ็ท state
setProjectState(projects: IPrjMst[]): void {
this.projectState.next(projects);
}
// เคลียร์ state
clearState(): void {
this.projectState.next(null);
this.transactionState.next(null);
}
}