2026-03-29 18:07:10 +03:30
|
|
|
import { AuthService } from '@/core';
|
2026-05-06 22:01:20 +03:30
|
|
|
import { NativeBridgeService } from '@/core/services';
|
|
|
|
|
import { ToastService } from '@/core/services/toast.service';
|
2026-04-30 16:27:42 +03:30
|
|
|
import { LayoutService } from '@/layout/service/layout.service';
|
2026-03-18 13:35:57 +03:30
|
|
|
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
2026-04-30 16:27:42 +03:30
|
|
|
import {
|
|
|
|
|
AfterViewInit,
|
|
|
|
|
Component,
|
|
|
|
|
TemplateRef,
|
|
|
|
|
ViewChild,
|
|
|
|
|
computed,
|
|
|
|
|
inject,
|
|
|
|
|
signal,
|
|
|
|
|
} from '@angular/core';
|
2026-03-18 13:35:57 +03:30
|
|
|
import { RouterOutlet } from '@angular/router';
|
2026-04-13 13:22:40 +03:30
|
|
|
import { MenuItem } from 'primeng/api';
|
2026-04-30 16:27:42 +03:30
|
|
|
import { Button, ButtonDirective } from 'primeng/button';
|
2026-04-13 13:22:40 +03:30
|
|
|
import { Card } from 'primeng/card';
|
2026-05-05 22:42:06 +03:30
|
|
|
import { Menu } from 'primeng/menu';
|
2026-03-29 18:07:10 +03:30
|
|
|
import images from 'src/assets/images';
|
2026-04-25 15:19:19 +03:30
|
|
|
import { PosInfoStore, PosProfileStore } from '../store';
|
2026-04-13 13:22:40 +03:30
|
|
|
import { PosChooseCardsComponent } from './choose-pos.component';
|
2026-04-30 16:27:42 +03:30
|
|
|
import { PosMainMenuSidebarComponent } from './mainMenuSidebar/main-menu-sidebar.component';
|
2026-03-18 13:35:57 +03:30
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'pos-layout',
|
|
|
|
|
templateUrl: './layout.component.html',
|
2026-04-13 13:22:40 +03:30
|
|
|
imports: [
|
|
|
|
|
PageLoadingComponent,
|
|
|
|
|
RouterOutlet,
|
|
|
|
|
ButtonDirective,
|
|
|
|
|
Card,
|
|
|
|
|
PosChooseCardsComponent,
|
2026-04-30 16:27:42 +03:30
|
|
|
Button,
|
|
|
|
|
PosMainMenuSidebarComponent,
|
2026-05-05 22:42:06 +03:30
|
|
|
Menu,
|
2026-04-13 13:22:40 +03:30
|
|
|
],
|
2026-03-18 13:35:57 +03:30
|
|
|
})
|
2026-04-30 16:27:42 +03:30
|
|
|
export class PosLayoutComponent implements AfterViewInit {
|
2026-03-18 13:35:57 +03:30
|
|
|
constructor() {}
|
2026-05-06 22:01:20 +03:30
|
|
|
|
|
|
|
|
private readonly nativeBridgeService = inject(NativeBridgeService);
|
|
|
|
|
private readonly toastService = inject(ToastService);
|
|
|
|
|
|
2026-04-30 16:27:42 +03:30
|
|
|
@ViewChild('topbarStart', { static: true }) topbarStart!: TemplateRef<any>;
|
|
|
|
|
@ViewChild('topbarCenter', { static: true }) topbarCenter!: TemplateRef<any>;
|
|
|
|
|
@ViewChild('topbarEnd', { static: true }) topbarEnd!: TemplateRef<any>;
|
2026-03-18 13:35:57 +03:30
|
|
|
|
2026-04-23 01:22:44 +03:30
|
|
|
private readonly posProfileStore = inject(PosProfileStore);
|
2026-04-25 15:19:19 +03:30
|
|
|
private readonly posInfoStore = inject(PosInfoStore);
|
2026-03-29 18:07:10 +03:30
|
|
|
private readonly authService = inject(AuthService);
|
2026-04-30 16:27:42 +03:30
|
|
|
private readonly layoutService = inject(LayoutService);
|
|
|
|
|
|
|
|
|
|
mainMenuVisible = signal(false);
|
2026-03-18 13:35:57 +03:30
|
|
|
|
2026-04-23 01:22:44 +03:30
|
|
|
readonly posProfileLoading = computed(() => this.posProfileStore.loading());
|
|
|
|
|
readonly posProfile = computed(() => this.posProfileStore.entity());
|
|
|
|
|
readonly posProfileError = computed(() => this.posProfileStore.error());
|
|
|
|
|
|
2026-04-25 15:19:19 +03:30
|
|
|
readonly posInfoLoading = computed(() => this.posInfoStore.loading());
|
|
|
|
|
readonly posInfo = computed(() => this.posInfoStore.entity());
|
|
|
|
|
readonly posInfoError = computed(() => this.posInfoStore.error());
|
|
|
|
|
|
|
|
|
|
readonly loading = computed(() => this.posProfileLoading());
|
|
|
|
|
readonly error = computed(() => this.posProfileError());
|
2026-03-29 18:07:10 +03:30
|
|
|
|
2026-04-13 13:22:40 +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-25 15:19:19 +03:30
|
|
|
this.posProfileStore.getData().subscribe({
|
|
|
|
|
next: () => {
|
|
|
|
|
this.posInfoStore.getData().subscribe();
|
|
|
|
|
},
|
|
|
|
|
});
|
2026-03-18 13:35:57 +03:30
|
|
|
}
|
|
|
|
|
|
2026-04-30 16:27:42 +03:30
|
|
|
toggleMenu() {
|
|
|
|
|
this.mainMenuVisible.update((v) => !v);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-13 13:22:40 +03:30
|
|
|
onChoosePos() {
|
|
|
|
|
this.getData();
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-06 22:01:20 +03:30
|
|
|
doPay() {
|
2026-05-07 23:28:12 +03:30
|
|
|
// this.nativeBridgeService.pay({
|
|
|
|
|
// amount: 10_000,
|
|
|
|
|
// id: '1',
|
|
|
|
|
// });
|
|
|
|
|
this.nativeBridgeService.print({
|
|
|
|
|
title: 'salam',
|
|
|
|
|
items: [
|
|
|
|
|
{
|
|
|
|
|
label: 'مجموع قیمت',
|
|
|
|
|
value: '10_000',
|
|
|
|
|
},
|
|
|
|
|
],
|
2026-05-06 22:01:20 +03:30
|
|
|
});
|
2026-05-07 23:28:12 +03:30
|
|
|
// @ts-ignore
|
|
|
|
|
// window.NativeBridge.pay(12312, 'test');
|
2026-05-06 22:01:20 +03:30
|
|
|
}
|
|
|
|
|
|
2026-03-18 13:35:57 +03:30
|
|
|
ngOnInit() {
|
2026-04-30 16:27:42 +03:30
|
|
|
this.layoutService.changeIsFullPage(true);
|
2026-03-18 13:35:57 +03:30
|
|
|
this.getData();
|
|
|
|
|
}
|
2026-04-30 16:27:42 +03:30
|
|
|
|
|
|
|
|
ngAfterViewInit() {
|
|
|
|
|
this.layoutService.setTopbarStartSlot(this.topbarStart);
|
|
|
|
|
this.layoutService.setTopbarCenterSlot(this.topbarCenter);
|
|
|
|
|
this.layoutService.setTopbarEndSlot(this.topbarEnd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
2026-05-06 22:01:20 +03:30
|
|
|
this.layoutService.changeIsFullPage(false);
|
2026-04-30 16:27:42 +03:30
|
|
|
this.layoutService.setTopbarStartSlot(null);
|
|
|
|
|
this.layoutService.setTopbarCenterSlot(null);
|
|
|
|
|
this.layoutService.setTopbarEndSlot(null);
|
|
|
|
|
}
|
2026-05-06 22:01:20 +03:30
|
|
|
|
|
|
|
|
refresh() {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
}
|
2026-03-18 13:35:57 +03:30
|
|
|
}
|