Files
psp_panel/src/app/domains/pos/layouts/layout.component.ts
T

79 lines
2.2 KiB
TypeScript
Raw Normal View History

2026-03-29 18:07:10 +03:30
import { AuthService } from '@/core';
2026-03-18 13:35:57 +03:30
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
2026-03-29 18:07:10 +03:30
import { JalaliDateDirective } from '@/shared/directives';
2026-03-18 13:35:57 +03:30
import { Component, computed, inject } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { MenuItem } from 'primeng/api';
import { ButtonDirective } from 'primeng/button';
import { Card } from 'primeng/card';
import { Menu } from 'primeng/menu';
2026-03-29 18:07:10 +03:30
import images from 'src/assets/images';
2026-04-23 01:22:44 +03:30
import { PosProfileStore } from '../store';
import { PosStore } from '../store/pos.store';
import { PosChooseCardsComponent } from './choose-pos.component';
2026-03-18 13:35:57 +03:30
@Component({
selector: 'pos-layout',
templateUrl: './layout.component.html',
imports: [
PageLoadingComponent,
RouterOutlet,
JalaliDateDirective,
Menu,
ButtonDirective,
Card,
PosChooseCardsComponent,
],
2026-03-18 13:35:57 +03:30
})
export class PosLayoutComponent {
constructor() {}
2026-04-23 01:22:44 +03:30
private readonly posInfoStore = inject(PosStore);
private readonly posProfileStore = inject(PosProfileStore);
2026-03-29 18:07:10 +03:30
private readonly authService = inject(AuthService);
2026-03-18 13:35:57 +03:30
2026-04-23 01:22:44 +03:30
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());
2026-03-29 18:07:10 +03:30
logout = () => {
this.authService.logout();
};
profileMenuItems: MenuItem[] = [
{
label: 'راهنمای سامانه',
icon: 'pi pi-question-circle',
disabled: true,
},
{
label: 'خروج',
icon: 'pi pi-sign-out',
command: this.logout,
},
];
2026-03-29 18:07:10 +03:30
placeholderLogo = images.placeholders.logo;
now = new Date();
2026-03-18 13:35:57 +03:30
getData() {
2026-04-23 01:22:44 +03:30
this.posProfileStore.getData().subscribe();
this.posInfoStore.getData().subscribe();
2026-03-18 13:35:57 +03:30
}
onChoosePos() {
this.getData();
}
2026-03-18 13:35:57 +03:30
ngOnInit() {
this.getData();
}
}