Skip to content

Conversation

@witolDark
Copy link
Contributor

@witolDark witolDark commented Dec 29, 2025

Summary by CodeRabbit

  • New Features

    • Locale input added to admin date cells for language-aware date behavior.
  • Improvements

    • Consolidated date-cell UI into a single integrated field with refined enable/disable and blocking flows.
    • Address mapping now prefers UK-specific fields alongside English fields.
    • Order edit/payment flows fetch existing order info and may cancel prior payment links before processing.
    • Tariff selection now tracks both ID and display name.
    • Unauthorized-order errors now show a message and redirect to the orders list.
  • Bug Fixes

    • Improved date validation and consistent YYYY‑MM‑DD serialization.
    • Added snackbar message types and translations.
  • Tests

    • Expanded unit tests covering date editing, blocking logic, order/payment flows, and integrations.
  • Style

    • Scoped styling refinements for date picker visual consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@witolDark witolDark self-assigned this Dec 29, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

📝 Walkthrough

Walkthrough

Address mapping switched to Ukrainian-specific fields; date-cell template, styles, locale input and logic refactored with expanded tests; order flows now prefetch existing-order info and may cancel payments; added GetExistingOrderDetailsFail action/effect that shows a snack and navigates on 403; validators, i18n, and snackbar config updated.

Changes

Cohort / File(s) Change Summary
Address Mapping
src/app/store/functions.ts
transformAddress now reads regionUk, cityUk, districtUk, streetUk for address.uk; English keys remain regionEn, cityEn, districtEn.
Date Cell — Template
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.html
Replaced editable/display split with single mat-form-field containing date input and toggle; input disabled bound to uneditableStatus; picker opened via edit() handlers.
Date Cell — Styling
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.scss
Scoped ::ng-deep rules under :host ::ng-deep; added host-scoped form-field styling (height, background, ripples, subscript visibility).
Date Cell — Logic & Locale
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.ts
edit() now takes MatDatepicker<Date>, early-returns for uneditableStatus/non-Enter-keys; subscribes to blockOrders to open picker or emit blocked info; added @Input() set lang(...) to set DateAdapter locale; date serialization changed to yyyy-MM-dd; added falsy-date guard.
Date Cell — Tests
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
Expanded test scaffold (MockStore, ChangeDetectorRef, MatDatepicker mock) and coverage for edit() branches, changeData() formatting/validation, inputs, and blocked/unblocked flows.
Date Cell — Parent Binding
src/app/ubs/ubs-admin/components/ubs-admin-table/ubs-admin-table.component.html
Added [lang]="currentLang" binding to app-table-cell-date.
Existing-Order Prefetch (UI)
src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts
Calls orderService.getExistingOrderInfo(order.id) and uses returned info for dialog results, payment linking, half-paid logic, and local-storage preparation; removed unused filterUtil.
Submit Order — Cancel-if-needed
src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts
Added hasPaymentLink flag; when processing existing orders, conditionally call cancelExistingPayment then proceed via switchMap/iif.
Order Actions
src/app/store/actions/order.actions.ts
Added GetExistingOrderDetailsFail action carrying HttpErrorResponse.
Order Effects
src/app/store/effects/order.effects.ts
GetExistingOrderDetails errors now emit GetExistingOrderDetailsFail; new effect handles 403 by showing a snackbar and navigating to /ubs/user/orders; Router injected.
Snackbar Config & Translations
src/app/shared/services/mat-snack-bar/mat-snack-bar.service.ts
src/assets/i18n/uk.json
Added errorOrderUnauthorized snack type and translation keys snack-bar.error.error and snack-bar.error.order-not-authorized in Ukrainian.
Order Details — Tariff
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.html
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.spec.ts
currentTariff changed from string to number; added currentTariffName; UI and tests updated to use currentTariffName.
Order Location Popup
src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts
Removed SetTariff store dispatch; saveLocation now closes dialog returning selectedTariff (dialog result type changed).
Address Validator (Kyiv)
src/app/ubs/ubs/validators/address-validators.ts
Imported KyivNamesEnum and added guard: KyivRegionValidator.isValid returns false when cityEn === KyivEn and cityUk === KyivUa.
Tests & Mocks Updated
src/app/ubs/ubs-user/.../ubs-user-orders-list.component.spec.ts
src/app/ubs/ubs/.../ubs-submit-order.component.spec.ts
src/app/ubs/ubs/.../ubs-order-location-popup.component.spec.ts
Mocks extended with getExistingOrderInfo and cancelExistingPayment; tests adjusted (dialog payloads, removed Store.dispatch expectation).

Sequence Diagram(s)

sequenceDiagram
  participant UI as Component/UI
  participant Store as NgRx Store
  participant Effect as OrderEffects
  participant API as OrderService/API
  participant Snack as MatSnackBarService
  participant Router as Router

  UI->>Store: dispatch GetExistingOrderDetails(orderId)
  Store->>Effect: effect handles GetExistingOrderDetails
  Effect->>API: fetch existing order details
  alt success
    API-->>Effect: order details
    Effect-->>Store: dispatch GetExistingOrderDetailsSuccess
  else 403
    API-->>Effect: HttpErrorResponse(403)
    Effect-->>Store: dispatch GetExistingOrderDetailsFail(error)
    Effect->>Snack: show 'order-not-authorized' snack
    Effect->>Router: navigate('/ubs/user/orders')
  else other error
    API-->>Effect: HttpErrorResponse(error)
    Effect-->>Store: dispatch GetExistingOrderDetailsFail(error)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through keys and locale tunes,
Streets found Uk names beneath bright moons,
Dates tucked in one field, picker gave a wink,
Orders fetched their info, cancelled if on the brink,
Tests munched carrots — all set to blink!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title references only date cell and address fixes, but the PR includes substantial changes beyond these: order details refactoring, tariff handling, payment link logic, error handling, and localization updates. Revise the title to better reflect the scope, such as 'Refactor order details, date picker, and address handling with improved error management' or specify the primary change if one exists.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (3)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.ts (1)

92-96: Consider using a proper logging service instead of console.error.

Direct console logging may be stripped in production builds and isn't configurable. If this is intentional error handling for debugging, consider using the application's logging service for consistency and observability.

src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts (1)

22-25: Consider resetting mock spies between tests and verifying picker.open() is called.

The mockDatepicker spies are never reset between tests and open() is never verified. Since the edit() method calls picker.open() when orders aren't blocked, add assertions to verify this behavior.

