feat: update consumer and partner components for improved data handling and UI enhancements
- Refactor ConsumerPosListComponent to dynamically set cookie domain based on hostname. - Modify ConsumerUserFormContentComponent to correctly handle type selection and initialization. - Enhance single.component.html to conditionally display consumer details based on type. - Update ConsumerAccountListComponent to include nested role translation and pos details. - Adjust IConsumerAccountRawResponse to use IEnumTranslate for role and add pos details. - Refine ConsumersComponent to display translated status in the list view. - Revise single.component.html for superAdmin to show translated consumer type and details. - Improve AdminPartnerChargeAccountListComponent and AdminPartnerChargeLicenseTransactionListComponent by updating header labels. - Add file upload functionality in form.component.html for partner creation. - Enhance GuildFormComponent to handle file uploads and form data submission. - Update AdminPartnerLicensesComponent to display consumer names correctly. - Modify IPartnerActivatedLicenseResponse to include consumer_name for better clarity. - Add logo_url to IPartnerRawResponse for displaying partner logos. - Refactor PartnersService to handle FormData for partner creation and updates. - Enhance list.component.html to include partner logos in the display. - Update single.component.html for partners to show total counts for licenses and users. - Implement payment result handling in AuthComponent for improved payment integration. - Refactor SharedUploadFileComponent to manage file previews and uploads more effectively. - Introduce IEnumTranslate interface for better type handling in consumer models. - Update form-data utility to allow skipping specific fields during FormData construction. - Add RTL support styles for file upload and avatar components. - Change environment configuration for API base URL.
This commit is contained in:
@@ -35,3 +35,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="w-screen h-screen flex items-center justify-center bg-red-400">
|
||||
<div class="bg-white p-8 rounded-lg shadow-md w-[520px]">
|
||||
<h1 class="text-2xl font-bold mb-4">Auth Page</h1>
|
||||
<p class="mb-4">WebView payment listener test</p>
|
||||
<div class="flex gap-3 mb-4">
|
||||
<button pButton outlined class="mx-auto" (click)="pay()">pay</button>
|
||||
<button pButton outlined class="mx-auto" (click)="mockPaymentResult()">mock paymentResult</button>
|
||||
</div>
|
||||
<pre class="bg-gray-100 p-3 rounded text-xs overflow-auto max-h-52">{{ text() }}</pre>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { IAuthResponse, TRoles } from '@/core';
|
||||
import { IAuthResponse, Maybe, TRoles } from '@/core';
|
||||
import { ToastService } from '@/core/services/toast.service';
|
||||
import { Component, EventEmitter, inject, Input, Output, signal } from '@angular/core';
|
||||
import { Component, EventEmitter, OnDestroy, OnInit, inject, Input, Output, signal } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import images from 'src/assets/images';
|
||||
import { LoginComponent } from './login/login.component';
|
||||
|
||||
@@ -10,9 +11,9 @@ type TSteps = 'login' | 'otp' | 'modifyLoginInfo' | 'signup';
|
||||
@Component({
|
||||
selector: 'app-auth',
|
||||
templateUrl: './auth.component.html',
|
||||
imports: [LoginComponent],
|
||||
imports: [LoginComponent, ButtonDirective],
|
||||
})
|
||||
export class AuthComponent {
|
||||
export class AuthComponent implements OnInit, OnDestroy {
|
||||
@Input() redirectUrl!: string;
|
||||
@Input() loginApiUrl!: string;
|
||||
@Input() role?: TRoles;
|
||||
@@ -83,4 +84,67 @@ export class AuthComponent {
|
||||
}
|
||||
this.router.navigateByUrl(redirectUrl);
|
||||
}
|
||||
|
||||
text = signal<string>('waiting for paymentResult...');
|
||||
private restorePaymentCallback: Maybe<() => void> = null;
|
||||
private readonly injectedPaymentResultHandler = (payload: unknown) => {
|
||||
this.handlePaymentResult(payload);
|
||||
};
|
||||
|
||||
ngOnInit() {
|
||||
this.listenAndroidPaymentResultCallback();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.restorePaymentCallback?.();
|
||||
}
|
||||
|
||||
private listenAndroidPaymentResultCallback() {
|
||||
const w = window as any;
|
||||
const previousGlobal = w.onPaymentResult;
|
||||
// Android app can call this function directly via evaluateJavascript.
|
||||
w.onPaymentResult = this.injectedPaymentResultHandler;
|
||||
|
||||
const bridge = w.AndroidPSP;
|
||||
const previousBridge = bridge?.onPaymentResult;
|
||||
if (bridge) {
|
||||
bridge.onPaymentResult = this.injectedPaymentResultHandler;
|
||||
}
|
||||
|
||||
this.restorePaymentCallback = () => {
|
||||
w.onPaymentResult = previousGlobal;
|
||||
if (bridge) {
|
||||
bridge.onPaymentResult = previousBridge;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private handlePaymentResult(result: unknown) {
|
||||
const value = typeof result === 'string' ? result : JSON.stringify(result, null, 2);
|
||||
this.text.set(value);
|
||||
this.toastService.success({ text: 'Result received from Android.' });
|
||||
}
|
||||
|
||||
async pay() {
|
||||
//@ts-ignore
|
||||
this.toastService.success({ text: window.AndroidPSP.pay(100000) });
|
||||
//@ts-ignore
|
||||
await window.AndroidPSP?.pay(100000)
|
||||
.then((response: any) => {
|
||||
// alert('payment')
|
||||
// console.log('Payment response:', response);
|
||||
this.toastService.success({ text: 'پرداخت با موفقیت انجام شد.' });
|
||||
})
|
||||
.catch((error: any) => {
|
||||
// console.error('Payment error:', error);
|
||||
this.toastService.error({ text: 'خطا در انجام پرداخت.' });
|
||||
});
|
||||
this.toastService.success({ text: 'پرداخت با موفقیت انجام شد.' });
|
||||
// //@ts-ignore
|
||||
// alert(window.AndroidPSP);
|
||||
}
|
||||
|
||||
mockPaymentResult() {
|
||||
this.injectedPaymentResultHandler(`test-result-${Date.now()}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user