digipay-utility-payment 0.0.21 → 0.0.22

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
@@ -1922,6 +1922,7 @@ class BillWorkflowComponent {
1922
1922
  allWorkflowData = {};
1923
1923
  selectedProduct = null;
1924
1924
  PRODUCT_PRICE_TYPE = PRODUCT_PRICE_TYPE;
1925
+ isInitialized = false;
1925
1926
  constructor(topupAndBillpaymentService, toasterService, fb, translationService, router, cdr, sdkState) {
1926
1927
  this.topupAndBillpaymentService = topupAndBillpaymentService;
1927
1928
  this.toasterService = toasterService;
@@ -1950,42 +1951,57 @@ class BillWorkflowComponent {
1950
1951
  this.currentScreenIndex = index;
1951
1952
  }
1952
1953
  });
1954
+ this.topupAndBillpaymentService.workflowData.pipe(takeUntil(this.destroy$)).subscribe((data) => {
1955
+ if (isNotNull(data)) {
1956
+ this.allWorkflowData = data;
1957
+ }
1958
+ });
1953
1959
  this.topupAndBillpaymentService.workflowScreens.pipe(takeUntil(this.destroy$)).subscribe((screens) => {
1954
1960
  if (isNotNull(screens)) {
1955
1961
  this.workflowScreens = screens;
1956
- if (this.workflowScreens.length > 0 && this.currentScreenIndex < this.workflowScreens.length) {
1962
+ if (this.isInitialized &&
1963
+ this.workflowScreens.length > 0 &&
1964
+ this.currentScreenIndex < this.workflowScreens.length) {
1957
1965
  this.loadCurrentScreen();
1958
1966
  }
1959
1967
  }
1960
1968
  });
1961
- this.topupAndBillpaymentService.workflowData.pipe(takeUntil(this.destroy$)).subscribe((data) => {
1962
- if (isNotNull(data)) {
1963
- this.allWorkflowData = data;
1964
- }
1965
- });
1966
1969
  // Create form with updateOn: 'change' for real-time validation
1967
1970
  this.detailsForm = this.fb.group({}, { updateOn: 'change' });
1968
1971
  }
1969
1972
  ngOnInit() {
1970
- if (this.workflowScreens.length === 0) {
1971
- if (this.billData) {
1972
- this.checkWorkflowForBill(this.billData);
1973
- }
1974
- else if (this.selectedBill) {
1975
- this.checkWorkflowForBill(this.selectedBill);
1973
+ this.syncSelectedBillFromInputs();
1974
+ if (this.workflowScreens.length > 0) {
1975
+ if (this.getSelectedBill()) {
1976
+ this.loadCurrentScreen();
1976
1977
  }
1977
1978
  }
1979
+ else if (this.billData) {
1980
+ this.checkWorkflowForBill(this.billData);
1981
+ }
1982
+ else if (this.selectedBill) {
1983
+ this.checkWorkflowForBill(this.selectedBill);
1984
+ }
1985
+ this.isInitialized = true;
1978
1986
  }
1979
1987
  ngAfterViewInit() {
1980
1988
  // Detect changes after view initialization to prevent ExpressionChangedAfterItHasBeenCheckedError
1981
1989
  this.cdr.detectChanges();
1982
1990
  }
1983
1991
  ngOnChanges(changes) {
1992
+ const billFromInput = changes['billData']?.currentValue ?? changes['selectedBill']?.currentValue;
1993
+ if (billFromInput) {
1994
+ this.selectedBill = billFromInput;
1995
+ if (this.isInitialized && this.workflowScreens.length > 0) {
1996
+ this.loadCurrentScreen();
1997
+ return;
1998
+ }
1999
+ }
1984
2000
  if (this.workflowScreens.length === 0) {
1985
- if (changes['billData'] && changes['billData'].currentValue) {
2001
+ if (changes['billData']?.currentValue) {
1986
2002
  this.checkWorkflowForBill(changes['billData'].currentValue);
1987
2003
  }
1988
- if (changes['selectedBill'] && changes['selectedBill'].currentValue) {
2004
+ else if (changes['selectedBill']?.currentValue) {
1989
2005
  this.checkWorkflowForBill(changes['selectedBill'].currentValue);
1990
2006
  }
1991
2007
  }
@@ -2550,8 +2566,16 @@ class BillWorkflowComponent {
2550
2566
  const amount = typeof value === "number" ? value : parseFloat(String(value));
2551
2567
  return isNaN(amount) ? null : amount;
2552
2568
  }
2569
+ syncSelectedBillFromInputs() {
2570
+ if (this.billData) {
2571
+ this.selectedBill = this.billData;
2572
+ }
2573
+ else if (this.allWorkflowData?.selectedBill) {
2574
+ this.selectedBill = this.allWorkflowData.selectedBill;
2575
+ }
2576
+ }
2553
2577
  getSelectedBill() {
2554
- return this.allWorkflowData?.selectedBill ?? this.selectedBill ?? null;
2578
+ return this.allWorkflowData?.selectedBill ?? this.billData ?? this.selectedBill ?? null;
2555
2579
  }
2556
2580
  ngOnDestroy() {
2557
2581
  this.destroy$.next(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "digipay-utility-payment",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20.0.0",
6
6
  "@angular/core": "^20.0.0",