🔎 Proposed addition
// In beforeEach, reset the spies:
beforeEach(() => {
  (mockDatepicker.open as jasmine.Spy).calls.reset();
  (mockDatepicker.close as jasmine.Spy).calls.reset();
  // ... rest of setup
});

// Add a test to verify picker opens when not blocked:
it('should open picker when blockOrders returns undefined', () => {
  const service = TestBed.inject(AdminTableService);
  spyOn(service, 'blockOrders').and.returnValue(of([undefined]));
  component.isAllChecked = false;
  component.ordersToChange = [];
  component.id = 1;
  component.edit(mockDatepicker as MatDatepicker<Date>);
  expect(mockDatepicker.open).toHaveBeenCalled();
});
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-input/table-cell-input.component.ts (1)

128-130: Emit addressChanged event after successful address update.

The newly added addressChanged output (line 32) should likely be emitted here after the address is successfully updated. Currently, the subscription only unblocks orders but doesn't notify parent components of the change.

🔎 Emit the addressChanged event
      .subscribe(() => {
        this.adminTableService.unblockOrders([this.id]).subscribe();
+        this.addressChanged.emit(this.id);
      });
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca1c37e and 4b342c3.

📒 Files selected for processing (7)
  • src/app/store/functions.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.html
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.scss
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-input/table-cell-input.component.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/ubs-admin-table.component.html
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-01T22:32:58.734Z
Learnt from: AndrewKozovyi
Repo: ita-social-projects/GreenCityClient PR: 3770
File: src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts:103-110
Timestamp: 2025-08-01T22:32:58.734Z
Learning: In UbsAdminCustomersComponent (src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts), using take(1) instead of takeUntilDestroyed(this.destroyRef) for the adminTableOfCustomersSelector$ subscription prevents excessive additional functionality from being triggered and works correctly for the component's initialization sequence.

Applied to files:

  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-input/table-cell-input.component.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.ts
📚 Learning: 2025-12-11T20:44:21.136Z
Learnt from: witolDark
Repo: ita-social-projects/GreenCityClient PR: 3921
File: src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts:214-214
Timestamp: 2025-12-11T20:44:21.136Z
Learning: In Angular projects using HttpClient, HTTP call observables complete after emitting a single value. Therefore, take(1) or takeUntil is not strictly required to prevent memory leaks for typical single-emission requests. However, using take(1) (or takeUntil in combination with a component-destruction signal) can improve readability and guard against accidental multiple emissions if the observable is reused or transformed. For files like src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts and other services using HttpClient, rely on HttpClient completion for single requests, but consider adding take(1) when subscribing in long-lived contexts or when the observable could emit more than once due to retries or stream augmentation.

Applied to files:

  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
  • src/app/store/functions.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-input/table-cell-input.component.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.ts
🧬 Code graph analysis (2)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-input/table-cell-input.component.ts (1)
src/app/ubs/ubs-admin/models/ubs-admin.interface.ts (1)
  • IColumnBelonging (501-506)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.ts (1)
src/app/store/actions/ubs-admin.actions.ts (1)
  • SetCursorWaite (10-10)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (9)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.ts (2)

49-58: LGTM!

The lang setter properly propagates locale changes to the DateAdapter, and the constructor injection is correctly typed.


60-63: LGTM!

The early return guards properly handle uneditable status and filter keyboard events to only respond to Enter/Space for accessibility compliance.

src/app/ubs/ubs-admin/components/ubs-admin-table/ubs-admin-table.component.html (1)

362-373: LGTM!

The [lang]="currentLang" binding is correctly added to the date cell component, consistent with other cell components in the table that also receive the language binding.

src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.html (2)

1-10: LGTM!

The form field structure with disabled state binding, min date constraint, and dateChange event handler is well-implemented.


11-16: The toggle's click handler is necessary and correct. The mat-datepicker-toggle only has built-in click handling when the [for] attribute is present. This toggle intentionally omits [for] and uses custom (click) and (keydown) handlers to implement the blocking validation logic via blockOrders() before opening the picker. No double-open occurs since the toggle has no default behavior to conflict with the edit() method.

Likely an incorrect or invalid review comment.

src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts (1)

101-120: LGTM!

The test correctly constructs the expected date format to match the component's changeData() implementation, ensuring the assertion validates the actual behavior.

src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.scss (2)

19-43: LGTM!

The host-scoped styles properly encapsulate Material form field customizations within this component, preventing style leakage to other parts of the application.


45-65: Note: ::ng-deep is deprecated but currently necessary.

The use of :host ::ng-deep is the correct pattern for scoping Material component overrides. Be aware that ::ng-deep is deprecated, though Angular has not provided a replacement for this use case yet.

src/app/store/functions.ts (1)

1-12: [Rewritten review comment]
[Classification tag]

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/app/store/functions.ts (1)

1-1: The any type issue remains unaddressed.

The function parameter is still typed as any, which was flagged in a previous review. Please define a proper interface for type safety as suggested in the earlier review.

🧹 Nitpick comments (1)
src/app/store/functions.ts (1)

3-8: Add type safety to the function parameter instead of any.

The function parameter is typed as any, which lacks type safety. While the interface IShortAddress.orderAddressExportDetails defines all address fields (region, city, district, street, houseNumber, entranceNumber) as required strings, using any bypasses TypeScript's type checking and could allow incomplete data to be passed.

Either type the input parameter as IOrderAddressExportDetails (or extract/export the nested interface) or add consistent fallbacks across all fields for defensive robustness. Currently, only houseCorpus and addressComment have fallbacks (|| ''), creating inconsistent handling.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b342c3 and 88189c3.

📒 Files selected for processing (2)
  • src/app/store/functions.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-input/table-cell-input.component.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-input/table-cell-input.component.ts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-11T20:44:21.136Z
Learnt from: witolDark
Repo: ita-social-projects/GreenCityClient PR: 3921
File: src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts:214-214
Timestamp: 2025-12-11T20:44:21.136Z
Learning: In Angular projects using HttpClient, HTTP call observables complete after emitting a single value. Therefore, take(1) or takeUntil is not strictly required to prevent memory leaks for typical single-emission requests. However, using take(1) (or takeUntil in combination with a component-destruction signal) can improve readability and guard against accidental multiple emissions if the observable is reused or transformed. For files like src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts and other services using HttpClient, rely on HttpClient completion for single requests, but consider adding take(1) when subscribing in long-lived contexts or when the observable could emit more than once due to retries or stream augmentation.

