diff --git a/src/app/header/progress-bar/progress-bar.component.html b/src/app/header/progress-bar/progress-bar.component.html
index ae115b11aa..de6a7d0b6e 100644
--- a/src/app/header/progress-bar/progress-bar.component.html
+++ b/src/app/header/progress-bar/progress-bar.component.html
@@ -1,5 +1,13 @@
diff --git a/src/app/header/progress-bar/progress-bar.component.ts b/src/app/header/progress-bar/progress-bar.component.ts
index a7e19ca4cf..9cfa6dc1cc 100644
--- a/src/app/header/progress-bar/progress-bar.component.ts
+++ b/src/app/header/progress-bar/progress-bar.component.ts
@@ -1,3 +1,5 @@
+import { RegistrationState } from 'src/app/shared/store/registration.state';
+import { ProviderState } from './../../shared/store/provider.state';
import { MainPageState } from 'src/app/shared/store/main-page.state';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Select } from '@ngxs/store';
@@ -24,6 +26,10 @@ export class ProgressBarComponent implements OnInit, OnDestroy {
isLoadingAdminData$: Observable;
@Select(MainPageState.isLoadingData)
isLoadingMainPage$: Observable;
+ @Select(ProviderState.isLoading)
+ isLoadingProvider$: Observable;
+ @Select(RegistrationState.isAutorizationLoading)
+ isAutorizationLoading$: Observable;
isLoadingResultPage: boolean;
isLoadingCabinet: boolean;
@@ -31,6 +37,8 @@ export class ProgressBarComponent implements OnInit, OnDestroy {
isLoadingAdminData: boolean;
isLoadingNotifications: boolean;
isLoadingMainPage: boolean;
+ isAutorizationLoading: boolean;
+ isLoadingProvider: boolean;
private destroy$: Subject = new Subject();
@@ -42,16 +50,30 @@ export class ProgressBarComponent implements OnInit, OnDestroy {
this.isLoadingMetaData$,
this.isLoadingCabinet$,
this.isLoadingAdminData$,
- this.isLoadingMainPage$
+ this.isLoadingMainPage$,
+ this.isAutorizationLoading$,
+ this.isLoadingProvider$,
])
.pipe(takeUntil(this.destroy$), delay(0))
- .subscribe(([isLoadingResult, isLoadingMeta, isLoadingCabinet, isLoadingAdminData, isLoadingMainPage]) => {
- this.isLoadingResultPage = isLoadingResult;
- this.isLoadingMetaData = isLoadingMeta;
- this.isLoadingCabinet = isLoadingCabinet;
- this.isLoadingAdminData = isLoadingAdminData;
- this.isLoadingMainPage = isLoadingMainPage;
- });
+ .subscribe(
+ ([
+ isLoadingResult,
+ isLoadingMeta,
+ isLoadingCabinet,
+ isLoadingAdminData,
+ isLoadingMainPage,
+ isAutorizationLoading,
+ isLoadingProvider,
+ ]) => {
+ this.isLoadingResultPage = isLoadingResult;
+ this.isLoadingMetaData = isLoadingMeta;
+ this.isLoadingCabinet = isLoadingCabinet;
+ this.isLoadingAdminData = isLoadingAdminData;
+ this.isLoadingMainPage = isLoadingMainPage;
+ this.isAutorizationLoading = isAutorizationLoading;
+ this.isLoadingProvider = isLoadingProvider;
+ }
+ );
}
ngOnDestroy(): void {
diff --git a/src/app/shared/components/workshop-card/workshop-card.component.html b/src/app/shared/components/workshop-card/workshop-card.component.html
index 1f0b8a2ee4..34749d7f81 100644
--- a/src/app/shared/components/workshop-card/workshop-card.component.html
+++ b/src/app/shared/components/workshop-card/workshop-card.component.html
@@ -86,7 +86,7 @@
+ (click)="role === Role.parent && onDisLike()">
favorite
diff --git a/src/app/shared/components/workshop-card/workshop-card.component.ts b/src/app/shared/components/workshop-card/workshop-card.component.ts
index 5acc9351d7..3c49bb1a4c 100644
--- a/src/app/shared/components/workshop-card/workshop-card.component.ts
+++ b/src/app/shared/components/workshop-card/workshop-card.component.ts
@@ -38,10 +38,12 @@ export class WorkshopCardComponent implements OnInit, OnDestroy {
readonly recruitmentStatusUkr = RecruitmentStatusUkr;
readonly modalConfirmationType = ModalConfirmationType;
- isFavorite: boolean;
+ isFavorite = false;
canChangeWorkshopStatus: boolean;
workshopData: ProviderWorkshopCard | WorkshopCard;
+ private favoriteWorkshopId: string;
+
@Input() set workshop(workshop: WorkshopCard) {
this.workshopData = workshop;
this.imagesService.setWorkshopCoverImage(workshop);
@@ -95,9 +97,9 @@ export class WorkshopCardComponent implements OnInit, OnDestroy {
this.isFavorite = !this.isFavorite;
}
- onDisLike(id: string): void {
+ onDisLike(): void {
this.store.dispatch([
- new DeleteFavoriteWorkshop(id),
+ new DeleteFavoriteWorkshop(this.favoriteWorkshopId),
new ShowMessageBar({ message: `Гурток ${this.workshopData.title} видалено з Улюблених`, type: 'success' }),
]);
this.isFavorite = !this.isFavorite;
@@ -139,7 +141,11 @@ export class WorkshopCardComponent implements OnInit, OnDestroy {
filter((favorites: Favorite[]) => !!favorites)
)
.subscribe((favorites: Favorite[]) => {
- this.isFavorite = !!favorites.find((item: Favorite) => item.workshopId === this.workshopData.workshopId);
+ const favorite = favorites.find((item: Favorite) => item.workshopId === this.workshopData.workshopId);
+ if (!!favorite) {
+ this.favoriteWorkshopId = favorite.id;
+ this.isFavorite = true;
+ }
});
}
}
diff --git a/src/app/shared/store/user.state.ts b/src/app/shared/store/user.state.ts
index 720ce05516..6af96966ce 100644
--- a/src/app/shared/store/user.state.ts
+++ b/src/app/shared/store/user.state.ts
@@ -6,7 +6,7 @@ import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { State, Action, StateContext, Selector } from '@ngxs/store';
import { Observable, of, throwError } from 'rxjs';
-import { catchError, tap } from 'rxjs/operators';
+import { catchError, tap, debounceTime } from 'rxjs/operators';
import { ApplicationCards } from '../models/application.model';
import { ChildCards } from '../models/child.model';
import { Provider } from '../models/provider.model';
@@ -160,7 +160,6 @@ export class UserState {
return state.isReviewed;
}
-
constructor(
private userWorkshopService: UserWorkshopService,
private applicationService: ApplicationService,
@@ -269,10 +268,7 @@ export class UserState {
}
@Action(GetUsersChildren)
- getUsersChildren(
- { patchState }: StateContext,
- {}: GetUsersChildren
- ): Observable {
+ getUsersChildren({ patchState }: StateContext, {}: GetUsersChildren): Observable {
patchState({ isLoading: true });
return this.childrenService
.getUsersChildren()
@@ -288,13 +284,10 @@ export class UserState {
}
@Action(GetUsersChildById)
- getUsersChildById(
- { patchState }: StateContext,
- { payload }: GetUsersChildById
- ): Observable {
- patchState({ isLoading: true });
- return this.childrenService
- .getUsersChildById( payload )
+ getUsersChildById({ patchState }: StateContext, { payload }: GetUsersChildById): Observable {
+ patchState({ isLoading: true });
+ return this.childrenService
+ .getUsersChildById(payload)
.pipe(tap((selectedChild: Child) => patchState({ selectedChild: selectedChild, isLoading: false })));
}
@@ -455,13 +448,11 @@ export class UserState {
{ parentId, workshopId }: GetStatusAllowedToReview
): Observable {
patchState({ isLoading: true });
- return this.applicationService
- .getApplicationsAllowedToReview(parentId, workshopId)
- .pipe(
- tap((status: boolean) => {
- return patchState({ isAllowedToReview: status, isLoading: false });
- })
- );
+ return this.applicationService.getApplicationsAllowedToReview(parentId, workshopId).pipe(
+ tap((status: boolean) => {
+ return patchState({ isAllowedToReview: status, isLoading: false });
+ })
+ );
}
@Action(GetReviewedApplications)
@@ -470,13 +461,11 @@ export class UserState {
{ parentId, workshopId }: GetReviewedApplications
): Observable {
patchState({ isLoading: true });
- return this.applicationService
- .getReviewedApplications(parentId, workshopId)
- .pipe(
- tap((status: boolean) => {
- return patchState({ isReviewed: status, isLoading: false });
- })
- );
+ return this.applicationService.getReviewedApplications(parentId, workshopId).pipe(
+ tap((status: boolean) => {
+ return patchState({ isReviewed: status, isLoading: false });
+ })
+ );
}
@Action(CreateRating)
@@ -531,9 +520,10 @@ export class UserState {
{ dispatch }: StateContext,
{ payload }: CreateFavoriteWorkshop
): Observable