-เชื่อมโยง api search กับ frontend
-ปรับปรุงระบบ state -เพิ่ม ระบบ pipe dtmtodatetime
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { IDropAct, IStateDrop } from '../../interfaces/dashboard.interface';
|
||||
import { IDropAct, IStateDrop, IActData } from '../../interfaces/dashboard.interface';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -8,6 +8,7 @@ import { IDropAct, IStateDrop } from '../../interfaces/dashboard.interface';
|
||||
export class DashboardStateService {
|
||||
// ประกาศ BehaviorSubject ด้วย Interface
|
||||
private dashboardState = new BehaviorSubject<IStateDrop | null>(null);
|
||||
private accountting = new BehaviorSubject<IActData[] | null>(null);
|
||||
|
||||
// ส่ง Observable ไปให้ components subscribe
|
||||
getStateResult(): Observable<IStateDrop | null> {
|
||||
@@ -15,8 +16,13 @@ export class DashboardStateService {
|
||||
}
|
||||
|
||||
// เซ็ท state
|
||||
setStateResult(product: IStateDrop): void {
|
||||
this.dashboardState.next(product);
|
||||
setStateResult(dashboard: IStateDrop): void {
|
||||
this.dashboardState.next(dashboard);
|
||||
}
|
||||
|
||||
|
||||
setStateAccountResult(dashboard: IActData[]): void {
|
||||
this.accountting.next(dashboard);
|
||||
}
|
||||
|
||||
// เคลียร์ state
|
||||
@@ -24,8 +30,12 @@ export class DashboardStateService {
|
||||
this.dashboardState.next(null);
|
||||
}
|
||||
|
||||
getStateAccountResult(): Observable<IActData[] | null> {
|
||||
return this.accountting.asObservable();
|
||||
}
|
||||
|
||||
// ดึงค่า current state (ไม่ใช่ observable)
|
||||
// getCurrentState(): IDropAct | null {
|
||||
// return this.productState.value;
|
||||
// return this.dashboardState.value;
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user