Applied to files:

  • src/app/store/functions.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (18.x)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts (1)

28-31: Reset mock datepicker spies between tests to prevent false positives.

The mockDatepicker spies are created once at module level but never reset. Spy call counts accumulate across tests, which can cause false positives when checking toHaveBeenCalled() or toHaveBeenCalledTimes().

Proposed fix: reset spies in beforeEach
   beforeEach(() => {
     jasmine.clock().install();
     jasmine.clock().mockDate(new Date());
 
     fixture = TestBed.createComponent(TableCellDateComponent);
     component = fixture.componentInstance;
     adminTableService = TestBed.inject(AdminTableService);
     store = TestBed.inject(MockStore);
     cdr = fixture.componentRef.injector.get(ChangeDetectorRef);
+
+    (mockDatepicker.open as jasmine.Spy).calls.reset();
+    (mockDatepicker.close as jasmine.Spy).calls.reset();
 
     fixture.detectChanges();
   });
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88189c3 and c36471c.

📒 Files selected for processing (1)
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-01T22:32:58.734Z
Learnt from: AndrewKozovyi
Repo: ita-social-projects/GreenCityClient PR: 3770
File: src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts:103-110
Timestamp: 2025-08-01T22:32:58.734Z
Learning: In UbsAdminCustomersComponent (src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts), using take(1) instead of takeUntilDestroyed(this.destroyRef) for the adminTableOfCustomersSelector$ subscription prevents excessive additional functionality from being triggered and works correctly for the component's initialization sequence.

Applied to files:

  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
📚 Learning: 2025-12-11T20:44:21.136Z
Learnt from: witolDark
Repo: ita-social-projects/GreenCityClient PR: 3921
File: src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts:214-214
Timestamp: 2025-12-11T20:44:21.136Z
Learning: In Angular projects using HttpClient, HTTP call observables complete after emitting a single value. Therefore, take(1) or takeUntil is not strictly required to prevent memory leaks for typical single-emission requests. However, using take(1) (or takeUntil in combination with a component-destruction signal) can improve readability and guard against accidental multiple emissions if the observable is reused or transformed. For files like src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts and other services using HttpClient, rely on HttpClient completion for single requests, but consider adding take(1) when subscribing in long-lived contexts or when the observable could emit more than once due to retries or stream augmentation.

Applied to files:

  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
🧬 Code graph analysis (1)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts (1)
src/app/store/actions/ubs-admin.actions.ts (1)
  • SetCursorWaite (10-10)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (4)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts (4)

214-312: Good test coverage for date formatting and edge cases.

The changeData() tests comprehensively cover:

  • Standard date formatting with leading zeros
  • Boundary conditions (year start/end)
  • Invalid input handling (null/undefined)
  • Type coercion from string to Date

314-358: LGTM!

Input property tests use the modern setInput() API and provide good coverage for all relevant inputs.


360-397: Integration tests correctly validate end-to-end flows.

The tests properly verify the complete edit workflow including cursor state management, blocking check, and conditional datepicker opening. Line 394 correctly expects the datepicker to NOT open when orders are blocked.


58-72: LGTM!

Initialization tests appropriately verify component creation and default state.

@witolDark witolDark force-pushed the Spelina/style-leakage-fix branch from e002205 to e247f11 Compare January 2, 2026 14:17
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts (2)

132-164: Missing error handling and unsubscription for the observable chain.

The refactored editOrPayPopup method lacks:

  1. Error handling - if getExistingOrderInfo fails, the user receives no feedback
  2. takeUntil(this.destroy$) - potential subscription leak if component is destroyed while request is in flight
🔎 Proposed fix
 editOrPayPopup(order: IUserOrderInfo) {
   this.orderService
     .getExistingOrderInfo(order.id)
     .pipe(
+      takeUntil(this.destroy$),
       switchMap((info) =>
         this.dialog
           .open(DialogPopUpComponent, {
             data: this.editOrPayDialogData,
             autoFocus: true
           })
           .afterClosed()
           .pipe(map((res) => ({ res, info })))
       )
     )
-    .subscribe(({ res, info }) => {
+    .subscribe({
+      next: ({ res, info }) => {
         if (res) {
           if (info.paymentLink) {
             window.location.href = info.paymentLink;
           } else {
             this.openOrderPaymentPopUp(info);
           }
           return;
         }
 
         if (res === false) {
           if (this.isOrderHalfPaid(info)) {
             this.openOrderPaymentPopUp(info);
           } else {
             this.getDataForLocalStorage(info);
           }
         }
-      });
+      },
+      error: () => this.snackBarService.openSnackBar('error')
+    });
 }

217-228: Bug: hasPaymentLink is never set on orderDetails, causing dead code.

The condition on line 247 checks this.orderDetails.hasPaymentLink, but this property is never assigned when orderDetails is constructed in lines 217-228. The cancelExistingPayment logic will never execute.

🔎 Proposed fix - set hasPaymentLink from the order info
       this.orderDetails = {
         additionalOrders: order.additionalOrders,
         bags: this.bags,
         certificates: [],
         certificatesSum: 0,
         finalSum: order.orderFullPrice,
         orderComment: order.orderComment,
         points: this.bonuses,
         pointsSum: 0,
         pointsToUse: 0,
-        total: order.orderFullPrice
+        total: order.orderFullPrice,
+        hasPaymentLink: !!order.paymentLink
       };

Also applies to: 247-247

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e247f11 and aa23947.

📒 Files selected for processing (2)
  • src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts
  • src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-01T22:32:58.734Z
Learnt from: AndrewKozovyi
Repo: ita-social-projects/GreenCityClient PR: 3770
File: src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts:103-110
Timestamp: 2025-08-01T22:32:58.734Z
Learning: In UbsAdminCustomersComponent (src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts), using take(1) instead of takeUntilDestroyed(this.destroyRef) for the adminTableOfCustomersSelector$ subscription prevents excessive additional functionality from being triggered and works correctly for the component's initialization sequence.

Applied to files:

  • src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts
  • src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts
