This commit is contained in:
2026-04-23 01:22:44 +03:30
parent e027b89173
commit 57f333f5b8
43 changed files with 16222 additions and 2847 deletions
+49
View File
@@ -0,0 +1,49 @@
import { defaultBaseStateData, EntityState, EntityStore } from '@/core/state';
import { HttpErrorResponse } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { catchError, finalize, map } from 'rxjs';
import { IPosProfileResponse } from '../models';
import { PosService } from '../modules/landing/services/main.service';
interface PosProfileState extends EntityState<IPosProfileResponse> {}
@Injectable({
providedIn: 'root',
})
export class PosProfileStore extends EntityStore<IPosProfileResponse, PosProfileState> {
private readonly service = inject(PosService);
constructor() {
super({
...defaultBaseStateData,
});
}
getData() {
this.patchState({ loading: true });
return this.service.getProfile().pipe(
finalize(() => {
this.patchState({ loading: false });
}),
catchError((err: HttpErrorResponse) => {
this.setError(err);
// if (err.status === 403) debugger;
throw err;
}),
map((entity: IPosProfileResponse) => {
if (entity) {
this.setEntity(entity);
}
return entity;
}),
);
}
override reset(): void {
this.setState({
...defaultBaseStateData,
});
}
}