some improvements
This commit is contained in:
@@ -11,7 +11,6 @@ type Currency = 'RUB';
|
||||
interface SettingsResponse {
|
||||
minAmount?: number;
|
||||
maxAmount?: number;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
interface CreateQrResponse {
|
||||
@@ -21,14 +20,10 @@ interface CreateQrResponse {
|
||||
nspkurl?: string; // actual field name in real responses
|
||||
qrUrl?: string;
|
||||
status?: string; // e.g. "REGISTERED"
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
interface QrStatusResponse {
|
||||
status?: string; // "REGISTERED" | "NEW" | "APPROVED" | "REJECTED" | "COMPLETED"
|
||||
nspkurl?: string;
|
||||
nspkID?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@@ -51,7 +46,6 @@ export class CreatePage {
|
||||
note = signal<string>('');
|
||||
error = signal<string>('');
|
||||
loading = signal<boolean>(false);
|
||||
settingsLoaded = signal<boolean>(false);
|
||||
|
||||
currency = signal<Currency>('RUB');
|
||||
payment = signal<PaymentMethod>('sbp');
|
||||
@@ -72,7 +66,6 @@ export class CreatePage {
|
||||
qrStatus = signal<string>('');
|
||||
paymentDone = signal<boolean>(false);
|
||||
private pollHandle: ReturnType<typeof setInterval> | null = null;
|
||||
private activeQrId = '';
|
||||
|
||||
/** Auth credentials passed by the host page as URL params. */
|
||||
private get authKey(): string {
|
||||
@@ -100,18 +93,13 @@ export class CreatePage {
|
||||
// The `id` query param is the user's id. Fetch per-user amount limits.
|
||||
// If the call fails or omits a value, keep current defaults.
|
||||
const userId = this.partnerqrID;
|
||||
if (!userId) {
|
||||
this.settingsLoaded.set(true);
|
||||
return;
|
||||
}
|
||||
if (!userId) return;
|
||||
const url = `${QR_VITANOVA_API}/settings?id=${encodeURIComponent(userId)}`;
|
||||
this.http.get<SettingsResponse>(url).subscribe({
|
||||
next: (s) => {
|
||||
if (typeof s?.minAmount === 'number') this.minAmount.set(s.minAmount);
|
||||
if (typeof s?.maxAmount === 'number') this.maxAmount.set(s.maxAmount);
|
||||
this.settingsLoaded.set(true);
|
||||
},
|
||||
error: () => this.settingsLoaded.set(true) // proceed with current defaults
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -167,7 +155,6 @@ export class CreatePage {
|
||||
}
|
||||
|
||||
if (qrId || nspkUrl) {
|
||||
this.activeQrId = qrId;
|
||||
const qrData = nspkUrl
|
||||
? `https://api.qrserver.com/v1/create-qr-code/?size=256x256&margin=8&data=${encodeURIComponent(nspkUrl)}`
|
||||
: (res.qrUrl ?? null);
|
||||
@@ -227,13 +214,9 @@ export class CreatePage {
|
||||
}
|
||||
|
||||
closeQr(): void {
|
||||
this.stopPolling();
|
||||
this.qrImageUrl.set(null);
|
||||
this.qrPolling.set(false);
|
||||
this.qrStatus.set('');
|
||||
this.paymentDone.set(false);
|
||||
if (this.pollHandle !== null) {
|
||||
clearInterval(this.pollHandle);
|
||||
this.pollHandle = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user