📚 Learning: 2025-12-11T20:44:21.136Z
Learnt from: witolDark
Repo: ita-social-projects/GreenCityClient PR: 3921
File: src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts:214-214
Timestamp: 2025-12-11T20:44:21.136Z
Learning: In Angular projects using HttpClient, HTTP call observables complete after emitting a single value. Therefore, take(1) or takeUntil is not strictly required to prevent memory leaks for typical single-emission requests. However, using take(1) (or takeUntil in combination with a component-destruction signal) can improve readability and guard against accidental multiple emissions if the observable is reused or transformed. For files like src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts and other services using HttpClient, rely on HttpClient completion for single requests, but consider adding take(1) when subscribing in long-lived contexts or when the observable could emit more than once due to retries or stream augmentation.

Applied to files:

  • src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts
  • src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (2)
src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts (1)

119-139: Nested iif logic for conditional payment cancellation looks correct.

The implementation correctly:

  • Evaluates existingOrderId >= 0 to determine if this is an existing order
  • Conditionally cancels the existing payment when hasPaymentLink is true before processing
  • Chains the cancellation with switchMap to ensure sequential execution
  • Handles errors by redirecting to the confirm page via finalize

One minor consideration: the subscription lacks takeUntil(this.$destroy), but since the observable chain completes after a single emission (HTTP calls) and the component redirects on completion, this is acceptable per the project's conventions noted in the learnings.

src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts (1)

146-162: No type compatibility issues exist.

getExistingOrderInfo returns Observable<IUserOrderInfo>, and all three methods (openOrderPaymentPopUp, isOrderHalfPaid, getDataForLocalStorage) are explicitly typed to accept IUserOrderInfo. The interface contains all required properties (id, amountBeforePayment, paymentLink, paymentStatusEn, additionalOrders, orderFullPrice, etc.). TypeScript's type system ensures complete compatibility at compile time.

Likely an incorrect or invalid review comment.

Made kyiv city invalid for kyiv region validator
fixed existring order query params handling for order that doesnt belong to the user
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Fix all issues with AI Agents 🤖
In @src/app/store/effects/order.effects.ts:
- Line 71: Add a reducer handler for the GetExistingOrderDetailsFail action so
isOrderDetailsLoading is set back to false and the error payload is stored (or
cleared) for consumers; locate the reducer using the createReducer handling
GetExistingOrderDetails and GetExistingOrderDetailsSuccess and add a case for
GetExistingOrderDetailsFail that sets isOrderDetailsLoading: false and copies
action.error (or sets an errors field) so components relying on the
isOrderDetailsLoading selector won’t remain stuck on error.

In @src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts:
- Line 73: The flag changedTariffForExistingOrder is defined but never set to
true, so remove the dead code: delete the private property declaration
changedTariffForExistingOrder and remove the conditional block that checks it
(the if (...) { ... } block that relies on changedTariffForExistingOrder);
search for any other references to changedTariffForExistingOrder in
ubs-order-details component and remove or refactor them as needed, then run the
TypeScript build/tests to ensure no lingering references remain.

In
@src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts:
- Around line 81-84: In saveLocation(), the undefined identifier tariff is used
and will throw at runtime; replace tariff.id with this.selectedTariff.id and
guard against missing selection (e.g., if (!this.selectedTariff) return or
handle error) before calling this.localStorageService.setTariffId and closing
the dialogRef so you only call setTariffId(this.selectedTariff.id) when
selectedTariff exists.

In @src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts:
- Around line 121-127: When hasPaymentLink is true, a failure in
cancelExistingPayment aborts processing; wrap
cancelExistingPayment(this.existingOrderId) with a catchError to recover and
return a harmless observable so processExistingOrder(...) still runs (import
catchError), e.g. catch the error, log or surface a user-friendly message via
the component logger/UI, and return of(null) (or EMPTY) so switchMap proceeds to
call orderService.processExistingOrder(this.getOrder(shouldBePaid),
this.existingOrderId); keep the hasPaymentLink, cancelExistingPayment,
processExistingOrder, getOrder, and existingOrderId references to locate the
change.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts (1)

72-72: Add explicit type conversion for query parameter.

Query parameters from ActivatedRoute are strings, but existingOrderId is typed as number. Convert the parameter explicitly using Number() or the unary + operator to ensure type safety and match the expected type for orderService.cancelExistingPayment() and orderService.processExistingOrder() which both expect number.

Related pattern: ubs-user-orders-list.component.ts (line 249) shows proper conversion with Number(this.orderId).

🧹 Nitpick comments (2)
src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts (1)

125-126: Consider refactoring to reduce code duplication.

The call to processExistingOrder appears in both branches of the inner iif. This duplication could be reduced by restructuring the observable chain.

🔎 Alternative approach without duplication
 iif(
   () => this.existingOrderId >= 0,
-  iif(
-    () => this.hasPaymentLink,
-    this.orderService
-      .cancelExistingPayment(this.existingOrderId)
-      .pipe(switchMap(() => this.orderService.processExistingOrder(this.getOrder(shouldBePaid), this.existingOrderId))),
-    this.orderService.processExistingOrder(this.getOrder(shouldBePaid), this.existingOrderId)
-  ),
+  (this.hasPaymentLink 
+    ? this.orderService.cancelExistingPayment(this.existingOrderId)
+    : of(null)
+  ).pipe(switchMap(() => this.orderService.processExistingOrder(this.getOrder(shouldBePaid), this.existingOrderId))),
   this.orderService.processNewOrder(this.getOrder(shouldBePaid))
 )

Note: You'll need to import of from rxjs.

src/app/store/effects/order.effects.ts (1)

77-88: Consider checking current route before navigation.

The effect navigates to /ubs/user/orders on 403 errors. If the user is already on that route, this could cause unnecessary re-rendering or route reinitialization.

🔎 Proposed improvement to avoid redundant navigation
 getExistingOrderDetailsFail = createEffect(
   () =>
     this.actions.pipe(
       ofType(GetExistingOrderDetailsFail),
       filter(({ error }) => error.status === 403),
       tap(() => {
         this.snackBar.openSnackBar('errorOrderUnauthorized');
-        this.router.navigate(['/ubs/user/orders']);
+        if (!this.router.url.includes('/ubs/user/orders')) {
+          this.router.navigate(['/ubs/user/orders']);
+        }
       })
     ),
   { dispatch: false }
 );
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa23947 and 9654dcf.

