digipay-utility-payment 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
|
@@ -1306,7 +1306,7 @@ class FormlyHorizontalWrapperComponent extends FieldWrapper {
|
|
|
1306
1306
|
<em class="text-danger">*</em>
|
|
1307
1307
|
}
|
|
1308
1308
|
</label>
|
|
1309
|
-
<div class="col-md-
|
|
1309
|
+
<div class="col-md-7">
|
|
1310
1310
|
<ng-template #fieldComponent></ng-template>
|
|
1311
1311
|
@if (showError) {
|
|
1312
1312
|
<div class="invalid-feedback d-block">
|
|
@@ -1331,7 +1331,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
|
|
|
1331
1331
|
<em class="text-danger">*</em>
|
|
1332
1332
|
}
|
|
1333
1333
|
</label>
|
|
1334
|
-
<div class="col-md-
|
|
1334
|
+
<div class="col-md-7">
|
|
1335
1335
|
<ng-template #fieldComponent></ng-template>
|
|
1336
1336
|
@if (showError) {
|
|
1337
1337
|
<div class="invalid-feedback d-block">
|
|
@@ -1928,19 +1928,16 @@ class BillWorkflowComponent {
|
|
|
1928
1928
|
this.topupAndBillpaymentService.vendorProvider.pipe(takeUntil(this.destroy$)).subscribe(data => {
|
|
1929
1929
|
if (isNotNull(data)) {
|
|
1930
1930
|
this.vendorProvider = data;
|
|
1931
|
-
console.log("vendorProvider==>", this.vendorProvider);
|
|
1932
1931
|
}
|
|
1933
1932
|
});
|
|
1934
1933
|
this.topupAndBillpaymentService.workFlowUserInput.pipe(takeUntil(this.destroy$)).subscribe((data) => {
|
|
1935
1934
|
if (isNotNull(data)) {
|
|
1936
1935
|
this.workFlowUserInput = data;
|
|
1937
|
-
console.log("workFlowUserInput==>", this.workFlowUserInput);
|
|
1938
1936
|
}
|
|
1939
1937
|
});
|
|
1940
1938
|
this.topupAndBillpaymentService.vendorPlan.pipe(takeUntil(this.destroy$)).subscribe((data) => {
|
|
1941
1939
|
if (isNotNull(data)) {
|
|
1942
1940
|
this.selectedProduct = data;
|
|
1943
|
-
console.log("selectedProduct==>", this.selectedProduct);
|
|
1944
1941
|
}
|
|
1945
1942
|
});
|
|
1946
1943
|
this.topupAndBillpaymentService.currentScreenStep.pipe(takeUntil(this.destroy$)).subscribe((index) => {
|
|
@@ -1959,7 +1956,6 @@ class BillWorkflowComponent {
|
|
|
1959
1956
|
this.topupAndBillpaymentService.workflowData.pipe(takeUntil(this.destroy$)).subscribe((data) => {
|
|
1960
1957
|
if (isNotNull(data)) {
|
|
1961
1958
|
this.allWorkflowData = data;
|
|
1962
|
-
console.log("allWorkflowData==>", this.allWorkflowData);
|
|
1963
1959
|
}
|
|
1964
1960
|
});
|
|
1965
1961
|
// Create form with updateOn: 'change' for real-time validation
|
|
@@ -2087,7 +2083,36 @@ class BillWorkflowComponent {
|
|
|
2087
2083
|
}
|
|
2088
2084
|
}
|
|
2089
2085
|
submitForm() {
|
|
2090
|
-
|
|
2086
|
+
// Mark all fields as touched to show validation errors
|
|
2087
|
+
this.fieldsArray.forEach((field) => {
|
|
2088
|
+
if (!field.key)
|
|
2089
|
+
return;
|
|
2090
|
+
const formControl = this.detailsForm.get(field?.key.toString());
|
|
2091
|
+
if (formControl) {
|
|
2092
|
+
formControl.markAsTouched();
|
|
2093
|
+
formControl.updateValueAndValidity();
|
|
2094
|
+
}
|
|
2095
|
+
});
|
|
2096
|
+
// Check if any required fields are empty
|
|
2097
|
+
let hasEmptyFields = false;
|
|
2098
|
+
this.fieldsArray.forEach((field) => {
|
|
2099
|
+
const isRequired = field?.templateOptions?.required;
|
|
2100
|
+
const fieldKey = field.key?.toString();
|
|
2101
|
+
if (!fieldKey)
|
|
2102
|
+
return;
|
|
2103
|
+
const formControl = this.detailsForm.get(fieldKey);
|
|
2104
|
+
const fieldValue = formControl?.value;
|
|
2105
|
+
if (isRequired && (!fieldValue || fieldValue === '' || fieldValue === null || fieldValue === undefined)) {
|
|
2106
|
+
hasEmptyFields = true;
|
|
2107
|
+
if (formControl) {
|
|
2108
|
+
formControl.setErrors({ required: true });
|
|
2109
|
+
formControl.markAsTouched();
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
});
|
|
2113
|
+
if (hasEmptyFields || !this.detailsForm.valid) {
|
|
2114
|
+
// Show error message when form is invalid or has empty required fields
|
|
2115
|
+
this.toasterService.error(this.translationService.translate("LABEL_PLEASE_FILL_ALL_REQUIRED_FIELDS"));
|
|
2091
2116
|
return;
|
|
2092
2117
|
}
|
|
2093
2118
|
// Validate amount range for products with range price type
|
|
@@ -2252,6 +2277,93 @@ class BillWorkflowComponent {
|
|
|
2252
2277
|
};
|
|
2253
2278
|
this.topupAndBillpaymentService.saveWorkflowData(workflowState);
|
|
2254
2279
|
}
|
|
2280
|
+
// getExtraFieldsToShow(field: any): FormlyFieldConfig | undefined {
|
|
2281
|
+
// if (!field) return undefined; // Early return for falsy field
|
|
2282
|
+
// let isReadOnly = false;
|
|
2283
|
+
// if (field?.external_field_key === "dial_code") {
|
|
2284
|
+
// isReadOnly = true;
|
|
2285
|
+
// this.fieldsModel = { "dial_code": this.currentUserDetails?.dial_code };
|
|
2286
|
+
// }
|
|
2287
|
+
// const validations: Array<any> = field?.field_validation || [];
|
|
2288
|
+
// let isRequired: boolean = false;
|
|
2289
|
+
// let minLength: number | undefined;
|
|
2290
|
+
// let maxLength: number | undefined;
|
|
2291
|
+
// let minValue: number | undefined;
|
|
2292
|
+
// let maxValue: number | undefined;
|
|
2293
|
+
// const validationMessages: any = {};
|
|
2294
|
+
// validations.forEach((validation: any) => {
|
|
2295
|
+
// const fieldType = validation?.field_types;
|
|
2296
|
+
// const fieldValue = validation?.field_values;
|
|
2297
|
+
// const fieldError = validation?.field_error;
|
|
2298
|
+
// if (fieldType === 1) {
|
|
2299
|
+
// isRequired = fieldValue === "true" || fieldValue === true || fieldValue === "1";
|
|
2300
|
+
// } else if (fieldType === 2) {
|
|
2301
|
+
// maxLength = parseInt(fieldValue);
|
|
2302
|
+
// if (fieldError) validationMessages.maxlength = fieldError;
|
|
2303
|
+
// } else if (fieldType === 3) {
|
|
2304
|
+
// minValue = parseFloat(fieldValue);
|
|
2305
|
+
// if (fieldError) validationMessages.min = fieldError;
|
|
2306
|
+
// } else if (fieldType === 4) {
|
|
2307
|
+
// minLength = parseInt(fieldValue);
|
|
2308
|
+
// if (fieldError) validationMessages.minlength = fieldError;
|
|
2309
|
+
// if (!isRequired) isRequired = true;
|
|
2310
|
+
// } else if (fieldType === 5) {
|
|
2311
|
+
// maxValue = parseFloat(fieldValue);
|
|
2312
|
+
// if (fieldError) validationMessages.max = fieldError;
|
|
2313
|
+
// }
|
|
2314
|
+
// });
|
|
2315
|
+
// let res: FormlyFieldConfig = {
|
|
2316
|
+
// key: field.external_field_key,
|
|
2317
|
+
// templateOptions: {} as FormlyTemplateOptions,
|
|
2318
|
+
// className: "col-sm-6",
|
|
2319
|
+
// wrappers: ["form-field-horizontal"],
|
|
2320
|
+
// type: "input",
|
|
2321
|
+
// modelOptions: { updateOn: 'change' },
|
|
2322
|
+
// expressionProperties: {
|
|
2323
|
+
// 'templateOptions.disabled': 'formState.disabled',
|
|
2324
|
+
// },
|
|
2325
|
+
// hooks: {
|
|
2326
|
+
// onInit: (field: FormlyFieldConfig) => {
|
|
2327
|
+
// const control = field.formControl;
|
|
2328
|
+
// if (control) {
|
|
2329
|
+
// control.valueChanges.subscribe(() => {
|
|
2330
|
+
// if (control.invalid && control.value !== null && control.value !== '') {
|
|
2331
|
+
// control.markAsTouched();
|
|
2332
|
+
// }
|
|
2333
|
+
// });
|
|
2334
|
+
// }
|
|
2335
|
+
// }
|
|
2336
|
+
// }
|
|
2337
|
+
// };
|
|
2338
|
+
// if (isRequired) {
|
|
2339
|
+
// validationMessages.required = `${field.field_title} ${this.translationService.translate("LABEL_IS_REQUIRED")}`;
|
|
2340
|
+
// }
|
|
2341
|
+
// if (Object.keys(validationMessages).length > 0) {
|
|
2342
|
+
// res["validation"] = { messages: validationMessages };
|
|
2343
|
+
// }
|
|
2344
|
+
// if (field.field_type == TOPUP_BILL_PAYMENT_FIELD_TYPE.TEXT_BOX) {
|
|
2345
|
+
// res["templateOptions"] = {
|
|
2346
|
+
// label: `${field.field_title} `,
|
|
2347
|
+
// placeholder: `${this.translationService.translate("COMMON_LABEL_PLEASE_ENTER")} ${field.field_title}`,
|
|
2348
|
+
// required: isRequired,
|
|
2349
|
+
// minLength: minLength,
|
|
2350
|
+
// maxLength: maxLength,
|
|
2351
|
+
// readonly: isReadOnly,
|
|
2352
|
+
// };
|
|
2353
|
+
// } else if (field.field_type == TOPUP_BILL_PAYMENT_FIELD_TYPE.NUMERIC) {
|
|
2354
|
+
// res["templateOptions"] = {
|
|
2355
|
+
// label: `${field.field_title} `,
|
|
2356
|
+
// placeholder: `${this.translationService.translate("COMMON_LABEL_PLEASE_ENTER")} ${field.field_title}`,
|
|
2357
|
+
// required: isRequired,
|
|
2358
|
+
// min: minValue,
|
|
2359
|
+
// max: maxValue,
|
|
2360
|
+
// minLength: minLength,
|
|
2361
|
+
// maxLength: maxLength,
|
|
2362
|
+
// };
|
|
2363
|
+
// res["type"] = "number-field";
|
|
2364
|
+
// }
|
|
2365
|
+
// return res; // Always reached now
|
|
2366
|
+
// }
|
|
2255
2367
|
getExtraFieldsToShow(field) {
|
|
2256
2368
|
if (field) {
|
|
2257
2369
|
let isReadOnly = false;
|
|
@@ -2281,7 +2393,6 @@ class BillWorkflowComponent {
|
|
|
2281
2393
|
const rangeMin = Number(this.selectedProduct?.product_range_price?.min) || 0;
|
|
2282
2394
|
const rangeMax = Number(this.selectedProduct?.product_range_price?.max) || 0;
|
|
2283
2395
|
customValidators = {
|
|
2284
|
-
...customValidators,
|
|
2285
2396
|
// Range validator - checks if value is within the allowed range
|
|
2286
2397
|
// Allows typing leading zeros (e.g., "01", "08") but validates the numeric value
|
|
2287
2398
|
range: {
|
|
@@ -2304,24 +2415,6 @@ class BillWorkflowComponent {
|
|
|
2304
2415
|
};
|
|
2305
2416
|
}
|
|
2306
2417
|
}
|
|
2307
|
-
if (isAmountField) {
|
|
2308
|
-
const billAmount = this.getBillAmount();
|
|
2309
|
-
if (billAmount !== null) {
|
|
2310
|
-
customValidators = {
|
|
2311
|
-
...customValidators,
|
|
2312
|
-
billAmountMax: {
|
|
2313
|
-
expression: (control) => {
|
|
2314
|
-
const enteredAmount = this.parseFormAmount(control?.value);
|
|
2315
|
-
if (enteredAmount === null) {
|
|
2316
|
-
return true;
|
|
2317
|
-
}
|
|
2318
|
-
return enteredAmount <= billAmount;
|
|
2319
|
-
},
|
|
2320
|
-
message: () => this.translationService.translate("COMMON_LABEL_AMOUNT_MUST_NOT_EXCEED_BILL_AMOUNT"),
|
|
2321
|
-
},
|
|
2322
|
-
};
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
2418
|
const validations = field?.field_validation || [];
|
|
2326
2419
|
const normalizedFieldType = this.normalizeFieldType(field?.field_type);
|
|
2327
2420
|
const normalizedValidations = this.normalizeValidations(validations);
|
|
@@ -2413,50 +2506,6 @@ class BillWorkflowComponent {
|
|
|
2413
2506
|
this.destroy$.next(true);
|
|
2414
2507
|
this.destroy$.unsubscribe();
|
|
2415
2508
|
}
|
|
2416
|
-
getSelectedBill() {
|
|
2417
|
-
return this.allWorkflowData?.selectedBill ?? this.selectedBill ?? null;
|
|
2418
|
-
}
|
|
2419
|
-
getBillAmount() {
|
|
2420
|
-
const billAmount = Number(this.getSelectedBill()?.bill_amount);
|
|
2421
|
-
if (isNaN(billAmount) || billAmount <= 0) {
|
|
2422
|
-
return null;
|
|
2423
|
-
}
|
|
2424
|
-
return billAmount;
|
|
2425
|
-
}
|
|
2426
|
-
findAmountField() {
|
|
2427
|
-
return this.fieldsArray.find((field) => {
|
|
2428
|
-
const keyStr = String(field?.key || "").toLowerCase();
|
|
2429
|
-
const labelStr = String(field?.templateOptions?.label || "").toLowerCase();
|
|
2430
|
-
return keyStr.includes("amount") || labelStr.includes("amount");
|
|
2431
|
-
});
|
|
2432
|
-
}
|
|
2433
|
-
parseFormAmount(value) {
|
|
2434
|
-
if (value === null || value === undefined || value === "") {
|
|
2435
|
-
return null;
|
|
2436
|
-
}
|
|
2437
|
-
const amount = typeof value === "number" ? value : parseFloat(String(value));
|
|
2438
|
-
return isNaN(amount) ? null : amount;
|
|
2439
|
-
}
|
|
2440
|
-
validateEnteredAmountAgainstBill() {
|
|
2441
|
-
const billAmount = this.getBillAmount();
|
|
2442
|
-
if (billAmount === null) {
|
|
2443
|
-
return true;
|
|
2444
|
-
}
|
|
2445
|
-
const amountField = this.findAmountField();
|
|
2446
|
-
if (!amountField?.key) {
|
|
2447
|
-
return true;
|
|
2448
|
-
}
|
|
2449
|
-
const fieldKey = String(amountField.key);
|
|
2450
|
-
const enteredAmount = this.parseFormAmount(this.detailsForm?.value[fieldKey]);
|
|
2451
|
-
if (enteredAmount === null || enteredAmount <= billAmount) {
|
|
2452
|
-
return true;
|
|
2453
|
-
}
|
|
2454
|
-
this.toasterService.error(this.translationService.translate("COMMON_LABEL_AMOUNT_MUST_NOT_EXCEED_BILL_AMOUNT"));
|
|
2455
|
-
const control = this.detailsForm.get(fieldKey);
|
|
2456
|
-
control?.setErrors({ ...(control.errors ?? {}), billAmountMax: true });
|
|
2457
|
-
control?.markAsTouched();
|
|
2458
|
-
return false;
|
|
2459
|
-
}
|
|
2460
2509
|
normalizeWorkflowDetails(workflowDetails) {
|
|
2461
2510
|
if (!Array.isArray(workflowDetails))
|
|
2462
2511
|
return [];
|
|
@@ -2627,7 +2676,7 @@ class WorkFlowComponent {
|
|
|
2627
2676
|
this.prepareFormFields(this.workFlowDetails?.screen_config);
|
|
2628
2677
|
}
|
|
2629
2678
|
else {
|
|
2630
|
-
this.toasterService.error(res?.error[0]);
|
|
2679
|
+
this.toasterService.error(this.translationService.translate(res?.error[0]));
|
|
2631
2680
|
}
|
|
2632
2681
|
},
|
|
2633
2682
|
});
|