feat: update app version in ngsw-config.json; refactor input component for leading zero normalization and improve payment dialog handling

This commit is contained in:
2026-05-16 20:17:26 +03:30
parent fda318add5
commit 29c5c50d62
8 changed files with 90 additions and 54 deletions
@@ -119,6 +119,15 @@ export class PosPagesLayoutComponent {
this.layoutService.setTopbarEndSlot(this.topbarEnd);
}
// ngAfterViewInit() {
// // @ts-ignore
// window.WebV = {
// onPaymentResult: (payload: unknown) => {
// console.log('payload', payload);
// },
// };
// }
ngOnDestroy() {
this.layoutService.changeIsFullPage(false);
this.layoutService.setTopbarStartSlot(null);
@@ -31,16 +31,16 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
IPosOrderItem<IGoldPayload>,
IPosOrderItem<IGoldPayload>
> {
// override defaultValues: Partial<IPosOrderItem<IGoldPayload>> = {
// unit_price: 200_000_000,
// quantity: 2,
// payload: {
// commission: 10_000,
// wages: 10_000,
// profit: 10_000,
// karat: '18' as TGoldKarat,
// } as any,
// };
override defaultValues: Partial<IPosOrderItem<IGoldPayload>> = {
unit_price: 200_000_000,
quantity: 2,
payload: {
// commission: 10_000,
// wages: 10_000,
// profit: 10_000,
karat: 'KARAT_18' as TGoldKarat,
} as any,
};
@Output() onSubmitForm = new EventEmitter<IGoldPayload>();
@Output() onChangeTotalAmount = new EventEmitter<number>();
@@ -27,6 +27,6 @@
[discountAmount]="discountAmount()"
[taxAmount]="taxAmount()"
/>
<p-button class="sm:w-auto w-full" (onClick)="submit()"> {{ preparedCTAText() }} </p-button>
<button pButton class="sm:w-auto w-full" (onClick)="submit()">{{ preparedCTAText() }}</button>
</div>
</form>
@@ -6,7 +6,7 @@ import { formatWithCurrency } from '@/utils';
import { Component, computed, EventEmitter, Input, Output, signal } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { Button } from 'primeng/button';
import { ButtonDirective } from 'primeng/button';
import { IPosOrderItem, IStandardPayload } from '../../../models';
import { PosFormDialogAmountCardTemplateComponent } from '../form-dialog-amount-card-template.component';
@@ -16,9 +16,9 @@ import { PosFormDialogAmountCardTemplateComponent } from '../form-dialog-amount-
imports: [
ReactiveFormsModule,
InputComponent,
Button,
PosFormDialogAmountCardTemplateComponent,
AmountPercentageInputComponent,
ButtonDirective,
],
})
export class PosStandardPayloadFormComponent extends AbstractForm<
@@ -57,12 +57,16 @@ export class PosPaymentFormDialogComponent extends AbstractFormDialog<IPayment,
payedInTerminal = signal<Array<number>>([]);
private restorePaymentCallback: Maybe<() => void> = null;
private readonly injectedPaymentResultHandler = (payload: unknown) => {
alert('پرداخت با موفقیت انجام شد');
this.toastServices.success({ text: 'شد شد شد شد شد' });
// this.handlePaymentResult(payload);
};
ngOnViewInit() {
ngAfterViewInit() {
console.log('ngOnViewInit');
this.restorePaymentCallback = this.paymentBridge.registerPaymentResultListener(
this.injectedPaymentResultHandler,
);
@@ -1,36 +1,33 @@
import { Injectable } from '@angular/core';
import { ToastService } from '@/core/services/toast.service';
import { inject, Injectable } from '@angular/core';
import { PosPaymentBridgeAbstract } from './payment-bridge.abstract';
@Injectable({ providedIn: 'root' })
export class PosPaymentBridgeService extends PosPaymentBridgeAbstract {
private readonly toastServices = inject(ToastService);
registerPaymentResultListener(handler: (payload: unknown) => void): () => void {
const w = window as unknown as {
WebV: {
onPaymentResult?: (payload: unknown) => void;
AndroidBridge?: {
onPaymentResult?: (payload: unknown) => void;
};
};
// const w = window as unknown as {
// WebV?: {
// onPaymentResult?: (payload: unknown) => void;
// AndroidBridge?: {
// onPaymentResult?: (payload: unknown) => void;
// };
// };
// };
this.toastServices.error({ text: '@@@@@@@@@@@@@' });
// @ts-ignore
window.webV = {
onPaymentResult: () => {
this.toastServices.error({ text: 'asdasdsadassadasdas' });
},
};
const previousGlobal = w.WebV.onPaymentResult;
const previousBridge = w.WebV.AndroidBridge?.onPaymentResult;
w.WebV.onPaymentResult = handler;
if (w.WebV.AndroidBridge) {
w.WebV.AndroidBridge.onPaymentResult = handler;
}
return () => {
w.WebV.onPaymentResult = previousGlobal;
if (w.WebV.AndroidBridge) {
w.WebV.AndroidBridge.onPaymentResult = previousBridge;
}
};
return () => {};
}
emitPaymentResultForTest(payload: unknown): void {
const w = window as unknown as { WebV: { onPaymentResult?: (payload: unknown) => void } };
w.WebV.onPaymentResult?.(payload);
const w = window as unknown as { WebV?: { onPaymentResult?: (payload: unknown) => void } };
w.WebV?.onPaymentResult?.(payload);
}
}