📒 Files selected for processing (10)
  • src/app/shared/services/mat-snack-bar/mat-snack-bar.service.ts
  • src/app/store/actions/order.actions.ts
  • src/app/store/effects/order.effects.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.html
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.spec.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts
  • src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts
  • src/app/ubs/ubs/validators/address-validators.ts
  • src/assets/i18n/uk.json
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-11T20:44:21.136Z
Learnt from: witolDark
Repo: ita-social-projects/GreenCityClient PR: 3921
File: src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts:214-214
Timestamp: 2025-12-11T20:44:21.136Z
Learning: In Angular projects using HttpClient, HTTP call observables complete after emitting a single value. Therefore, take(1) or takeUntil is not strictly required to prevent memory leaks for typical single-emission requests. However, using take(1) (or takeUntil in combination with a component-destruction signal) can improve readability and guard against accidental multiple emissions if the observable is reused or transformed. For files like src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts and other services using HttpClient, rely on HttpClient completion for single requests, but consider adding take(1) when subscribing in long-lived contexts or when the observable could emit more than once due to retries or stream augmentation.

Applied to files:

  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.spec.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts
  • src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts
  • src/app/store/effects/order.effects.ts
  • src/app/store/actions/order.actions.ts
  • src/app/ubs/ubs/validators/address-validators.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts
  • src/app/shared/services/mat-snack-bar/mat-snack-bar.service.ts
📚 Learning: 2025-08-01T22:32:58.734Z
Learnt from: AndrewKozovyi
Repo: ita-social-projects/GreenCityClient PR: 3770
File: src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts:103-110
Timestamp: 2025-08-01T22:32:58.734Z
Learning: In UbsAdminCustomersComponent (src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts), using take(1) instead of takeUntilDestroyed(this.destroyRef) for the adminTableOfCustomersSelector$ subscription prevents excessive additional functionality from being triggered and works correctly for the component's initialization sequence.

Applied to files:

  • src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts
🧬 Code graph analysis (2)
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts (2)
src/app/store/actions/order.actions.ts (4)
  • GetOrderDetails (94-94)
  • GetExistingOrderDetails (109-109)
  • GetCourierLocations (97-97)
  • SetTariff (93-93)
src/app/ubs/ubs/models/ubs.interface.ts (1)
  • ActiveTariffInfo (276-283)
src/app/store/effects/order.effects.ts (1)
src/app/store/actions/order.actions.ts (1)
  • GetExistingOrderDetailsFail (114-114)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (12)
src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.ts (3)

4-4: LGTM!

The switchMap import is necessary for the new conditional payment cancellation logic and is correctly imported.


41-41: LGTM!

The hasPaymentLink field appropriately tracks whether a payment link exists for conditional cancellation logic.


85-85: Previous issue resolved.

The optional chaining has been correctly added, preventing potential runtime errors when existingOrderInfo is undefined.

src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.html (1)

7-7: LGTM! Property reference updated correctly.

The template correctly references currentTariffName instead of currentTariff, aligning with the component refactor where tariff ID and name are now tracked separately.

src/app/store/actions/order.actions.ts (1)

5-5: LGTM! Proper error action implementation.

The new GetExistingOrderDetailsFail action correctly follows NgRx patterns:

  • Properly imports HttpErrorResponse for type safety
  • Adds the failure action to the enum
  • Exports a typed action creator with the error payload

This enables downstream effects to handle 403 authorization errors when fetching existing order details.

Also applies to: 41-41, 114-114

src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.spec.ts (1)

381-381: LGTM! Test updated for property rename.

The test assertion correctly references component.currentTariffName instead of component.currentTariff, maintaining test coverage for the refactored tariff name storage.

src/assets/i18n/uk.json (1)

517-517: LGTM! Translation entries added for error handling.

The new Ukrainian translations support the 403 authorization error flow:

  • Generic error message: "Сталася помилка"
  • Order-specific authorization message: "Немає доступу до замовлення"

JSON syntax is correct with proper comma placement.

Also applies to: 533-534

src/app/shared/services/mat-snack-bar/mat-snack-bar.service.ts (1)

41-41: LGTM! Snackbar configuration updates align with error handling flow.

The new errorOrderUnauthorized entry and the translation key addition to errorMessage follow existing patterns and support the 403 error handling introduced in the effects layer.

Also applies to: 54-54

src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts (2)

57-58: LGTM! Cleaner separation of tariff id and name.

The refactoring separates the tariff id (for logic) from the tariff name (for display), improving code clarity. The currentTariff property now stores the numeric id, and currentTariffName stores the localized name string.

Also applies to: 161-162


164-166: Verify dispatches use correct tariffId parameter.

The dispatches now use tariffId: this.currentTariff where currentTariff is a number (tariff id). Ensure the action signatures and effects expect tariffId as a number, not a string.

Based on the relevant code snippets, GetOrderDetails and GetCourierLocations actions expect { tariffId: number }, which aligns with the changes. The refactoring correctly updates these dispatches.

src/app/ubs/ubs/validators/address-validators.ts (2)

3-3: KyivNamesEnum is properly defined with correct properties.

The enum exists in src/app/ubs/ubs/models/ubs.interface.ts with the expected KyivEn ('Kyiv') and KyivUa ('Київ') properties. The import at line 3 is correct, and the validation logic at lines 50-52 properly uses these enum values to exclude Kyiv city from Kyiv region validation.


50-52: The AND condition is correct—no changes needed.

Verification confirms the logic is sound. The strict AND condition (cityEn === KyivEn && cityUk === KyivUa) appropriately requires both English and Ukrainian names to match before excluding an address, preventing false positives where only one name might coincide. The placement of this check after the locations list validation creates a good defensive safeguard.

One observation: no unit tests exist for KyivRegionValidator or the address validation logic. Consider adding test coverage for edge cases including Kyiv city exclusion and distance-based validation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts (2)

132-163: Missing error handling in the observable chain.

The getExistingOrderInfo call lacks error handling. If the request fails, the user will see no feedback, and the dialog won't open. Consider adding error handling to notify the user.

