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
@@ -18,7 +18,7 @@
<div class="">
<p-menu #menu [model]="profileMenuItems" [popup]="true" />
<button pButton (click)="menu.toggle($event)" icon="pi pi-user" severity="contrast">
{{ userInfo()?.username }}
{{ posProfile()?.account?.username }}
</button>
</div>
</div>
@@ -8,7 +8,8 @@ import { ButtonDirective } from 'primeng/button';
import { Card } from 'primeng/card';
import { Menu } from 'primeng/menu';
import images from 'src/assets/images';
import { PosStore } from '../pos.store';
import { PosProfileStore } from '../store';
import { PosStore } from '../store/pos.store';
import { PosChooseCardsComponent } from './choose-pos.component';
@Component({
@@ -27,13 +28,19 @@ import { PosChooseCardsComponent } from './choose-pos.component';
export class PosLayoutComponent {
constructor() {}
private readonly store = inject(PosStore);
private readonly posInfoStore = inject(PosStore);
private readonly posProfileStore = inject(PosProfileStore);
private readonly authService = inject(AuthService);
readonly loading = computed(() => this.store.loading());
readonly posInfo = computed(() => this.store.entity());
readonly error = computed(() => this.store.error());
readonly userInfo = computed(() => this.authService.currentAccount());
readonly posInfoLoading = computed(() => this.posInfoStore.loading());
readonly posInfo = computed(() => this.posInfoStore.entity());
readonly posInfoError = computed(() => this.posInfoStore.error());
readonly posProfileLoading = computed(() => this.posProfileStore.loading());
readonly posProfile = computed(() => this.posProfileStore.entity());
readonly posProfileError = computed(() => this.posProfileStore.error());
readonly loading = computed(() => this.posInfoLoading() || this.posProfileLoading());
readonly error = computed(() => this.posInfoError() || this.posProfileError());
logout = () => {
this.authService.logout();
@@ -57,7 +64,8 @@ export class PosLayoutComponent {
now = new Date();
getData() {
this.store.getData().subscribe();
this.posProfileStore.getData().subscribe();
this.posInfoStore.getData().subscribe();
}
onChoosePos() {
+3
View File
@@ -0,0 +1,3 @@
export * from './good.io';
export * from './pos.io';
export * from './profile.io';
+1 -1
View File
@@ -1,7 +1,7 @@
import ISummary from '@/core/models/summary';
export interface IPosInfoRawResponse {
name: true;
name: string;
complex: {
id: string;
name: string;
+17
View File
@@ -0,0 +1,17 @@
import ISummary from '@/core/models/summary';
export interface IPosProfileRawResponse {
id: string;
role: string;
account: { username: string };
consumer: {
first_name: string;
last_name: string;
};
}
export interface IPosProfileResponse extends IPosProfileRawResponse {}
interface Complex extends ISummary {
business_activity: ISummary;
}
@@ -1,6 +1,7 @@
const baseUrl = '/api/v1/pos';
export const POS_API_ROUTES = {
profile: () => `${baseUrl}/me`,
info: () => `${baseUrl}`,
accessible: () => `${baseUrl}/accessible`,
goods: () => `${baseUrl}/goods`,
@@ -5,9 +5,6 @@ export interface IGoldPayload {
wages: number;
profit: number;
commission: number;
// wages_amount: number;
// profit_amount: number;
// commission_amount: number;
}
export interface IStandardPayload {}
@@ -11,6 +11,7 @@ import {
IPosInfoRawResponse,
IPosInfoResponse,
} from '@/domains/pos/models/pos.io';
import { IPosProfileRawResponse, IPosProfileResponse } from '@/domains/pos/models/profile.io';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@@ -23,6 +24,10 @@ export class PosService {
private apiRoutes = POS_API_ROUTES;
getProfile(): Observable<IPosProfileResponse> {
return this.http.get<IPosProfileRawResponse>(this.apiRoutes.profile());
}
getInfo(): Observable<IPosInfoResponse> {
return this.http.get<IPosInfoRawResponse>(this.apiRoutes.info());
}
@@ -1,5 +1,5 @@
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { PosStore } from '@/domains/pos/pos.store';
import { PosStore } from '@/domains/pos/store/pos.store';
import { Component, computed, inject } from '@angular/core';
import { PosGoodsComponent } from '../components/goods.component';
import { PosOrderSectionComponent } from '../components/order/order-section.component';
+2
View File
@@ -0,0 +1,2 @@
export * from './me.store';
export * from './pos.store';
+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,
});
}
}
@@ -4,8 +4,8 @@ import { computed, inject, Injectable } from '@angular/core';
import { CookieService } from 'ngx-cookie-service';
import { catchError, finalize, map } from 'rxjs';
import { COOKIE_KEYS } from 'src/assets/constants';
import { IPosInfoResponse } from './models/pos.io';
import { PosService } from './modules/landing/services/main.service';
import { IPosInfoResponse } from '../models/pos.io';
import { PosService } from '../modules/landing/services/main.service';
interface PosState extends EntityState<IPosInfoResponse> {
posId: string;