Skip to content

Commit 1586245

Browse files
witolDarkViktoriyaRyazhskaSaenkoVovaAnastasiaRakuta
authored
Spelina/prod update (#3933)
* 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>
1 parent fc6f110 commit 1586245

39 files changed

+950
-418
lines changed

src/app/app.component.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<div *ngIf="offline" class="offline">
2-
<span>offline</span>
3-
</div>
4-
51
<router-outlet></router-outlet>
62

73
<app-chat-contact-admin-pop-up></app-chat-contact-admin-pop-up>

src/app/app.component.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
@import '../typography/typography';
22

3-
.offline {
4-
top: 50px;
5-
left: 50%;
6-
position: fixed;
7-
font-weight: 500;
8-
font-size: larger;
9-
background: transparent;
10-
color: var(--error-red);
11-
z-index: 999;
12-
}
13-
143
::ng-deep .mat-select:focus-visible {
154
outline: 2px solid currentcolor !important;
165
}

src/app/app.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { filter, Subject } from 'rxjs';
77
import { LocalStorageService } from 'src/app/shared/services/localstorage/local-storage.service';
88
import { MetaService } from 'src/app/shared/services/meta/meta.service';
99
import { SwUpdate, VersionReadyEvent } from '@angular/service-worker';
10+
import { MatSnackBarService } from '@global-service/mat-snack-bar/mat-snack-bar.service';
1011

1112
@Component({
1213
selector: 'app-root',
@@ -21,7 +22,7 @@ export class AppComponent implements OnInit, OnDestroy {
2122
private readonly destroy$: Subject<void> = new Subject<void>();
2223
router: Router = inject(Router);
2324
metaService: MetaService = inject(MetaService);
24-
offline: boolean;
25+
private readonly snackBar = inject(MatSnackBarService);
2526

2627
ngOnInit(): void {
2728
this.metaService.setMetaOnRouteChange();
@@ -45,7 +46,9 @@ export class AppComponent implements OnInit, OnDestroy {
4546
}
4647

4748
onNetworkStatusChange(): void {
48-
this.offline = !navigator.onLine;
49+
if (!navigator.onLine) {
50+
this.snackBar.openSnackBar('noInternet');
51+
}
4952
}
5053

5154
ngOnDestroy(): void {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class MatSnackBarService {
3838
successConfirmEmail: { classname: SnackbarClassName.success, key: 'snack-bar.success.confirm-email' },
3939
successConfirmSaveOrder: { classname: SnackbarClassName.successUbs, key: 'snack-bar.saved-order' },
4040
successConfirmUpdateOrder: { classname: SnackbarClassName.successUbs, key: 'snack-bar.update-order' },
41+
errorOrderUnauthorized: { classname: SnackbarClassName.error, key: 'snack-bar.error.order-not-authorized' },
4142
successUpdateUbsData: { classname: SnackbarClassName.successUbs, key: 'snack-bar.save-employee-permissons' },
4243
cafeNotificationsExists: { classname: SnackbarClassName.error, key: 'update-cafe.notifications.exists' },
4344
cafeNotificationsCloseTime: { classname: SnackbarClassName.error, key: 'update-cafe.notifications.closeTime' },
@@ -50,7 +51,7 @@ export class MatSnackBarService {
5051
habitDidNotGiveUp: { classname: SnackbarClassName.success, key: 'user.habit.all-habits.habit-did-not-give-up' },
5152
habitUpdated: { classname: SnackbarClassName.success, key: 'user.habit.all-habits.new-habit-updated' },
5253
habitAcquired: { classname: SnackbarClassName.success, key: 'user.habit.all-habits.habit-acquired' },
53-
errorMessage: { classname: SnackbarClassName.error },
54+
errorMessage: { classname: SnackbarClassName.error, key: 'snack-bar.error.error' },
5455
sendNewLetter: { classname: SnackbarClassName.error, key: 'snack-bar.error.restore-password-again' },
5556
sendNewUnblockLetter: { classname: SnackbarClassName.error, key: 'snack-bar.error.unblock-account-again' },
5657
changesSaved: { classname: SnackbarClassName.success, key: 'user.edit-profile.profile-changes-saved' },

src/app/store/actions/order.actions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createAction, props } from '@ngrx/store';
22
import { IUserOrderInfo } from '@ubs/ubs-user/components/ubs-user-orders-list/models/UserOrder.interface';
33
import { ActiveTariffInfo, Address, AddressData, CourierLocations, OrderDetails, PersonalData } from 'src/app/ubs/ubs/models/ubs.interface';
44
import { CCertificate } from 'src/app/ubs/ubs/models/ubs.model';
5+
import { HttpErrorResponse } from '@angular/common/http';
56

67
export enum OrderActions {
78
SetCurrentStep = '[Order] Set Current Step',
@@ -37,6 +38,7 @@ export enum OrderActions {
3738

3839
GetExistingOrderDetails = '[Order] Get Existing Order Details',
3940
GetExistingOrderDetailsSuccess = '[Order] Get Existing Order Details Success',
41+
GetExistingOrderDetailsFail = '[Order] Get Existing Order Details Fail',
4042

4143
GetExistingOrderTariff = '[Order] Get Existing Order Tariff',
4244
GetExistingOrderTariffSuccess = '[Order] Get Existing Order Tariff Success',
@@ -109,6 +111,7 @@ export const GetExistingOrderDetailsSuccess = createAction(
109111
OrderActions.GetExistingOrderDetailsSuccess,
110112
props<{ orderDetails: OrderDetails }>()
111113
);
114+
export const GetExistingOrderDetailsFail = createAction(OrderActions.GetExistingOrderDetailsFail, props<{ error: HttpErrorResponse }>());
112115

113116
export const GetExistingOrderTariff = createAction(OrderActions.GetExistingOrderTariff, props<{ orderId: number }>());
114117
export const GetExistingOrderTariffSuccess = createAction(

src/app/store/effects/order.effects.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { Actions, createEffect, ofType } from '@ngrx/effects';
33
import { catchError, map, mergeMap, tap } from 'rxjs/operators';
4-
import { EMPTY, of } from 'rxjs';
4+
import { EMPTY, filter, of } from 'rxjs';
55
import {
66
CreateAddress,
77
CreateAddressFail,
@@ -14,6 +14,7 @@ import {
1414
GetCourierLocationsSuccess,
1515
GetExistingOrderDetails,
1616
GetExistingOrderDetailsSuccess,
17+
GetExistingOrderDetailsFail,
1718
GetExistingOrderInfo,
1819
GetExistingOrderInfoSuccess,
1920
GetExistingOrderTariff,
@@ -35,14 +36,17 @@ import { OrderService } from 'src/app/ubs/ubs/services/order.service';
3536
import { LocalStorageService } from 'src/app/shared/services/localstorage/local-storage.service';
3637
import { Address, AddressData } from 'src/app/ubs/ubs/models/ubs.interface';
3738
import { MatSnackBarService } from '@global-service/mat-snack-bar/mat-snack-bar.service';
39+
import { HttpErrorResponse } from '@angular/common/http';
40+
import { Router } from '@angular/router';
3841

3942
@Injectable()
4043
export class OrderEffects {
4144
constructor(
4245
private readonly actions: Actions,
4346
private readonly orderService: OrderService,
4447
private readonly localStorageService: LocalStorageService,
45-
private readonly snackBar: MatSnackBarService
48+
private readonly snackBar: MatSnackBarService,
49+
private readonly router: Router
4650
) {}
4751

4852
getOrderDetails = createEffect(() =>
@@ -64,12 +68,25 @@ export class OrderEffects {
6468
mergeMap((action: { orderId: number }) =>
6569
this.orderService.getExistingOrderDetails(action.orderId).pipe(
6670
map((orderDetails) => GetExistingOrderDetailsSuccess({ orderDetails })),
67-
catchError(() => EMPTY)
71+
catchError((error: HttpErrorResponse) => of(GetExistingOrderDetailsFail({ error })))
6872
)
6973
)
7074
)
7175
);
7276

77+
getExistingOrderDetailsFail = createEffect(
78+
() =>
79+
this.actions.pipe(
80+
ofType(GetExistingOrderDetailsFail),
81+
filter(({ error }) => error.status === 403),
82+
tap(() => {
83+
this.snackBar.openSnackBar('errorOrderUnauthorized');
84+
this.router.navigate(['/ubs/user/orders']);
85+
})
86+
),
87+
{ dispatch: false }
88+
);
89+
7390
getExistingOrderTariff = createEffect(() =>
7491
this.actions.pipe(
7592
ofType(GetExistingOrderTariff),

src/app/store/functions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export function transformAddress(input: any) {
22
return {
3-
region: { uk: input.region, en: input.regionEn },
4-
city: { uk: input.city, en: input.cityEn },
5-
district: { uk: input.district, en: input.districtEn },
3+
region: { uk: input.regionUk, en: input.regionEn },
4+
city: { uk: input.cityUk, en: input.cityEn },
5+
district: { uk: input.districtUk, en: input.districtEn },
66
address: {
7-
uk: `${input.street} ${input.houseNumber}, корп.- ${input.houseCorpus || ''}, п.${input.entranceNumber}`,
7+
uk: `${input.streetUk} ${input.houseNumber}, корп.- ${input.houseCorpus || ''}, п.${input.entranceNumber}`,
88
en: `${input.streetEn} ${input.houseNumber}, b.- ${input.houseCorpus || ''}, e.${input.entranceNumber}`
99
},
1010
commentToAddressForClient: input.addressComment || ''
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface FilterCustomers {
2+
key: string;
3+
labelKey: string;
4+
fromValue?: string | null;
5+
toValue?: string | null;
6+
fromControl: string;
7+
toControl: string;
8+
isDate?: boolean;
9+
}

src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customer-orders/ubs-admin-customer-orders.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
<th id="head" mat-header-cell *matHeaderCellDef [appResizeColumn]="{ resizable: true, index: i }">
1919
<div class="columns_header">
2020
<span>{{ column.title | serverTranslate: currentLang }}</span>
21-
<mat-icon *ngIf="arrowDirection !== column.title.key" (click)="onSortTable(column.title.key, 'DESC')">
21+
<mat-icon *ngIf="arrowDirection !== column.title.key" (click)="onSortTable(column.title.key, 'ASC')">
2222
arrow_downward
2323
</mat-icon>
24-
<mat-icon *ngIf="arrowDirection === column.title.key" (click)="onSortTable(column.title.key, 'ASC')"> arrow_upward </mat-icon>
24+
<mat-icon *ngIf="arrowDirection === column.title.key" (click)="onSortTable(column.title.key, 'DESC')">
25+
arrow_upward
26+
</mat-icon>
2527
</div>
2628
</th>
2729
<td mat-cell *matCellDef="let row">

src/app/ubs/ubs-admin/components/ubs-admin-customers/ubs-admin-customers.component.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,25 @@
285285
</div>
286286
</div>
287287
</div>
288+
<div class="tag-filtrs-list" *ngIf="activeFilters.length">
289+
<div class="tag-filter-item" *ngFor="let filter of activeFilters">
290+
<button
291+
type="button"
292+
class="remove-item-btn"
293+
(click)="removeActiveFilter(filter)"
294+
[attr.aria-label]="'ubs-tables.clear-filters' | translate"
295+
></button>
296+
<span class="filter-content">
297+
{{ filter.labelKey | translate }}
298+
<ng-container *ngIf="filter.fromValue">
299+
{{ 'ubs-customer-filters.from' | translate }} {{ filter.fromValue }}
300+
</ng-container>
301+
<ng-container *ngIf="filter.toValue">
302+
{{ 'ubs-customer-filters.to' | translate }} {{ filter.toValue }}
303+
</ng-container>
304+
</span>
305+
</div>
306+
</div>
288307

289308
<div id="table-container" class="scrolling" infiniteScroll [infiniteScrollThrottle]="100" (scrolled)="onScroll()" [scrollWindow]="false">
290309
<mat-table [dataSource]="dataSource" id="table" class="customers_table" *ngIf="!isLoading" cdkDropListGroup>

0 commit comments

Comments
 (0)