🔎 Proposed fix
   editOrPayPopup(order: IUserOrderInfo) {
     this.orderService
       .getExistingOrderInfo(order.id)
       .pipe(
         switchMap((info) =>
           this.dialog
             .open(DialogPopUpComponent, {
               data: this.editOrPayDialogData,
               autoFocus: true
             })
             .afterClosed()
             .pipe(map((res) => ({ res, info })))
         )
       )
-      .subscribe(({ res, info }) => {
+      .subscribe({
+        next: ({ res, info }) => {
           if (res) {
             if (info.paymentLink) {
               window.location.href = info.paymentLink;
             } else {
               this.openOrderPaymentPopUp(info);
             }
             return;
           }
 
           if (res === false) {
             if (this.isOrderHalfPaid(info)) {
               this.openOrderPaymentPopUp(info);
             } else {
               this.getDataForLocalStorage(info);
             }
           }
-      });
+        },
+        error: () => {
+          this.snackBarService.openSnackBar('error');
+        }
+      });
   }

188-234: No explicit error handling for forkJoin requests.

If either getExistingOrderDetails or getPersonalData fails, the forkJoin will error and the subscription's success callback won't execute, leaving the user without feedback. Consider adding error handling.

🔎 Proposed fix
-    forkJoin([orderDataRequest, personalDataRequest]).subscribe(() => {
+    forkJoin([orderDataRequest, personalDataRequest]).subscribe({
+      next: () => {
         this.bags = orderDataResponse.bags || [];
         // ... rest of the logic
         this.setDataToLocalStorage();
-    });
+      },
+      error: () => {
+        this.snackBarService.openSnackBar('error');
+      }
+    });
src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.spec.ts (1)

477-490: Consider adding a test for the half-paid branch when dialog returns false.

This test covers the getDataForLocalStorage branch (when isOrderHalfPaid is false), but there's no test for the case when res === false and isOrderHalfPaid(info) is true, which should call openOrderPaymentPopUp. Consider adding coverage for that scenario.

🔎 Example test case
it('should call openOrderPaymentPopUp if dialog returned false and order is half-paid', fakeAsync(() => {
  dialogRefSpy.afterClosed.and.returnValue(of(false));
  const halfPaidOrder = { ...fakeInputOrderData[1], paymentStatusEn: 'Half paid' };
  orderServiceMock.getExistingOrderInfo.and.returnValue(of(halfPaidOrder));
  const orderPaymentPopupSpy = spyOn(component as any, 'openOrderPaymentPopUp');
  const getDataForLocalStorageSpy = spyOn(component, 'getDataForLocalStorage');

  component.editOrPayPopup(fakeInputOrderData[1] as any);
  tick();

  expect(orderPaymentPopupSpy).toHaveBeenCalledWith(halfPaidOrder as any);
  expect(getDataForLocalStorageSpy).not.toHaveBeenCalled();
}));
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9654dcf and 04fda97.

📒 Files selected for processing (3)
  • src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.spec.ts
  • src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-11T20:44:21.136Z
Learnt from: witolDark
Repo: ita-social-projects/GreenCityClient PR: 3921
File: src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts:214-214
Timestamp: 2025-12-11T20:44:21.136Z
Learning: In Angular projects using HttpClient, HTTP call observables complete after emitting a single value. Therefore, take(1) or takeUntil is not strictly required to prevent memory leaks for typical single-emission requests. However, using take(1) (or takeUntil in combination with a component-destruction signal) can improve readability and guard against accidental multiple emissions if the observable is reused or transformed. For files like src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts and other services using HttpClient, rely on HttpClient completion for single requests, but consider adding take(1) when subscribing in long-lived contexts or when the observable could emit more than once due to retries or stream augmentation.

Applied to files:

  • src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.spec.ts
  • src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts
📚 Learning: 2025-08-01T22:32:58.734Z
Learnt from: AndrewKozovyi
Repo: ita-social-projects/GreenCityClient PR: 3770
File: src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts:103-110
Timestamp: 2025-08-01T22:32:58.734Z
Learning: In UbsAdminCustomersComponent (src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts), using take(1) instead of takeUntilDestroyed(this.destroyRef) for the adminTableOfCustomersSelector$ subscription prevents excessive additional functionality from being triggered and works correctly for the component's initialization sequence.

Applied to files:

  • src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts
🧬 Code graph analysis (2)
src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.spec.ts (1)
src/app/ubs/mocks/order-data-mock.ts (1)
  • fakeInputOrderData (108-161)
src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts (1)
src/app/ubs/ubs/models/ubs.interface.ts (2)
  • OrderDetails (36-49)
  • PersonalData (65-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (6)
src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.ts (2)

232-232: Good use of optional chaining.

The optional chaining on order.id?.toString() adds defensive coding against potential undefined values.


148-151: No type compatibility issues exist.

The info object from getExistingOrderInfo is correctly typed as IUserOrderInfo. The service method explicitly returns Observable<IUserOrderInfo>, and both openOrderPaymentPopUp(order: IUserOrderInfo) and isOrderHalfPaid(order: IUserOrderInfo) accept this type. The types match exactly and no runtime errors will occur.

src/app/ubs/ubs-user/components/ubs-user-orders-list/ubs-user-orders-list.component.spec.ts (4)

92-102: Mock setup looks correct.

The getExistingOrderInfo method is properly added to the mock and configured with a default return value. This aligns with the component's new data flow.


391-391: Good typo fix.

Corrected "orsers" to "orders" in the test description.


462-475: Test correctly verifies the true dialog result branch.

The mock for getExistingOrderInfo returns the expected order data, and the assertions verify that openOrderPaymentPopUp is called with the info from the service response.


233-245: Updated test data reference aligns with the new flow.

The test now correctly uses fakeInputOrderData[0] and expects orderId: 3, which matches the data structure. This ensures the test reflects the actual component behavior.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.spec.ts (1)

31-32: Add an assertion for the new cancellation branch (and type the spy to catch signature drift).

Right now you mock cancelExistingPayment, but no test verifies it’s called when the “has payment link → cancel” path is taken, so the suite may not actually protect this new behavior.

Proposed tweak (type-safe spy + minimal assertion)
-    const orderServiceSpy = jasmine.createSpyObj('OrderService', ['processExistingOrder', 'processNewOrder', 'cancelExistingPayment']);
+    const orderServiceSpy = jasmine.createSpyObj<OrderService>('OrderService', [
+      'processExistingOrder',
+      'processNewOrder',
+      'cancelExistingPayment'
+    ]);
     orderServiceSpy.cancelExistingPayment.and.returnValue(of(true));
   it('should process existing order successfully', () => {
     orderService.processExistingOrder.and.returnValue(of({ orderId: 123, link: 'https://' }));
     component.existingOrderId = 1;
     component.personalData = personalMockData;
     component.orderDetails = orderDetailsMock;
     component.processOrder(true);

     expect(component.isLoadingAnim).toBe(true);
+    // If the new flow cancels when a payment link exists, assert it here (adjust params as per real signature).
+    expect(orderService.cancelExistingPayment).toHaveBeenCalled();
     expect(orderService.processExistingOrder).toHaveBeenCalled();
   });
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04fda97 and be3cf63.

📒 Files selected for processing (2)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.spec.ts
  • src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.spec.ts
💤 Files with no reviewable changes (1)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.spec.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-01T22:32:58.734Z
Learnt from: AndrewKozovyi
Repo: ita-social-projects/GreenCityClient PR: 3770
File: src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts:103-110
Timestamp: 2025-08-01T22:32:58.734Z
Learning: In UbsAdminCustomersComponent (src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts), using take(1) instead of takeUntilDestroyed(this.destroyRef) for the adminTableOfCustomersSelector$ subscription prevents excessive additional functionality from being triggered and works correctly for the component's initialization sequence.

Applied to files:

  • src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.spec.ts
📚 Learning: 2025-12-11T20:44:21.136Z
Learnt from: witolDark
Repo: ita-social-projects/GreenCityClient PR: 3921
File: src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts:214-214
Timestamp: 2025-12-11T20:44:21.136Z
Learning: In Angular projects using HttpClient, HTTP call observables complete after emitting a single value. Therefore, take(1) or takeUntil is not strictly required to prevent memory leaks for typical single-emission requests. However, using take(1) (or takeUntil in combination with a component-destruction signal) can improve readability and guard against accidental multiple emissions if the observable is reused or transformed. For files like src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts and other services using HttpClient, rely on HttpClient completion for single requests, but consider adding take(1) when subscribing in long-lived contexts or when the observable could emit more than once due to retries or stream augmentation.

Applied to files:

  • src/app/ubs/ubs/components/ubs-submit-order/ubs-submit-order.component.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (18.x)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In
@src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts:
- Around line 213-311: The test "should handle non-Date object by converting to
Date" is flaky because parsing '2024-06-15' can shift across timezones; update
the test to avoid reliance on string-to-Date parsing by providing a
deterministic Date instance or by passing explicit numeric parts: replace
dateString = '2024-06-15' and dateEvent.value with new Date(2024, 5, 15) (or
build via parts and new Date(year, month-1, day)), keep
component.id/nameOfColumn and the expectation against
component.editDateCell.emit unchanged so changeData() receives an unambiguous
Date and the emitted newValue remains '2024-06-15'.
- Around line 359-396: The test for the blocked-orders branch has an incorrect
assertion: when adminTableService.blockOrders returns a blocked result
(iAlertInfo), the component.edit branch should call
component.showBlockedInfo.emit(res) and NOT open the datepicker; remove the
assertion expecting mockDatepicker.open toHaveBeenCalled in that test. Locate
the second spec in the "Integration scenarios" block that spies on
adminTableService.blockOrders and component.showBlockedInfo, then delete the
expect(mockDatepicker.open).toHaveBeenCalled() line so the test only asserts
blockOrders was called, showBlockedInfo.emit was called with iAlertInfo, and the
cursor wait dispatch happened.

In @src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts:
- Around line 349-356: existingOrderId is declared as a number but the dialog
handler assigns null to it, causing TypeScript strict-null checks to fail;
update the existingOrderId property declaration on the component
(existingOrderId) to type number | null and adjust any initializations/usages
(e.g., where existingOrderId is read or assigned from orderId: number | null) to
handle possible null values so assignments like this.existingOrderId = null are
type-safe.
🧹 Nitpick comments (2)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts (2)

41-66: Stabilize the “current date” test by using a fixed mocked date (not new Date()).
Right now it’s likely fine because both sides use the mocked clock, but using a constant makes the test intention clearer and eliminates any clock/mock timing edge.

Proposed tweak
 beforeEach(() => {
   jasmine.clock().install();
-  jasmine.clock().mockDate(new Date());
+  jasmine.clock().mockDate(new Date(2024, 0, 1, 12, 0, 0));
   ...
 });

 ...
 it('should set current date on initialization', () => {
-  const mockDate = new Date();
-  expect(component.current).toEqual(mockDate);
+  expect(component.current).toEqual(new Date(2024, 0, 1, 12, 0, 0));
 });

74-211: Assert SetCursorWaite dispatch call order (optional), not just presence.
If the component ever dispatches additional actions, toHaveBeenCalledWith(...) can still pass while the UX regresses (e.g., false dispatched before true).

Example pattern
 component.edit(mockDatepicker as MatDatepicker<Date>);

- expect(store.dispatch).toHaveBeenCalledWith(SetCursorWaite({ isWaiting: true }));
+ expect(store.dispatch.calls.allArgs()).toEqual([
+   [SetCursorWaite({ isWaiting: true })],
+   [SetCursorWaite({ isWaiting: false })]
+ ]);
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be3cf63 and 21476db.

📒 Files selected for processing (2)
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-01T22:32:58.734Z
Learnt from: AndrewKozovyi
Repo: ita-social-projects/GreenCityClient PR: 3770
File: src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts:103-110
Timestamp: 2025-08-01T22:32:58.734Z
Learning: In UbsAdminCustomersComponent (src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts), using take(1) instead of takeUntilDestroyed(this.destroyRef) for the adminTableOfCustomersSelector$ subscription prevents excessive additional functionality from being triggered and works correctly for the component's initialization sequence.

Applied to files:

  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
📚 Learning: 2025-12-11T20:44:21.136Z
Learnt from: witolDark
Repo: ita-social-projects/GreenCityClient PR: 3921
File: src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts:214-214
Timestamp: 2025-12-11T20:44:21.136Z
Learning: In Angular projects using HttpClient, HTTP call observables complete after emitting a single value. Therefore, take(1) or takeUntil is not strictly required to prevent memory leaks for typical single-emission requests. However, using take(1) (or takeUntil in combination with a component-destruction signal) can improve readability and guard against accidental multiple emissions if the observable is reused or transformed. For files like src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts and other services using HttpClient, rely on HttpClient completion for single requests, but consider adding take(1) when subscribing in long-lived contexts or when the observable could emit more than once due to retries or stream augmentation.

Applied to files:

  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
🧬 Code graph analysis (2)
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts (2)
src/app/store/actions/order.actions.ts (4)
  • GetOrderDetails (94-94)
  • GetExistingOrderDetails (109-109)
  • GetCourierLocations (97-97)
  • SetTariff (93-93)
src/app/ubs/ubs/models/ubs.interface.ts (1)
  • ActiveTariffInfo (276-283)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts (1)
src/app/store/actions/ubs-admin.actions.ts (1)
  • SetCursorWaite (10-10)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (2)
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts (2)

57-58: LGTM! Good separation of ID and display name.

The refactor to separate currentTariff (ID) as a number from currentTariffName (display) as a string improves type safety and clarity. This aligns well with the ActiveTariffInfo interface and the action signatures that expect numeric tariffId values.


160-165: Verified: getTariffName method exists and is correctly implemented.

The OrderService.getTariffName() method is properly defined at line 240 in src/app/ubs/ubs/services/order.service.ts, takes an ActiveTariffInfo parameter, and returns a localized tariff name string via langService.getLangValue(). The tariff handling logic at lines 160-165 correctly extracts the ID and name, dispatches type-safe numeric tariffId values, and appropriately handles both existing and new orders.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts (2)

74-80: Consider testing locale effects via public interface.

While the test correctly verifies that adapter.setLocale is called, accessing private properties with bracket notation (component['adapter']) couples tests to implementation details. If feasible, consider testing the observable effect of locale changes through the public API instead.


282-302: Verify that console.error is sufficient for invalid date handling.

The tests verify that console.error is called for null/undefined date values. While this provides debugging output, consider whether the component should:

  • Throw an error to fail fast
  • Emit a specific error event
  • Display a user-facing error message

Console errors are easily missed in production and may not provide adequate error recovery.

Do you want me to suggest a more robust error handling approach?

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21476db and 1b794ea.

📒 Files selected for processing (1)
  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-01T22:32:58.734Z
Learnt from: AndrewKozovyi
Repo: ita-social-projects/GreenCityClient PR: 3770
File: src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts:103-110
Timestamp: 2025-08-01T22:32:58.734Z
Learning: In UbsAdminCustomersComponent (src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.ts), using take(1) instead of takeUntilDestroyed(this.destroyRef) for the adminTableOfCustomersSelector$ subscription prevents excessive additional functionality from being triggered and works correctly for the component's initialization sequence.

Applied to files:

  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
📚 Learning: 2025-12-11T20:44:21.136Z
Learnt from: witolDark
Repo: ita-social-projects/GreenCityClient PR: 3921
File: src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts:214-214
Timestamp: 2025-12-11T20:44:21.136Z
Learning: In Angular projects using HttpClient, HTTP call observables complete after emitting a single value. Therefore, take(1) or takeUntil is not strictly required to prevent memory leaks for typical single-emission requests. However, using take(1) (or takeUntil in combination with a component-destruction signal) can improve readability and guard against accidental multiple emissions if the observable is reused or transformed. For files like src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-select/table-cell-select.component.ts and other services using HttpClient, rely on HttpClient completion for single requests, but consider adding take(1) when subscribing in long-lived contexts or when the observable could emit more than once due to retries or stream augmentation.

Applied to files:

  • src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (6)
src/app/ubs/ubs-admin/components/ubs-admin-table/table-cell-date/table-cell-date.component.spec.ts (6)

1-56: LGTM! Well-structured test setup.

The test configuration is comprehensive with appropriate mocks for the MatDatepicker, MockStore, and ChangeDetectorRef. The jasmine clock setup for date testing is a good practice.


58-72: LGTM! Proper initialization coverage.

The initialization tests appropriately verify component creation and default state setup.


82-219: Excellent coverage of edit flow, including keyboard accessibility.

The edit() method tests comprehensively cover:

  • Early returns for uneditable states
  • Keyboard navigation (Enter/Space keys) for accessibility
  • Loading state management via SetCursorWaite
  • All branching logic for order selection (isAllChecked, ordersToChange, id)
  • Datepicker interaction and blocked order handling

The keyboard event tests (lines 98-132) are particularly valuable for ensuring accessibility compliance.


221-280: LGTM! Comprehensive date formatting coverage.

The tests thoroughly verify:

  • ISO 8601 date format (yyyy-MM-dd) with leading zeros
  • Edge cases: start of year (01-01) and end of year (12-31)
  • Proper IEditCell object emission with id, nameOfColumn, and newValue

The date formatting validation is particularly robust.


321-365: LGTM! Modern Angular testing approach for Input properties.

The tests use fixture.componentRef.setInput(), which is the recommended Angular 14+ approach for testing @input() properties. All input properties are covered:

  • date, nameOfColumn, id
  • ordersToChange, isAllChecked
  • uneditableStatus

367-404: Excellent end-to-end integration coverage.

The integration tests verify complete workflows:

  • Full edit flow when orders are not blocked (datepicker opens, cursor states managed)
  • Full edit flow when orders are blocked (showBlockedInfo emitted, proper cleanup)

These tests provide valuable regression protection by testing multiple components working together (store, service, datepicker, change detection).

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2026

@witolDark witolDark merged commit ee06bf3 into dev Jan 9, 2026
3 checks passed
@witolDark witolDark deleted the Spelina/style-leakage-fix branch January 9, 2026 14:45
softservedata pushed a commit that referenced this pull request Jan 16, 2026
* changed view encapsulation from none to emulated in main page comp to fix styles leakage

* Bugfix/table cell date and address fix (#3930)

* Bugfix/table col width fix, changed pwa app name  (#3929)

* changed pwa app name

* admin table row styles

* Bugfix #8972 profile deactivation (#3925)

* Fix #8972 changed profile deactivation base url, changed a request body format

* Fix #8972 changed profile deactivation base url, changed a request body format

* Bugfix/added technical support block to main page and fixed styles (#3932)

* added technical support block for main page

* fixed translation for new tech support quills, fixed styles for main page

* tests fix

* Fix/frontend bugs (#3931)

* Add snack-bar instead 'offline' field in header

* Add filter tags for Customers

* Fix sorting in customers orders table

* Remove coma

* Add tests for snack bar and filter tags

* Fix coderabbit issues

* Fix coderabbit issues

* Remove commas

---------

Co-authored-by: vryazh <vryazhskaya@gmail.com>
Co-authored-by: Saienko Volodymyr <48810972+SaenkoVova@users.noreply.github.com>
Co-authored-by: AnastasiaRakuta <168209962+AnastasiaRakuta@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants