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 e0853f77b2..1f0b8a2ee4 100644 --- a/src/app/shared/components/workshop-card/workshop-card.component.html +++ b/src/app/shared/components/workshop-card/workshop-card.component.html @@ -1,6 +1,5 @@ - - +
@@ -10,7 +9,8 @@ [src]="workshopData['_meta']" alt="{{ workshopData.title }}" />
-
+ +
@@ -33,19 +33,17 @@ - - + - - + + Детальніше arrow_forward - + add Додати досягнення @@ -80,15 +78,15 @@ -
+
+ class="actions_btn action-icon favorite-icon" + (click)="role === Role.parent && onDisLike(this.favoriteWorkshopId?.id)"> favorite
@@ -122,7 +120,7 @@

Очікує підтвердження:

- {{ pendingApplicationAmount }} + {{ workshopData.amountOfPendingApplications }}
@@ -164,7 +162,7 @@ account_balance Форма власності: {{ ownershipTypeUkr[workshopData.providerOwnership] }}

-

+

person {{ workshopData.minAge }} - {{ workshopData.maxAge }} років

diff --git a/src/app/shared/components/workshop-card/workshop-card.component.spec.ts b/src/app/shared/components/workshop-card/workshop-card.component.spec.ts index ad79c24c2e..1cb313723a 100644 --- a/src/app/shared/components/workshop-card/workshop-card.component.spec.ts +++ b/src/app/shared/components/workshop-card/workshop-card.component.spec.ts @@ -37,7 +37,6 @@ describe('WorkshopCardComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(WorkshopCardComponent); component = fixture.componentInstance; - component.application = { status: null } as Application; component.workshop = { workshopId: 1, title: '', 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 fc336e74a4..5acc9351d7 100644 --- a/src/app/shared/components/workshop-card/workshop-card.component.ts +++ b/src/app/shared/components/workshop-card/workshop-card.component.ts @@ -1,14 +1,12 @@ +import { ProviderWorkshopCard } from './../../models/workshop.model'; import { OwnershipTypeName } from './../../enum/provider'; import { Favorite } from './../../models/favorite.model'; import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { Select, Store } from '@ngxs/store'; -import { ApplicationStatus } from '../../enum/applications'; -import { ApplicationTitles } from 'src/app/shared/enum/enumUA/applications'; import { Role } from '../../enum/role'; -import { Application } from '../../models/application.model'; import { WorkshopCard } from '../../models/workshop.model'; import { RegistrationState } from '../../store/registration.state'; -import { CreateFavoriteWorkshop, DeleteFavoriteWorkshop, UpdateStatus } from '../../store/user.actions'; +import { CreateFavoriteWorkshop, DeleteFavoriteWorkshop } from '../../store/user.actions'; import { ShowMessageBar } from '../../store/app.actions'; import { UserState } from '../../store/user.state'; import { Observable, Subject } from 'rxjs'; @@ -22,6 +20,7 @@ import { ConfirmationModalWindowComponent } from '../confirmation-modal-window/c import { ModalConfirmationType } from '../../enum/modal-confirmation'; import { WorkhopStatus } from '../../enum/workshop'; import { OwnershipTypeUkr } from '../../enum/enumUA/provider'; +import { UpdateWorkshopStatus } from '../../store/provider.actions'; @Component({ selector: 'app-workshop-card', @@ -29,10 +28,8 @@ import { OwnershipTypeUkr } from '../../enum/enumUA/provider'; styleUrls: ['./workshop-card.component.scss'], }) export class WorkshopCardComponent implements OnInit, OnDestroy { - readonly applicationTitles = ApplicationTitles; - readonly applicationStatus = ApplicationStatus; readonly ownershipTypeUkr = OwnershipTypeUkr; - readonly Role: typeof Role = Role; + readonly Role = Role; readonly tooltipPosition = Constants.MAT_TOOL_TIP_POSITION_BELOW; readonly categoryIcons = CategoryIcons; readonly PayRateTypeUkr = PayRateTypeUkr; @@ -43,43 +40,43 @@ export class WorkshopCardComponent implements OnInit, OnDestroy { isFavorite: boolean; canChangeWorkshopStatus: boolean; - pendingApplicationAmount: number; - workshopData: WorkshopCard; + workshopData: ProviderWorkshopCard | WorkshopCard; @Input() set workshop(workshop: WorkshopCard) { this.workshopData = workshop; this.imagesService.setWorkshopCoverImage(workshop); } - @Input() userRoleView: string; - @Input() isMainPage: boolean; - @Input() application: Application; + + @Input() isCabinetView: boolean = false; @Input() isHorizontalView = false; - @Input() isCreateApplicationView = false; - @Input() icons: {}; + @Input() isCreateFormView = false; @Output() deleteWorkshop = new EventEmitter(); - @Output() leaveWorkshop = new EventEmitter(); @Select(UserState.favoriteWorkshops) favoriteWorkshops$: Observable; @Select(RegistrationState.role) - role$: Observable; - role: string; + role$: Observable; + role: Role; destroy$: Subject = new Subject(); - constructor(private store: Store, public dialog: MatDialog, private imagesService: ImagesService) {} + constructor(private store: Store, private dialog: MatDialog, private imagesService: ImagesService) {} ngOnInit(): void { - this.canChangeWorkshopStatus = !( - this.workshopData.providerOwnership === OwnershipTypeName.State || - this.workshopData.availableSeats === this.UNLIMITED_SEATS - ); - this.role$.pipe(takeUntil(this.destroy$)).subscribe((role: string) => { - this.role = role; - if (this.role === Role.parent) { + if (this.isCabinetView) { + this.canChangeWorkshopStatus = !( + this.workshopData.providerOwnership === OwnershipTypeName.State || + (this.workshopData as ProviderWorkshopCard).availableSeats === this.UNLIMITED_SEATS + ); + } + + this.role$ + .pipe(takeUntil(this.destroy$)) + .pipe(filter((role: Role) => role === Role.parent)) + .subscribe((role: Role) => { this.getFavoriteWorkshops(); - } - }); + this.role = role; + }); } onDelete(): void { @@ -117,16 +114,15 @@ export class WorkshopCardComponent implements OnInit, OnDestroy { dialogRef.afterClosed().subscribe((res: boolean) => { if (res) { this.store.dispatch( - new UpdateStatus({ workshopId: this.workshopData.workshopId, status: status }, this.workshopData.providerId) + new UpdateWorkshopStatus( + { workshopId: this.workshopData.workshopId, status: status }, + this.workshopData.providerId + ) ); } }); } - onWorkshopLeave(): void { - this.leaveWorkshop.emit(this.application); - } - onOpenDialog(): void { this.dialog.open(WorkshopCardDialog); } diff --git a/src/app/shared/models/workshop.model.ts b/src/app/shared/models/workshop.model.ts index c12d4de458..69a2da67b7 100644 --- a/src/app/shared/models/workshop.model.ts +++ b/src/app/shared/models/workshop.model.ts @@ -1,4 +1,5 @@ import { Direction } from 'src/app/shared/models/category.model'; +import { WorkhopStatus } from '../enum/workshop'; import { Address } from './address.model'; import { Provider } from './provider.model'; import { SectionItem } from './sectionItem.model'; @@ -95,7 +96,7 @@ export class Workshop { if (about.price) { this.price = about.price; } - if(about.availableSeats){ + if (about.availableSeats) { this.availableSeats = about.availableSeats; } } @@ -112,26 +113,43 @@ export class WorkshopSectionItem extends SectionItem { } } } -export interface WorkshopCard { - address: Address; - directionId: number; +export interface WorkshopBaseCard { + workshopId: string; + title: string; + directionsId: number[]; + coverImageId?: string; +} + +export interface ProviderWorkshopCard extends WorkshopBaseCard { + providerTitle: string; + providerOwnership: string; + providerId: string; payRate: string; maxAge: number; minAge: number; - photo?: string; price: number; - providerId: string; + address: Address; + availableSeats: number; + takenSeats: number; + amountOfPendingApplications: number; + status: WorkhopStatus; +} + +export interface WorkshopCard extends WorkshopBaseCard { + workshopId: string; providerTitle: string; providerOwnership: string; - rating: number; + providerId: string; title: string; - workshopId: string; + payRate: string; coverImageId?: string; + maxAge: number; + minAge: number; + price: number; directionsId: number[]; - status: string; - availableSeats: number; - takenSeats: number; + address: Address; } + export interface WorkshopFilterCard { totalAmount: number; entities: WorkshopCard[]; @@ -140,4 +158,4 @@ export interface WorkshopFilterCard { export interface WorkshopStatus { workshopId: string; status: string; -} \ No newline at end of file +} diff --git a/src/app/shared/services/provider/provider.service.ts b/src/app/shared/services/provider/provider.service.ts index b53807bf01..de7344f422 100644 --- a/src/app/shared/services/provider/provider.service.ts +++ b/src/app/shared/services/provider/provider.service.ts @@ -40,17 +40,17 @@ export class ProviderService { * This method create Provider * @param Provider */ - createProvider(provider: Provider, isRelease3: boolean): Observable { + createProvider(provider: Provider, isRelease3: boolean): Observable { return isRelease3 ? this.createProviderV2(provider) : this.createProviderV1(provider); } - createProviderV1(provider: Provider): Observable { - return this.http.post('/api/v1/Provider/Create', provider); + createProviderV1(provider: Provider): Observable { + return this.http.post('/api/v1/Provider/Create', provider); } - createProviderV2(provider: Provider): Observable { + createProviderV2(provider: Provider): Observable { const formData = Provider.createFormData(provider); - return this.http.post('/api/v2/Provider/Create', formData); + return this.http.post('/api/v2/Provider/Create', formData); } /** @@ -64,17 +64,17 @@ export class ProviderService { * This method update Provider * @param Provider */ - updateProvider(provider: Provider, isRelease3: boolean): Observable { + updateProvider(provider: Provider, isRelease3: boolean): Observable { return isRelease3 ? this.updateProviderV2(provider) : this.updateProviderV1(provider); } - updateProviderV1(provider: Provider): Observable { - return this.http.put('/api/v1/Provider/Update', provider); + updateProviderV1(provider: Provider): Observable { + return this.http.put('/api/v1/Provider/Update', provider); } - updateProviderV2(provider: Provider): Observable { + updateProviderV2(provider: Provider): Observable { const formData = Provider.createFormData(provider); - return this.http.put('/api/v2/Provider/Update', formData); + return this.http.put('/api/v2/Provider/Update', formData); } /** diff --git a/src/app/shared/services/workshops/user-workshop/user-workshop.service.ts b/src/app/shared/services/workshops/user-workshop/user-workshop.service.ts index 2689e4ab2a..facd4a5457 100644 --- a/src/app/shared/services/workshops/user-workshop/user-workshop.service.ts +++ b/src/app/shared/services/workshops/user-workshop/user-workshop.service.ts @@ -1,3 +1,5 @@ +import { WorkshopCard } from 'src/app/shared/models/workshop.model'; +import { ProviderWorkshopCard } from './../../../models/workshop.model'; import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Store } from '@ngxs/store'; @@ -17,21 +19,28 @@ export class UserWorkshopService { /** * This method get related workshops for provider admins */ - getProviderAdmisnWorkshops(): Observable { - return this.http.get(`/api/v1/ProviderAdmin/ManagedWorkshops`); + getProviderAdminsWorkshops(): Observable { + return this.http.get(`/api/v1/ProviderAdmin/ManagedWorkshops`); + } + + /** + * This method get related workshops for provider + */ + getProviderWorkshops(id: string): Observable { + return this.http.get(`/api/v1/Workshop/GetWorkshopProviderViewCardByproviderId/${id}`); } /** * This method get workshops by Provider id * @param id: string */ - getWorkshopsByProviderId(id: string, excludedWorkshopId?: string): Observable { + getWorkshopsByProviderId(id: string, excludedWorkshopId?: string): Observable { let params = new HttpParams(); if (excludedWorkshopId) { params = params.set('excludedWorkshopId', excludedWorkshopId); } - return this.http.get(`/api/v1/Workshop/GetByProviderId/${id}`, { params }); + return this.http.get(`/api/v1/Workshop/GetByProviderId/${id}`, { params }); } /** @@ -46,36 +55,36 @@ export class UserWorkshopService { * This method create workshop * @param workshop: Workshop */ - createWorkshop(workshop: Workshop): Observable { + createWorkshop(workshop: Workshop): Observable { this.isRelease3 = this.store.selectSnapshot(MetaDataState.featuresList).release3; return this.isRelease3 ? this.createWorkshopV2(workshop) : this.createWorkshopV1(workshop); } - createWorkshopV1(workshop: Workshop): Observable { - return this.http.post('/api/v1/Workshop/Create', workshop); + createWorkshopV1(workshop: Workshop): Observable { + return this.http.post('/api/v1/Workshop/Create', workshop); } - createWorkshopV2(workshop: Workshop): Observable { + createWorkshopV2(workshop: Workshop): Observable { const formData = this.createFormData(workshop); - return this.http.post('/api/v2/Workshop/Create', formData); + return this.http.post('/api/v2/Workshop/Create', formData); } /** * This method update workshop * @param workshop: Workshop */ - updateWorkshop(workshop: Workshop): Observable { + updateWorkshop(workshop: Workshop): Observable { this.isRelease3 = this.store.selectSnapshot(MetaDataState.featuresList).release2; return this.isRelease3 ? this.updateWorkshopV2(workshop) : this.updateWorkshopV1(workshop); } - updateWorkshopV1(workshop: Workshop): Observable { - return this.http.put('/api/v1/Workshop/Update', workshop); + updateWorkshopV1(workshop: Workshop): Observable { + return this.http.put('/api/v1/Workshop/Update', workshop); } - updateWorkshopV2(workshop: Workshop): Observable { + updateWorkshopV2(workshop: Workshop): Observable { const formData = this.createFormData(workshop); - return this.http.put('/api/v2/Workshop/Update', formData); + return this.http.put('/api/v2/Workshop/Update', formData); } /** diff --git a/src/app/shared/store/provider.actions.ts b/src/app/shared/store/provider.actions.ts index 204118ba47..8de807723a 100644 --- a/src/app/shared/store/provider.actions.ts +++ b/src/app/shared/store/provider.actions.ts @@ -1,5 +1,9 @@ +import { ProviderWorkshopCard, Workshop, WorkshopStatus } from './../models/workshop.model'; import { HttpErrorResponse } from '@angular/common/http'; import { Achievement } from '../models/achievement.model'; +import { Provider } from '../models/provider.model'; +import { ProviderAdmin } from '../models/providerAdmin.model'; +import { BlockedParent } from '../models/block.model'; export class GetAchievementById { static readonly type = '[provider] get achievement By Id'; @@ -60,3 +64,197 @@ export class OnDeleteAchievementFail { static readonly type = '[provider] delete Achievement fail'; constructor(public payload: HttpErrorResponse) {} } + +export class GetProviderAdminWorkshops { + static readonly type = '[provider] get Workshops for provider admin'; + constructor() {} +} + +export class GetProviderWorkshops { + static readonly type = '[provider] get Workshops for provider cabinet'; + constructor(public payload: string) {} +} + +export class GetAllProviderAdmins { + static readonly type = '[provider] get all users ProviderAdmins'; + constructor() {} +} + +export class CreateWorkshop { + static readonly type = '[provider] create Workshop'; + constructor(public payload: Workshop) {} +} + +export class OnCreateWorkshopFail { + static readonly type = '[provider] create Workshop fail'; + constructor(public payload: HttpErrorResponse) {} +} + +export class OnCreateWorkshopSuccess { + static readonly type = '[provider] create Workshop success'; + constructor(public payload) {} +} + +export class UpdateWorkshop { + static readonly type = '[provider] update Workshop'; + constructor(public payload: Workshop) {} +} + +export class OnUpdateWorkshopFail { + static readonly type = '[provider] update Workshop fail'; + constructor(public payload: HttpErrorResponse) {} +} + +export class OnUpdateWorkshopSuccess { + static readonly type = '[provider] update Workshop success'; + constructor(public payload: Workshop) {} +} + +export class DeleteWorkshopById { + static readonly type = '[provider] delete Workshop'; + constructor(public payload: ProviderWorkshopCard) {} +} + +export class OnDeleteWorkshopSuccess { + static readonly type = '[provider] delete Workshop success'; + constructor(public payload: ProviderWorkshopCard) {} +} + +export class OnDeleteWorkshopFail { + static readonly type = '[provider] delete Workshop fail'; + constructor(public payload: HttpErrorResponse) {} +} + +export class CreateProvider { + static readonly type = '[provider] create Provider'; + constructor(public payload: Provider, public isRelease3: boolean) {} +} + +export class OnCreateProviderFail { + static readonly type = '[provider] create Provider fail'; + constructor(public payload: HttpErrorResponse) {} +} + +export class OnCreateProviderSuccess { + static readonly type = '[provider] create Provider success'; + constructor(public payload: Provider) {} +} + +export class UpdateProvider { + static readonly type = '[provider] update Provider'; + constructor(public payload: Provider, public isRelease3: boolean) { } +} + +export class OnUpdateProviderFail { + static readonly type = '[provider] update Provider fail'; + constructor(public payload: HttpErrorResponse) { } +} + +export class OnUpdateProviderSuccess { + static readonly type = '[provider] update Provider success'; + constructor(public payload) { } +} + +export class CreateProviderAdmin { + static readonly type = '[provider] create Provider Admin'; + constructor(public payload: ProviderAdmin) {} +} + +export class OnCreateProviderAdminFail { + static readonly type = '[provider] create Provider Admin fail'; + constructor(public payload: HttpErrorResponse) {} +} + +export class OnCreateProviderAdminSuccess { + static readonly type = '[provider] create Provider Admin success'; + constructor(public payload: ProviderAdmin) {} +} + +export class BlockProviderAdminById { + static readonly type = '[provider] block Provider Admin'; + constructor(public payload) {} +} + +export class OnBlockProviderAdminSuccess { + static readonly type = '[provider] block Provider Admin success'; + constructor(public payload) {} +} + +export class OnBlockProviderAdminFail { + static readonly type = '[provider] block Provider Admin fail'; + constructor(public payload: HttpErrorResponse) {} +} + +export class DeleteProviderAdminById { + static readonly type = '[provider] delete Provider Admin'; + constructor(public payload) {} +} + +export class OnDeleteProviderAdminSuccess { + static readonly type = '[provider] delete Provider Admin success'; + constructor(public payload) {} +} + +export class OnDeleteProviderAdminFail { + static readonly type = '[provider] delete Provider Admin fail'; + constructor(public payload: HttpErrorResponse) {} +} + +export class UpdateWorkshopStatus { + static readonly type = '[provider] update Status'; + constructor(public payload: WorkshopStatus, public providerId: string) {} +} + +export class OnUpdateWorkshopStatusSuccess { + static readonly type = '[provider] update Status success'; + constructor(public payload: string) {} +} + +export class OnUpdateWorkshopStatusFail { + static readonly type = '[provider] update Status fail'; + constructor(public payload: HttpErrorResponse) {} +} + +export class BlockParent { + static readonly type = '[provider] block parent'; + constructor(public payload: BlockedParent) { } +} + +export class BlockParentFail { + static readonly type = '[provider] block parent fail'; + constructor(public payload: Error) { } +} +export class BlockParentSuccess { + static readonly type = '[provider] block parent success'; + constructor(public payload: BlockedParent) { } +} + +export class UnBlockParent { + static readonly type = '[provider] unblock parent'; + constructor(public payload: BlockedParent) { } +} + +export class UnBlockParentFail { + static readonly type = '[provider] unblock parent fail'; + constructor(public payload: Error) { } +} + +export class UnBlockParentSuccess { + static readonly type = '[provider] unblock parent success'; + constructor(public payload: BlockedParent) { } +} + +export class GetBlockedParents { + static readonly type = '[provider] get block parent'; + constructor(public providerId: string, public parentId: string) { } +} + +export class OnClearBlockedParents { + static readonly type = '[provider] clear blockedParents state'; + constructor( ) { } +} + +export class ResetAchievements { + static readonly type = '[provider] reset achievements'; + constructor() {} +} \ No newline at end of file diff --git a/src/app/shared/store/provider.state.ts b/src/app/shared/store/provider.state.ts index 3fd2b00d96..478bc182f7 100644 --- a/src/app/shared/store/provider.state.ts +++ b/src/app/shared/store/provider.state.ts @@ -1,33 +1,88 @@ +import { Workshop, WorkshopStatus } from 'src/app/shared/models/workshop.model'; import { HttpErrorResponse } from '@angular/common/http'; 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 { Constants } from '../constants/constants'; import { Achievement } from '../models/achievement.model'; import { ChildCards } from '../models/child.model'; +import { Provider } from '../models/provider.model'; +import { ProviderAdmin } from '../models/providerAdmin.model'; +import { ProviderWorkshopCard } from '../models/workshop.model'; import { AchievementsService } from '../services/achievements/achievements.service'; +import { ProviderAdminService } from '../services/provider-admins/provider-admin.service'; +import { ProviderService } from '../services/provider/provider.service'; +import { UserWorkshopService } from '../services/workshops/user-workshop/user-workshop.service'; +import { Util } from '../utils/utils'; import { MarkFormDirty, ShowMessageBar } from './app.actions'; import { + BlockParent, + BlockParentFail, + BlockParentSuccess, + BlockProviderAdminById, CreateAchievement, + CreateProvider, + CreateProviderAdmin, + CreateWorkshop, DeleteAchievementById, + DeleteProviderAdminById, + DeleteWorkshopById, GetAchievementById, GetAchievementsByWorkshopId, + GetAllProviderAdmins, + GetBlockedParents, GetChildrenByWorkshopId, + GetProviderAdminWorkshops, + GetProviderWorkshops, + OnBlockProviderAdminFail, + OnBlockProviderAdminSuccess, + OnClearBlockedParents, OnCreateAchievementFail, OnCreateAchievementSuccess, + OnCreateProviderAdminFail, + OnCreateProviderAdminSuccess, + OnCreateProviderFail, + OnCreateProviderSuccess, + OnCreateWorkshopFail, + OnCreateWorkshopSuccess, OnDeleteAchievementFail, OnDeleteAchievementSuccess, + OnDeleteProviderAdminFail, + OnDeleteProviderAdminSuccess, + OnDeleteWorkshopFail, + OnDeleteWorkshopSuccess, OnUpdateAchievementFail, OnUpdateAchievementSuccess, + OnUpdateProviderFail, + OnUpdateProviderSuccess, + OnUpdateWorkshopFail, + OnUpdateWorkshopStatusFail, + OnUpdateWorkshopStatusSuccess, + OnUpdateWorkshopSuccess, + ResetAchievements, + UnBlockParent, + UnBlockParentFail, + UnBlockParentSuccess, UpdateAchievement, + UpdateProvider, + UpdateWorkshop, + UpdateWorkshopStatus, } from './provider.actions'; +import { GetProfile } from './registration.actions'; +import { BlockedParent } from '../models/block.model'; +import { BlockService } from '../services/block/block.service'; +import { GetApplicationsByProviderId } from './user.actions'; export interface ProviderStateModel { isLoading: boolean; achievements: Achievement[]; selectedAchievement: Achievement; approvedChildren: ChildCards; + providerWorkshops: ProviderWorkshopCard[]; + providerAdmins: ProviderAdmin[]; + blockedParent: BlockedParent; } @State({ @@ -37,6 +92,9 @@ export interface ProviderStateModel { approvedChildren: null, achievements: null, selectedAchievement: null, + providerWorkshops: null, + providerAdmins: null, + blockedParent: null, }, }) @Injectable() @@ -61,7 +119,29 @@ export class ProviderState { return state.selectedAchievement; } - constructor(private achievementsService: AchievementsService, private router: Router) {} + @Selector() + static providerWorkshops(state: ProviderStateModel): ProviderWorkshopCard[] { + return state.providerWorkshops; + } + + @Selector() + static providerAdmins(state: ProviderStateModel): ProviderAdmin[] { + return state.providerAdmins; + } + + @Selector() + static blockedParent(state: ProviderStateModel): BlockedParent { + return state.blockedParent; + } + + constructor( + private achievementsService: AchievementsService, + private router: Router, + private userWorkshopService: UserWorkshopService, + private providerAdminService: ProviderAdminService, + private providerService: ProviderService, + private blockService: BlockService + ) {} @Action(GetAchievementById) getAchievementById( @@ -176,4 +256,395 @@ export class ProviderState { dispatch([new ShowMessageBar({ message: 'Досягнення видалено!', type: 'success' })]); this.router.navigate(['/details/workshop', payload.workshopId]); } + + @Action(GetProviderAdminWorkshops) + getProviderAdminWorkshops( + { patchState }: StateContext, + {}: GetProviderAdminWorkshops + ): Observable { + patchState({ isLoading: true }); + return this.userWorkshopService.getProviderAdminsWorkshops().pipe( + tap((providerWorkshops: ProviderWorkshopCard[]) => { + return patchState({ providerWorkshops, isLoading: false }); + }) + ); + } + + @Action(GetProviderWorkshops) + getProviderWorkshops( + { patchState }: StateContext, + { payload }: GetProviderWorkshops + ): Observable { + patchState({ isLoading: true }); + return this.userWorkshopService.getProviderWorkshops(payload).pipe( + tap((providerWorkshops: ProviderWorkshopCard[]) => { + return patchState({ providerWorkshops, isLoading: false }); + }) + ); + } + + @Action(GetAllProviderAdmins) + getAllProviderAdmins( + { patchState }: StateContext, + {}: GetAllProviderAdmins + ): Observable { + patchState({ isLoading: true }); + return this.providerAdminService + .getAllProviderAdmins() + .pipe(tap((providerAdmins: ProviderAdmin[]) => patchState({ providerAdmins, isLoading: false }))); + } + + @Action(CreateWorkshop) + createWorkshop( + { patchState, dispatch }: StateContext, + { payload }: CreateWorkshop + ): Observable { + patchState({ isLoading: true }); + return this.userWorkshopService.createWorkshop(payload).pipe( + tap(res => dispatch(new OnCreateWorkshopSuccess(res))), + catchError((error: HttpErrorResponse) => of(dispatch(new OnCreateWorkshopFail(error)))) + ); + } + + @Action(OnCreateWorkshopFail) + onCreateWorkshopFail( + { dispatch, patchState }: StateContext, + { payload }: OnCreateWorkshopFail + ): void { + throwError(payload); + patchState({ isLoading: false }); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnCreateWorkshopSuccess) + onCreateWorkshopSuccess( + { patchState, dispatch }: StateContext, + { payload }: OnCreateWorkshopSuccess + ): void { + const message = Util.getWorkshopMessage(payload); + patchState({ isLoading: false }); + dispatch([new MarkFormDirty(false), new ShowMessageBar({ message: message.text, type: message.type })]); + this.router.navigate(['./personal-cabinet/provider/workshops']); + } + + @Action(UpdateWorkshop) + updateWorkshop({ dispatch }: StateContext, { payload }: UpdateWorkshop): Observable { + return this.userWorkshopService.updateWorkshop(payload).pipe( + tap((res: Workshop) => dispatch(new OnUpdateWorkshopSuccess(res))), + catchError((error: HttpErrorResponse) => of(dispatch(new OnUpdateWorkshopFail(error)))) + ); + } + + @Action(OnUpdateWorkshopSuccess) + onUpdateWorkshopSuccess({ dispatch }: StateContext, { payload }: OnUpdateWorkshopSuccess): void { + const message = Util.getWorkshopMessage(payload); + dispatch([new MarkFormDirty(false), new ShowMessageBar({ message: message.text, type: message.type })]); + this.router.navigate(['/personal-cabinet/provider/workshops']); + } + + @Action(OnUpdateWorkshopFail) + onUpdateWorkshopFail({ dispatch }: StateContext, { payload }: OnUpdateWorkshopFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(DeleteWorkshopById) + deleteWorkshop({ dispatch }: StateContext, { payload }: DeleteWorkshopById): Observable { + return this.userWorkshopService.deleteWorkshop(payload.workshopId).pipe( + tap(res => dispatch(new OnDeleteWorkshopSuccess(payload))), + catchError((error: HttpErrorResponse) => of(dispatch(new OnDeleteWorkshopFail(error)))) + ); + } + + @Action(OnDeleteWorkshopFail) + onDeleteWorkshopFail({ dispatch }: StateContext, { payload }: OnDeleteWorkshopFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnDeleteWorkshopSuccess) + onDeleteWorkshopSuccess({ dispatch }: StateContext, { payload }: OnDeleteWorkshopSuccess): void { + dispatch([ + new ShowMessageBar({ + message: `Дякуємо! Гурток "${payload.title}" видалено!`, + type: 'success', + }), + new GetProviderWorkshops(payload.providerId), + ]); + } + + @Action(CreateProvider) + createProvider( + { dispatch }: StateContext, + { payload, isRelease3 }: CreateProvider + ): Observable { + return this.providerService.createProvider(payload, isRelease3).pipe( + tap((res: Provider) => dispatch(new OnCreateProviderSuccess(res))), + catchError(error => of(dispatch(new OnCreateProviderFail(error)))) + ); + } + + @Action(OnCreateProviderFail) + onCreateProviderFail({ dispatch }: StateContext, { payload }: OnCreateProviderFail): void { + throwError(payload); + const message = + payload.error === Constants.UNABLE_CREATE_PROVIDER || + Constants.UNABLE_CREATE_PROVIDER + Constants.THERE_IS_SUCH_DATA + ? 'Перевірте введені дані. Електрона пошта, номер телефону та ІПН/ЄДПРО мають бути унікальними' + : 'На жаль виникла помилка'; + dispatch(new ShowMessageBar({ message, type: 'error' })); + } + + @Action(OnCreateProviderSuccess) + onCreateProviderSuccess({ dispatch }: StateContext, { payload }: OnCreateProviderSuccess): void { + dispatch(new GetProfile()).subscribe(() => this.router.navigate([''])); + dispatch([ + new ShowMessageBar({ + message: 'Організацію успішно створено', + type: 'success', + }), + new MarkFormDirty(false), + ]); + } + + @Action(UpdateProvider) + updateProvider( + { dispatch }: StateContext, + { payload, isRelease3 }: UpdateProvider + ): Observable { + return this.providerService.updateProvider(payload, isRelease3).pipe( + tap(res => dispatch(new OnUpdateProviderSuccess(res))), + catchError((error: HttpErrorResponse) => of(dispatch(new OnUpdateProviderFail(error)))) + ); + } + + @Action(OnUpdateProviderFail) + onUpdateProviderfail({ dispatch }: StateContext, { payload }: OnUpdateProviderFail): void { + throwError(payload); + + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnUpdateProviderSuccess) + onUpdateProviderSuccess({ dispatch }: StateContext, { payload }: OnUpdateProviderSuccess): void { + dispatch(new MarkFormDirty(false)); + dispatch([ + new ShowMessageBar({ + message: 'Організація успішно відредагована', + type: 'success', + }), + ]); + dispatch(new GetProfile()).subscribe(() => this.router.navigate(['/personal-cabinet/provider/info'])); + } + + @Action(CreateProviderAdmin) + createProviderAdmin( + { dispatch }: StateContext, + { payload }: CreateProviderAdmin + ): Observable { + return this.providerAdminService.createProviderAdmin(payload).pipe( + tap((res: ProviderAdmin) => dispatch(new OnCreateProviderAdminSuccess(res))), + catchError((error: HttpErrorResponse) => of(dispatch(new OnCreateProviderAdminFail(error)))) + ); + } + + @Action(OnCreateProviderAdminFail) + onCreateProviderAdminFail( + { dispatch }: StateContext, + { payload }: OnCreateProviderAdminFail + ): void { + throwError(payload); + dispatch( + new ShowMessageBar({ + message: 'На жаль виникла помилка при створенні користувача', + type: 'error', + }) + ); + } + + @Action(OnCreateProviderAdminSuccess) + onCreateProviderAdminSuccess( + { dispatch }: StateContext, + { payload }: OnCreateProviderAdminSuccess + ): void { + dispatch([ + new ShowMessageBar({ + message: 'Користувача успішно створено', + type: 'success', + }), + new MarkFormDirty(false), + ]); + this.router.navigate(['/personal-cabinet/provider/administration']); + } + + @Action(BlockProviderAdminById) + blockProviderAdmin( + { dispatch }: StateContext, + { payload }: BlockProviderAdminById + ): Observable { + return this.providerAdminService.blockProviderAdmin(payload.userId, payload.providerId).pipe( + tap(res => dispatch(new OnBlockProviderAdminSuccess(payload))), + catchError((error: HttpErrorResponse) => of(dispatch(new OnBlockProviderAdminFail(error)))) + ); + } + + @Action(OnBlockProviderAdminFail) + onBlockProviderAdminFail( + { dispatch }: StateContext, + { payload }: OnBlockProviderAdminFail + ): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnBlockProviderAdminSuccess) + onBlockProviderAdminSuccess( + { dispatch }: StateContext, + { payload }: OnBlockProviderAdminSuccess + ): void { + dispatch([ + new GetAllProviderAdmins(), + new ShowMessageBar({ + message: `Дякуємо! користувача заблоковано!`, + type: 'success', + }), + ]); + } + + @Action(DeleteProviderAdminById) + deleteProviderAdmin( + { dispatch }: StateContext, + { payload }: DeleteProviderAdminById + ): Observable { + return this.providerAdminService.deleteProviderAdmin(payload.userId, payload.providerId).pipe( + tap(res => dispatch(new OnDeleteProviderAdminSuccess(payload))), + catchError((error: HttpErrorResponse) => of(dispatch(new OnDeleteProviderAdminFail(error)))) + ); + } + + @Action(OnDeleteProviderAdminFail) + onDeleteProviderAdminFail( + { dispatch }: StateContext, + { payload }: OnDeleteProviderAdminFail + ): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnDeleteProviderAdminSuccess) + onDeleteProviderAdminSuccess( + { dispatch }: StateContext, + { payload }: OnDeleteProviderAdminSuccess + ): void { + dispatch([ + new GetAllProviderAdmins(), + new ShowMessageBar({ + message: `Дякуємо! користувача видалено!`, + type: 'success', + }), + ]); + } + + @Action(UpdateWorkshopStatus) + updateStatus( + { dispatch }: StateContext, + { payload, providerId }: UpdateWorkshopStatus + ): Observable { + return this.userWorkshopService.updateWorkshopStatus(payload).pipe( + tap((res: WorkshopStatus) => dispatch(new OnUpdateWorkshopStatusSuccess(providerId))), + catchError((error: HttpErrorResponse) => of(dispatch(new OnUpdateWorkshopStatusFail(error)))) + ); + } + + @Action(OnUpdateWorkshopStatusFail) + onUpdateStatusFail({ dispatch }: StateContext, { payload }: OnUpdateWorkshopStatusFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnUpdateWorkshopStatusSuccess) + onUpdateStatusSuccess( + { dispatch }: StateContext, + { payload }: OnUpdateWorkshopStatusSuccess + ): void {} + + @Action(BlockParent) + blockParent( + { dispatch }: StateContext, + { payload }: BlockParent + ): Observable> { + return this.blockService.blockParent(payload).pipe( + tap(res => dispatch(new BlockParentSuccess(res))), + catchError((error: Error) => of(dispatch(new BlockParentFail(error)))) + ); + } + + @Action(BlockParentFail) + blockParentFail({ dispatch }: StateContext, { payload }: BlockParentFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(BlockParentSuccess) + blockParentFailSuccess({ dispatch }: StateContext, { payload }: BlockParentSuccess): void { + dispatch([ + new GetApplicationsByProviderId(payload.providerId, { + statuses: [], + showBlocked: false, + workshops: [], + }), + new MarkFormDirty(false), + new ShowMessageBar({ message: 'Користувач успішно заблокований', type: 'success' }), + ]); + } + + @Action(UnBlockParent) + unBlockParent( + { dispatch }: StateContext, + { payload }: UnBlockParent + ): Observable> { + return this.blockService.unBlockParent(payload).pipe( + tap(res => dispatch(new UnBlockParentSuccess(res))), + catchError((error: Error) => of(dispatch(new UnBlockParentFail(error)))) + ); + } + + @Action(UnBlockParentFail) + unBlockParentFail({ dispatch }: StateContext, { payload }: UnBlockParentFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(UnBlockParentSuccess) + unBlockParentFailSuccess({ dispatch }: StateContext, { payload }: UnBlockParentSuccess): void { + dispatch([ + new GetApplicationsByProviderId(payload.providerId, { + statuses: [], + showBlocked: true, + workshops: [], + }), + new MarkFormDirty(false), + new ShowMessageBar({ message: 'Користувач успішно розблокований', type: 'success' }), + ]); + } + + @Action(GetBlockedParents) + getBlockedParents( + { patchState }: StateContext, + { providerId, parentId }: GetBlockedParents + ): Observable { + return this.blockService + .getBlockedParents(providerId, parentId) + .pipe(tap((blockedParent: BlockedParent) => patchState({ blockedParent: blockedParent }))); + } + + @Action(OnClearBlockedParents) + onClearBlockedParents({ patchState }: StateContext, {}: OnClearBlockedParents): void { + patchState({ blockedParent: null }); + } + + @Action(ResetAchievements) + resetAchievement({ patchState }: StateContext, {}: ResetAchievements): void { + patchState({ selectedAchievement: null, achievements: null }); + } } diff --git a/src/app/shared/store/user.actions.ts b/src/app/shared/store/user.actions.ts index feefa1111f..b5698be55c 100644 --- a/src/app/shared/store/user.actions.ts +++ b/src/app/shared/store/user.actions.ts @@ -13,10 +13,6 @@ export class GetWorkshopsByProviderId { static readonly type = '[user] get Workshops By Provider Id'; constructor(public payload: string, public excludedWorkshopId?: string) { } } -export class GetProviderAdminWorkshops { - static readonly type = '[user] get Workshops for provider admin'; - constructor() { } -} export class GetWorkshopById { static readonly type = '[user] get Workshop By Wokrshop Id'; @@ -70,30 +66,7 @@ export class GetAllUsersChildren { static readonly type = '[user] get all users Children'; constructor() { } } -export class CreateWorkshop { - static readonly type = '[user] create Workshop'; - constructor(public payload: Workshop) { } -} -export class OnCreateWorkshopFail { - static readonly type = '[user] create Workshop fail'; - constructor(public payload: HttpErrorResponse) { } -} -export class OnCreateWorkshopSuccess { - static readonly type = '[user] create Workshop success'; - constructor(public payload) { } -} -export class DeleteWorkshopById { - static readonly type = '[user] delete Workshop'; - constructor(public payload: WorkshopCard) { } -} -export class OnDeleteWorkshopSuccess { - static readonly type = '[user] delete Workshop success'; - constructor(public payload: WorkshopCard) { } -} -export class OnDeleteWorkshopFail { - static readonly type = '[user] delete Workshop fail'; - constructor(public payload) { } -} + export class CreateChildren { static readonly type = '[parent] create Children'; constructor(public payload: Child) { } @@ -118,55 +91,6 @@ export class OnDeleteChildFail { static readonly type = '[user] delete Children fail'; constructor(public payload: HttpErrorResponse) { } } -export class CreateProvider { - static readonly type = '[parent] create Provider'; - constructor(public payload: Provider, public isRelease3: boolean) { } -} -export class OnCreateProviderFail { - static readonly type = '[user] create Provider fail'; - constructor(public payload: HttpErrorResponse) { } -} -export class OnCreateProviderSuccess { - static readonly type = '[user] create Provider success'; - constructor(public payload) { } -} -export class CreateProviderAdmin { - static readonly type = '[user] create Provider Admin'; - constructor(public payload: ProviderAdmin) { } -} -export class OnCreateProviderAdminFail { - static readonly type = '[user] create Provider Admin fail'; - constructor(public payload: HttpErrorResponse) { } -} -export class OnCreateProviderAdminSuccess { - static readonly type = '[user] create Provider Admin success'; - constructor(public payload) { } -} -export class BlockProviderAdminById { - static readonly type = '[user] block Provider Admin'; - constructor(public payload) { } -} -export class OnBlockProviderAdminSuccess { - static readonly type = '[user] block Provider Admin success'; - constructor(public payload) { } -} -export class OnBlockProviderAdminFail { - static readonly type = '[user] block Provider Admin fail'; - constructor(public payload) { } -} -export class DeleteProviderAdminById { - static readonly type = '[user] delete Provider Admin'; - constructor(public payload) { } -} -export class OnDeleteProviderAdminSuccess { - static readonly type = '[user] delete Provider Admin success'; - constructor(public payload) { } -} -export class OnDeleteProviderAdminFail { - static readonly type = '[user] delete Provider Admin fail'; - constructor(public payload) { } -} - export class CreateApplication { static readonly type = '[user] create Application'; constructor(public payload: Application) { } @@ -179,30 +103,6 @@ export class OnCreateApplicationSuccess { static readonly type = '[user] create Application success'; constructor(public payload) { } } -export class UpdateWorkshop { - static readonly type = '[user] update Workshop'; - constructor(public payload: Workshop) { } -} -export class OnUpdateWorkshopFail { - static readonly type = '[user] update Workshop fail'; - constructor(public payload: HttpErrorResponse) { } -} -export class OnUpdateWorkshopSuccess { - static readonly type = '[user] update Workshop success'; - constructor(public payload) { } -} -export class UpdateStatus { - static readonly type = '[user] update Status'; - constructor(public payload: WorkshopStatus, public providerId: string) { } -} -export class OnUpdateStatusSuccess { - static readonly type = '[user] update Status success'; - constructor(public payload: string) { } -} -export class OnUpdateStatusFail { - static readonly type = '[user] update Status fail'; - constructor(public payload: HttpErrorResponse) { } -} export class UpdateChild { static readonly type = '[user] update Child'; constructor(public payload: Child) { } @@ -215,18 +115,6 @@ export class OnUpdateChildSuccess { static readonly type = '[user] update Child success'; constructor(public payload) { } } -export class UpdateProvider { - static readonly type = '[user] update Provider'; - constructor(public payload: Provider, public isRelease3: boolean) { } -} -export class OnUpdateProviderFail { - static readonly type = '[user] update Provider fail'; - constructor(public payload: HttpErrorResponse) { } -} -export class OnUpdateProviderSuccess { - static readonly type = '[user] update Provider success'; - constructor(public payload) { } -} export class UpdateApplication { static readonly type = '[user] update Application'; constructor(public payload: ApplicationUpdate) { } @@ -267,10 +155,7 @@ export class DeleteFavoriteWorkshop { static readonly type = '[favorite] delete favorite workshop'; constructor(public payload: string) { } } -export class GetAllProviderAdmins { - static readonly type = '[user] get all users ProviderAdmins'; - constructor() { } -} + export class GetFilteredChildrens { static readonly type = '[user] Get Filtered Childrens'; constructor() { } @@ -283,38 +168,3 @@ export class ResetSelectedChild { static readonly type = '[user] reset selected child'; constructor() { } } -export class BlockParent { - static readonly type = '[user] block parent'; - constructor(public payload: BlockedParent) { } -} - -export class BlockParentFail { - static readonly type = '[user] block parent fail'; - constructor(public payload: Error) { } -} -export class BlockParentSuccess { - static readonly type = '[user] block parent success'; - constructor(public payload: BlockedParent) { } -} - -export class UnBlockParent { - static readonly type = '[user] unblock parent'; - constructor(public payload: BlockedParent) { } -} - -export class UnBlockParentFail { - static readonly type = '[user] unblock parent fail'; - constructor(public payload: Error) { } -} -export class UnBlockParentSuccess { - static readonly type = '[user] unblock parent success'; - constructor(public payload: BlockedParent) { } -} -export class GetBlockedParents { - static readonly type = '[user] get block parent'; - constructor(public providerId: string, public parentId: string) { } -} -export class OnClearBlockedParents { - static readonly type = '[user] clear blockedParents state'; - constructor( ) { } -} diff --git a/src/app/shared/store/user.state.ts b/src/app/shared/store/user.state.ts index cae28d813e..720ce05516 100644 --- a/src/app/shared/store/user.state.ts +++ b/src/app/shared/store/user.state.ts @@ -1,5 +1,5 @@ import { Child } from 'src/app/shared/models/child.model'; -import { Constants, PaginationConstants } from 'src/app/shared/constants/constants'; +import { PaginationConstants } from 'src/app/shared/constants/constants'; import { Favorite, WorkshopFavoriteCard } from './../models/favorite.model'; import { FavoriteWorkshopsService } from './../services/workshops/favorite-workshops/favorite-workshops.service'; import { Injectable } from '@angular/core'; @@ -10,45 +10,28 @@ import { catchError, tap } from 'rxjs/operators'; import { ApplicationCards } from '../models/application.model'; import { ChildCards } from '../models/child.model'; import { Provider } from '../models/provider.model'; -import { Workshop, WorkshopCard, WorkshopStatus } from '../models/workshop.model'; +import { Workshop, WorkshopCard } from '../models/workshop.model'; import { ApplicationService } from '../services/applications/application.service'; import { ChildrenService } from '../services/children/children.service'; import { ProviderService } from '../services/provider/provider.service'; -import { ProviderAdminService } from '../services/provider-admins/provider-admin.service'; import { RatingService } from '../services/rating/rating.service'; import { UserWorkshopService } from '../services/workshops/user-workshop/user-workshop.service'; import { MarkFormDirty, ShowMessageBar } from './app.actions'; -import { GetProfile } from './registration.actions'; import { PaginationElement } from '../models/paginationElement.model'; import { CreateApplication, CreateChildren, - CreateProvider, - CreateWorkshop, DeleteChildById, - DeleteWorkshopById, GetWorkshopsByProviderId, OnCreateApplicationFail, OnCreateApplicationSuccess, OnCreateChildrenFail, OnCreateChildrenSuccess, - OnCreateProviderFail, - OnCreateProviderSuccess, - OnCreateWorkshopFail, - OnCreateWorkshopSuccess, OnDeleteChildFail, OnDeleteChildSuccess, - OnDeleteWorkshopFail, - OnDeleteWorkshopSuccess, UpdateChild, OnUpdateChildFail, OnUpdateChildSuccess, - OnUpdateWorkshopSuccess, - UpdateWorkshop, - OnUpdateWorkshopFail, - UpdateProvider, - OnUpdateProviderFail, - OnUpdateProviderSuccess, GetWorkshopById, OnGetWorkshopByIdFail, GetApplicationsByProviderId, @@ -66,48 +49,24 @@ import { GetFavoriteWorkshopsByUserId, GetUsersChildren, GetAllUsersChildren, - GetAllProviderAdmins, - CreateProviderAdmin, - OnCreateProviderAdminFail, - OnCreateProviderAdminSuccess, - DeleteProviderAdminById, - OnDeleteProviderAdminFail, - OnDeleteProviderAdminSuccess, - BlockProviderAdminById, - OnBlockProviderAdminFail, - OnBlockProviderAdminSuccess, OnGetProviderByIdFail, ResetProviderWorkshopDetails, - BlockParent, - BlockParentFail, - BlockParentSuccess, - GetBlockedParents, - UnBlockParent, - UnBlockParentFail, - UnBlockParentSuccess, GetStatusIsAllowToApply, - OnClearBlockedParents, GetUsersChildById, GetStatusAllowedToReview, - GetProviderAdminWorkshops, GetReviewedApplications, ResetSelectedChild, - UpdateStatus, - OnUpdateStatusSuccess, - OnUpdateStatusFail, } from './user.actions'; import { ApplicationStatus } from '../enum/applications'; import { messageStatus } from '../enum/messageBar'; import { Util } from '../utils/utils'; import { ProviderAdmin } from '../models/providerAdmin.model'; import { Location } from '@angular/common'; -import { BlockService } from '../services/block/block.service'; -import { BlockedParent } from '../models/block.model'; import { HttpErrorResponse } from '@angular/common/http'; export interface UserStateModel { isLoading: boolean; - workshops: Workshop[]; + workshops: WorkshopCard[]; selectedWorkshop: Workshop; selectedProvider: Provider; applicationCards: ApplicationCards; @@ -117,7 +76,6 @@ export interface UserStateModel { favoriteWorkshopsCard: WorkshopCard[]; currentPage: PaginationElement; providerAdmins: ProviderAdmin[]; - blockedParent: BlockedParent; isAllowChildToApply: boolean; isAllowedToReview: boolean; isReviewed: boolean; @@ -136,7 +94,6 @@ export interface UserStateModel { favoriteWorkshopsCard: null, currentPage: PaginationConstants.firstPage, providerAdmins: null, - blockedParent: null, isAllowChildToApply: true, isAllowedToReview: false, isReviewed: false, @@ -150,7 +107,7 @@ export class UserState { } @Selector() - static workshops(state: UserStateModel): Workshop[] { + static workshops(state: UserStateModel): WorkshopCard[] { return state.workshops; } @@ -188,11 +145,6 @@ export class UserState { return state.favoriteWorkshopsCard; } - @Selector() - static providerAdmins(state: UserStateModel): ProviderAdmin[] { - return state.providerAdmins; - } - @Selector() static isAllowChildToApply(state: UserStateModel): boolean { return state.isAllowChildToApply; @@ -208,19 +160,15 @@ export class UserState { return state.isReviewed; } - @Selector() - static blockedParent(state: UserStateModel): BlockedParent { return state.blockedParent; } constructor( private userWorkshopService: UserWorkshopService, private applicationService: ApplicationService, private childrenService: ChildrenService, private providerService: ProviderService, - private providerAdminService: ProviderAdminService, private router: Router, private ratingService: RatingService, private favoriteWorkshopsService: FavoriteWorkshopsService, - private blockService: BlockService, private location: Location ) {} @@ -246,8 +194,6 @@ export class UserState { dispatch(new ShowMessageBar({ message: 'Даний гурток видалено', type: 'error' })); } - - @Action(GetProviderById) getProviderById( { patchState, dispatch }: StateContext, @@ -274,23 +220,10 @@ export class UserState { getWorkshopsByProviderId( { patchState }: StateContext, { payload, excludedWorkshopId }: GetWorkshopsByProviderId - ): Observable { + ): Observable { patchState({ isLoading: true }); return this.userWorkshopService.getWorkshopsByProviderId(payload, excludedWorkshopId).pipe( - tap((userWorkshops: Workshop[]) => { - return patchState({ workshops: userWorkshops, isLoading: false }); - }) - ); - } - - @Action(GetProviderAdminWorkshops) - getProviderAdminWorkshops( - { patchState }: StateContext, - {}: GetProviderAdminWorkshops - ): Observable { - patchState({ isLoading: true }); - return this.userWorkshopService.getProviderAdmisnWorkshops().pipe( - tap((userWorkshops: Workshop[]) => { + tap((userWorkshops: WorkshopCard[]) => { return patchState({ workshops: userWorkshops, isLoading: false }); }) ); @@ -335,17 +268,6 @@ export class UserState { ); } - @Action(GetAllProviderAdmins) - getAllProviderAdmins( - { patchState }: StateContext, - {}: GetAllProviderAdmins - ): Observable { - patchState({ isLoading: true }); - return this.providerAdminService - .getAllProviderAdmins() - .pipe(tap((providerAdmins: ProviderAdmin[]) => patchState({ providerAdmins: providerAdmins, isLoading: false }))); - } - @Action(GetUsersChildren) getUsersChildren( { patchState }: StateContext, @@ -384,67 +306,6 @@ export class UserState { .pipe(tap((children: ChildCards) => patchState({ children: children, isLoading: false }))); } - @Action(CreateWorkshop) - createWorkshop( - { patchState, dispatch }: StateContext, - { payload }: CreateWorkshop - ): Observable { - patchState({ isLoading: true }); - return this.userWorkshopService.createWorkshop(payload).pipe( - tap(res => dispatch(new OnCreateWorkshopSuccess(res))), - catchError((error: HttpErrorResponse) => of(dispatch(new OnCreateWorkshopFail(error)))) - ); - } - - @Action(OnCreateWorkshopFail) - onCreateWorkshopFail( - { dispatch, patchState }: StateContext, - { payload }: OnCreateWorkshopFail - ): void { - throwError(payload); - patchState({ isLoading: false }); - dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); - } - - @Action(OnCreateWorkshopSuccess) - onCreateWorkshopSuccess( - { patchState, dispatch }: StateContext, - { payload }: OnCreateWorkshopSuccess - ): void { - const message = Util.getWorkshopMessage(payload); - patchState({ isLoading: false }); - dispatch([ - new MarkFormDirty(false), - new ShowMessageBar({ message: message.text, type: message.type }), - ]); - this.router.navigate(['./personal-cabinet/provider/workshops']); - } - - @Action(DeleteWorkshopById) - deleteWorkshop({ dispatch }: StateContext, { payload }: DeleteWorkshopById): Observable { - return this.userWorkshopService.deleteWorkshop(payload.workshopId).pipe( - tap(res => dispatch(new OnDeleteWorkshopSuccess(payload))), - catchError((error: HttpErrorResponse) => of(dispatch(new OnDeleteWorkshopFail(error)))) - ); - } - - @Action(OnDeleteWorkshopFail) - onDeleteWorkshopFail({ dispatch }: StateContext, { payload }: OnDeleteWorkshopFail): void { - throwError(payload); - dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); - } - - @Action(OnDeleteWorkshopSuccess) - onDeleteWorkshopSuccess({ dispatch }: StateContext, { payload }: OnDeleteWorkshopSuccess): void { - dispatch([ - new ShowMessageBar({ - message: `Дякуємо! Гурток "${payload.title}" видалено!`, - type: 'success', - }), - new GetWorkshopsByProviderId(payload.providerId), - ]); - } - @Action(CreateChildren) createChildren({ dispatch }: StateContext, { payload }: CreateChildren): Observable { return this.childrenService.createChild(payload).pipe( @@ -471,136 +332,6 @@ export class UserState { this.router.navigate(['/personal-cabinet/parent/info']); } - @Action(CreateProvider) - createProvider({ dispatch }: StateContext, { payload, isRelease3 }: CreateProvider): Observable { - return this.providerService.createProvider(payload, isRelease3).pipe( - tap(res => dispatch(new OnCreateProviderSuccess(res))), - catchError(error => of(dispatch(new OnCreateProviderFail(error)))) - ); - } - - @Action(OnCreateProviderFail) - onCreateProviderFail({ dispatch }: StateContext, { payload }: OnCreateProviderFail): void { - throwError(payload); - const message = - payload.error === Constants.UNABLE_CREATE_PROVIDER || - Constants.UNABLE_CREATE_PROVIDER + Constants.THERE_IS_SUCH_DATA - ? 'Перевірте введені дані. Електрона пошта, номер телефону та ІПН/ЄДПРО мають бути унікальними' - : 'На жаль виникла помилка'; - dispatch(new ShowMessageBar({ message, type: 'error' })); - } - - @Action(OnCreateProviderSuccess) - onCreateProviderSuccess({ dispatch }: StateContext, { payload }: OnCreateProviderSuccess): void { - dispatch(new GetProfile()).subscribe(() => this.router.navigate([''])); - dispatch([ - new ShowMessageBar({ - message: 'Організацію успішно створено', - type: 'success', - }), - new MarkFormDirty(false), - ]); - } - - @Action(CreateProviderAdmin) - createProviderAdmin( - { dispatch }: StateContext, - { payload }: CreateProviderAdmin - ): Observable { - return this.providerAdminService.createProviderAdmin(payload).pipe( - tap(res => dispatch(new OnCreateProviderAdminSuccess(res))), - catchError((error: HttpErrorResponse) => of(dispatch(new OnCreateProviderAdminFail(error)))) - ); - } - - @Action(OnCreateProviderAdminFail) - onCreateProviderAdminFail({ dispatch }: StateContext, { payload }: OnCreateProviderAdminFail): void { - throwError(payload); - dispatch( - new ShowMessageBar({ - message: 'На жаль виникла помилка при створенні користувача', - type: 'error', - }) - ); - } - - @Action(OnCreateProviderAdminSuccess) - onCreateProviderAdminSuccess( - { dispatch }: StateContext, - { payload }: OnCreateProviderAdminSuccess - ): void { - dispatch([ - new ShowMessageBar({ - message: 'Користувача успішно створено', - type: 'success', - }), - new MarkFormDirty(false), - ]); - this.router.navigate(['/personal-cabinet/provider/administration']); - } - - @Action(BlockProviderAdminById) - blockProviderAdmin( - { dispatch }: StateContext, - { payload }: BlockProviderAdminById - ): Observable { - return this.providerAdminService.blockProviderAdmin(payload.userId, payload.providerId).pipe( - tap(res => dispatch(new OnBlockProviderAdminSuccess(payload))), - catchError((error: HttpErrorResponse) => of(dispatch(new OnBlockProviderAdminFail(error)))) - ); - } - - @Action(OnBlockProviderAdminFail) - onBlockProviderAdminFail({ dispatch }: StateContext, { payload }: OnBlockProviderAdminFail): void { - throwError(payload); - dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); - } - - @Action(OnBlockProviderAdminSuccess) - onBlockProviderAdminSuccess( - { dispatch }: StateContext, - { payload }: OnBlockProviderAdminSuccess - ): void { - dispatch([ - new GetAllProviderAdmins(), - new ShowMessageBar({ - message: `Дякуємо! користувача заблоковано!`, - type: 'success', - }), - ]); - } - - @Action(DeleteProviderAdminById) - deleteProviderAdmin( - { dispatch }: StateContext, - { payload }: DeleteProviderAdminById - ): Observable { - return this.providerAdminService.deleteProviderAdmin(payload.userId, payload.providerId).pipe( - tap(res => dispatch(new OnDeleteProviderAdminSuccess(payload))), - catchError((error: HttpErrorResponse) => of(dispatch(new OnDeleteProviderAdminFail(error)))) - ); - } - - @Action(OnDeleteProviderAdminFail) - onDeleteProviderAdminFail({ dispatch }: StateContext, { payload }: OnDeleteProviderAdminFail): void { - throwError(payload); - dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); - } - - @Action(OnDeleteProviderAdminSuccess) - onDeleteProviderAdminSuccess( - { dispatch }: StateContext, - { payload }: OnDeleteProviderAdminSuccess - ): void { - dispatch([ - new GetAllProviderAdmins(), - new ShowMessageBar({ - message: `Дякуємо! користувача видалено!`, - type: 'success', - }), - ]); - } - @Action(CreateApplication) createApplication({ dispatch }: StateContext, { payload }: CreateApplication): Observable { return this.applicationService.createApplication(payload).pipe( @@ -652,39 +383,6 @@ export class UserState { dispatch([new ShowMessageBar({ message: 'Дитину видалено!', type: 'success' }), new GetUsersChildren()]); } - @Action(UpdateWorkshop) - updateWorkshop({ dispatch }: StateContext, { payload }: UpdateWorkshop): Observable { - return this.userWorkshopService.updateWorkshop(payload).pipe( - tap((res: UpdateWorkshop) => dispatch(new OnUpdateWorkshopSuccess(res))), - catchError((error: HttpErrorResponse) => of(dispatch(new OnUpdateWorkshopFail(error)))) - ); - } - - @Action(OnUpdateWorkshopFail) - onUpdateWorkshopFail({ dispatch }: StateContext, { payload }: OnUpdateWorkshopFail): void { - throwError(payload); - dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); - } - - @Action(UpdateStatus) - updateStatus({ dispatch }: StateContext, { payload, providerId }: UpdateStatus): Observable { - return this.userWorkshopService.updateWorkshopStatus(payload).pipe( - tap((res: WorkshopStatus) => dispatch(new OnUpdateStatusSuccess(providerId))), - catchError((error: HttpErrorResponse) => of(dispatch(new OnUpdateStatusFail(error)))) - ); - } - - @Action(OnUpdateStatusFail) - onUpdateStatusFail({ dispatch }: StateContext, { payload }: OnUpdateStatusFail): void { - throwError(payload); - dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); - } - - @Action(OnUpdateStatusSuccess) - onUpdateStatusSuccess({ dispatch }: StateContext, { payload }: OnUpdateStatusSuccess): void { - dispatch(new GetWorkshopsByProviderId(payload)); - } - @Action(UpdateChild) updateChild({ dispatch }: StateContext, { payload }: UpdateChild): Observable { return this.childrenService.updateChild(payload).pipe( @@ -699,13 +397,6 @@ export class UserState { dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); } - @Action(OnUpdateWorkshopSuccess) - onUpdateWorkshopSuccess({ dispatch }: StateContext, { payload }: OnUpdateWorkshopSuccess): void { - const message = Util.getWorkshopMessage(payload); - dispatch([new MarkFormDirty(false), new ShowMessageBar({ message: message.text, type: message.type })]); - this.router.navigate(['/personal-cabinet/provider/workshops']); - } - @Action(OnUpdateChildSuccess) onUpdateChildSuccess({ dispatch }: StateContext, { payload }: OnUpdateChildSuccess): void { dispatch([ @@ -718,36 +409,6 @@ export class UserState { this.location.back(); } - @Action(UpdateProvider) - updateProvider( - { dispatch }: StateContext, - { payload, isRelease3 }: UpdateProvider, - ): Observable { - return this.providerService.updateProvider(payload, isRelease3).pipe( - tap(res => dispatch(new OnUpdateProviderSuccess(res))), - catchError((error: HttpErrorResponse) => of(dispatch(new OnUpdateProviderFail(error)))) - ); - } - - @Action(OnUpdateProviderFail) - onUpdateProviderfail({ dispatch }: StateContext, { payload }: OnUpdateProviderFail): void { - throwError(payload); - - dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); - } - - @Action(OnUpdateProviderSuccess) - onUpdateProviderSuccess({ dispatch }: StateContext, { payload }: OnUpdateProviderSuccess): void { - dispatch(new MarkFormDirty(false)); - dispatch([ - new ShowMessageBar({ - message: 'Організація успішно відредагована', - type: 'success', - }), - ]); - dispatch(new GetProfile()).subscribe(() => this.router.navigate(['/personal-cabinet/provider/info'])); - } - @Action(UpdateApplication) updateApplication({ dispatch }: StateContext, { payload }: UpdateApplication): Observable { return this.applicationService.updateApplication(payload).pipe( @@ -894,81 +555,4 @@ export class UserState { resetSelectedChild({ patchState }: StateContext): void { patchState({ selectedChild: null }); } - - @Action(BlockParent) - blockParent( - { dispatch }: StateContext, - { payload }: BlockParent - ): Observable> { - return this.blockService.blockParent(payload).pipe( - tap(res => dispatch(new BlockParentSuccess(res))), - catchError((error: Error) => of(dispatch(new BlockParentFail(error)))) - ); - } - - @Action(BlockParentFail) - blockParentFail({ dispatch }: StateContext, { payload }: BlockParentFail): void { - throwError(payload); - dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); - } - - @Action(BlockParentSuccess) - blockParentFailSuccess( - { dispatch, patchState }: StateContext, - { payload }: BlockParentSuccess - ): void { - dispatch([ - new GetApplicationsByProviderId(payload.providerId, { - statuses: [], - showBlocked: false, - workshops: [], - }), - new MarkFormDirty(false), - new ShowMessageBar({ message: 'Користувач успішно заблокований', type: 'success' }), - ]); - } - - @Action(UnBlockParent) - unBlockParent( - { dispatch }: StateContext, - { payload }: UnBlockParent - ): Observable> { - return this.blockService.unBlockParent(payload).pipe( - tap(res => dispatch(new UnBlockParentSuccess(res))), - catchError((error: Error) => of(dispatch(new UnBlockParentFail(error)))) - ); - } - - @Action(UnBlockParentFail) - unBlockParentFail({ dispatch }: StateContext, { payload }: UnBlockParentFail): void { - throwError(payload); - dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); - } - - @Action(UnBlockParentSuccess) - unBlockParentFailSuccess({ dispatch }: StateContext, { payload }: UnBlockParentSuccess): void { - dispatch([ - new GetApplicationsByProviderId(payload.providerId, { - statuses: [], - showBlocked: true, - workshops: [], - }), - new MarkFormDirty(false), - new ShowMessageBar({ message: 'Користувач успішно розблокований', type: 'success' }), - ]); - } - - @Action(GetBlockedParents) - getBlockedParents({ patchState }: StateContext, { providerId, parentId}: GetBlockedParents): Observable { - return this.blockService - .getBlockedParents(providerId, parentId) - .pipe( - tap((blockedParent: BlockedParent) => patchState({ blockedParent: blockedParent }) - )) - } - - @Action(OnClearBlockedParents) - onClearBlockedParents({ patchState }: StateContext, { }: OnClearBlockedParents): void { - patchState({ blockedParent: null }); - } } diff --git a/src/app/shell/details/details-tabs/achievements/achievements.component.html b/src/app/shell/details/details-tabs/achievements/achievements.component.html index e7469cb18d..eef82eecef 100644 --- a/src/app/shell/details/details-tabs/achievements/achievements.component.html +++ b/src/app/shell/details/details-tabs/achievements/achievements.component.html @@ -1,22 +1,25 @@ - -
-

Тут ви можете додати досягнення.

- - - -
-
- +

Тут ви можете додати досягнення.

+ + + +
+ +
+ + -
- - - -
+ + + + + + + diff --git a/src/app/shell/details/details-tabs/achievements/achievements.component.ts b/src/app/shell/details/details-tabs/achievements/achievements.component.ts index 72550ffdea..1b486b02c0 100644 --- a/src/app/shell/details/details-tabs/achievements/achievements.component.ts +++ b/src/app/shell/details/details-tabs/achievements/achievements.component.ts @@ -41,6 +41,8 @@ export class AchievementsComponent implements OnInit { ngOnInit(): void { const provider = this.store.selectSnapshot(RegistrationState.provider); + this.isAllowedEdit = this.workshop.providerId === provider?.id; + this.getAchievements(); combineLatest([this.achievements$, this.achievementsTypes$]) .pipe( @@ -50,7 +52,6 @@ export class AchievementsComponent implements OnInit { .subscribe(([achievements, achievementsTypes]: [Achievement[], AchievementType[]]) => { this.achievementsTypes = achievementsTypes; this.achievements = achievements; - this.isAllowedEdit = this.workshop.providerId === provider?.id; }); } diff --git a/src/app/shell/details/details-tabs/all-provider-workshops/all-provider-workshops.component.html b/src/app/shell/details/details-tabs/all-provider-workshops/all-provider-workshops.component.html index 949b40383c..d6642d1c67 100644 --- a/src/app/shell/details/details-tabs/all-provider-workshops/all-provider-workshops.component.html +++ b/src/app/shell/details/details-tabs/all-provider-workshops/all-provider-workshops.component.html @@ -1,6 +1,6 @@
- +
diff --git a/src/app/shell/details/details-tabs/all-provider-workshops/all-provider-workshops.component.spec.ts b/src/app/shell/details/details-tabs/all-provider-workshops/all-provider-workshops.component.spec.ts index d0c9422ee5..94bdc9d61d 100644 --- a/src/app/shell/details/details-tabs/all-provider-workshops/all-provider-workshops.component.spec.ts +++ b/src/app/shell/details/details-tabs/all-provider-workshops/all-provider-workshops.component.spec.ts @@ -40,6 +40,5 @@ describe('AllProviderWorkshopsComponent', () => { }) class MockProviderWorkshopCardComponent { @Input() workshop: Workshop; - @Input() isMainPage: boolean; - @Input() userRoleView: string; + @Input() isCreateFormView: boolean; } diff --git a/src/app/shell/details/workshop-details/workshop-details.component.ts b/src/app/shell/details/workshop-details/workshop-details.component.ts index 3889cbac79..67e4abd6b3 100644 --- a/src/app/shell/details/workshop-details/workshop-details.component.ts +++ b/src/app/shell/details/workshop-details/workshop-details.component.ts @@ -13,9 +13,15 @@ import { Workshop } from 'src/app/shared/models/workshop.model'; import { ImagesService } from 'src/app/shared/services/images/images.service'; import { GetRateByEntityId } from 'src/app/shared/store/meta-data.actions'; import { AddNavPath } from 'src/app/shared/store/navigation.actions'; -import { GetProviderById, GetWorkshopById, GetWorkshopsByProviderId, OnCreateRatingSuccess } from 'src/app/shared/store/user.actions'; +import { + GetProviderById, + GetWorkshopById, + GetWorkshopsByProviderId, + OnCreateRatingSuccess, +} from 'src/app/shared/store/user.actions'; import { RecruitmentStatusUkr } from 'src/app/shared/enum/enumUA/workshop'; import { WorkhopStatus } from 'src/app/shared/enum/workshop'; +import { ResetAchievements } from 'src/app/shared/store/provider.actions'; @Component({ selector: 'app-workshop-details', @@ -51,9 +57,7 @@ export class WorkshopDetailsComponent implements OnInit, OnDestroy { this.workshopStatusOpen = this.workshop.status === this.workhopStatus.Open; - this.route.params - .pipe(takeUntil(this.destroy$)) - .subscribe(() => (this.selectedIndex = 0)); + this.route.params.pipe(takeUntil(this.destroy$)).subscribe(() => (this.selectedIndex = 0)); this.actions$ .pipe(ofActionCompleted(OnCreateRatingSuccess)) .pipe(takeUntil(this.destroy$), distinctUntilChanged()) @@ -83,5 +87,6 @@ export class WorkshopDetailsComponent implements OnInit, OnDestroy { ngOnDestroy(): void { this.destroy$.next(true); this.destroy$.unsubscribe(); + this.store.dispatch(new ResetAchievements()); } } diff --git a/src/app/shell/main/main.component.html b/src/app/shell/main/main.component.html index 80c97a563c..97922ed13a 100644 --- a/src/app/shell/main/main.component.html +++ b/src/app/shell/main/main.component.html @@ -34,9 +34,7 @@

Найпопулярніші гуртки

+ [workshop]="workshop">
diff --git a/src/app/shell/main/main.component.spec.ts b/src/app/shell/main/main.component.spec.ts index 6b12edda80..e390ed76e0 100644 --- a/src/app/shell/main/main.component.spec.ts +++ b/src/app/shell/main/main.component.spec.ts @@ -63,6 +63,5 @@ class MockMainCategoryCardComponent { }) class MockMainWorkshopCardComponent { @Input() workshop: Workshop; - @Input() isMainPage: boolean; - @Input() userRoleView: string; + @Input() isCreateFormView: boolean; } diff --git a/src/app/shell/personal-cabinet/parent/create-application/create-application.component.html b/src/app/shell/personal-cabinet/parent/create-application/create-application.component.html index e33327cab3..3fdad2afda 100644 --- a/src/app/shell/personal-cabinet/parent/create-application/create-application.component.html +++ b/src/app/shell/personal-cabinet/parent/create-application/create-application.component.html @@ -7,7 +7,7 @@

ЗАЯВА НА ГУРТОК

class="application-workshop" [workshop]="workshop" [isHorizontalView]="true" - [isCreateApplicationView]="true"> + [isCreateFormView]="true">

@@ -29,7 +29,9 @@

ЗАЯВА НА ГУРТОК

- Дитина не може бути прийнята в гурток + Дитина не може бути прийнята в гурток diff --git a/src/app/shell/personal-cabinet/parent/create-application/create-application.component.spec.ts b/src/app/shell/personal-cabinet/parent/create-application/create-application.component.spec.ts index f1f17c5c7e..9f7b1d8480 100644 --- a/src/app/shell/personal-cabinet/parent/create-application/create-application.component.spec.ts +++ b/src/app/shell/personal-cabinet/parent/create-application/create-application.component.spec.ts @@ -86,10 +86,6 @@ class MockValidationHintForInputComponent { }) class MockMainWorkshopCardComponent { @Input() workshop: Workshop; - @Input() workshopId: string; - @Input() isMainPage: boolean; - @Input() userRole: string; - @Input() parent: boolean; @Input() isHorizontalView: boolean; - @Input() isCreateApplicationView: boolean; + @Input() isCreateFormView: boolean; } diff --git a/src/app/shell/personal-cabinet/parent/favorite-workshops/favorite-workshops.component.html b/src/app/shell/personal-cabinet/parent/favorite-workshops/favorite-workshops.component.html index fe6a7401bc..577633afb5 100644 --- a/src/app/shell/personal-cabinet/parent/favorite-workshops/favorite-workshops.component.html +++ b/src/app/shell/personal-cabinet/parent/favorite-workshops/favorite-workshops.component.html @@ -1,7 +1,6 @@
- +
{ }) class MockWorkshopCardComponent { @Input() workshop: Workshop; - @Input() isMainPage: boolean; - @Input() userRoleView: string; + @Input() isCreateFormView: boolean; } @Component({ diff --git a/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.html b/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.html index 1ce7f7fba5..e3ddf64731 100644 --- a/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.html +++ b/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.html @@ -7,7 +7,8 @@

ДОДАТИ ДОСЯГНЕННЯ

class="application-workshop" [workshop]="workshop" [isHorizontalView]="true" - [isCreateApplicationView]="true"> + [isCreateFormView]="true"> +
diff --git a/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.spec.ts b/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.spec.ts index 09d1178cb3..2b102f7057 100644 --- a/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.spec.ts +++ b/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.spec.ts @@ -75,7 +75,7 @@ describe('CreateAchievementComponent', () => { class MockMainWorkshopCardComponent { @Input() workshop: Workshop; @Input() workshopId: string; - @Input() isMainPage: boolean; + @Input() isCreateFormView: boolean; @Input() userRole: string; @Input() parent: boolean; @Input() isHorizontalView: boolean; diff --git a/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.ts b/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.ts index d14005bc7a..a5196de70e 100644 --- a/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-achievement/create-achievement.component.ts @@ -27,7 +27,7 @@ import { AddNavPath } from 'src/app/shared/store/navigation.actions'; import { Location } from '@angular/common'; import { NavBarName } from 'src/app/shared/enum/navigation-bar'; import { CreateAchievement, GetChildrenByWorkshopId } from 'src/app/shared/store/provider.actions'; -import { GetAchievementById, UpdateAchievement } from './../../../../shared/store/provider.actions'; +import { GetAchievementById, UpdateAchievement, ResetAchievements } from './../../../../shared/store/provider.actions'; import { Navigation } from 'src/app/shared/models/navigation.model'; @Component({ diff --git a/src/app/shell/personal-cabinet/provider/create-provider-admin/create-provider-admin.component.ts b/src/app/shell/personal-cabinet/provider/create-provider-admin/create-provider-admin.component.ts index 3a7e1cdb81..9a2d7ef752 100644 --- a/src/app/shell/personal-cabinet/provider/create-provider-admin/create-provider-admin.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-provider-admin/create-provider-admin.component.ts @@ -7,7 +7,7 @@ import { ActivatedRoute } from '@angular/router'; import { NavigationBarService } from 'src/app/shared/services/navigation-bar/navigation-bar.service'; import { FormBuilder, FormControl, FormGroup, Validators, ValidatorFn } from '@angular/forms'; import { Constants } from 'src/app/shared/constants/constants'; -import { CreateProviderAdmin, GetWorkshopsByProviderId } from 'src/app/shared/store/user.actions'; +import { GetWorkshopsByProviderId } from 'src/app/shared/store/user.actions'; import { ProviderAdmin } from 'src/app/shared/models/providerAdmin.model'; import { filter, takeUntil } from 'rxjs/operators'; import { Observable } from 'rxjs'; @@ -25,6 +25,7 @@ import { AddNavPath } from 'src/app/shared/store/navigation.actions'; import { NavBarName } from 'src/app/shared/enum/navigation-bar'; import { Util } from 'src/app/shared/utils/utils'; import { Role } from 'src/app/shared/enum/role'; +import { CreateProviderAdmin } from 'src/app/shared/store/provider.actions'; const defaultValidators: ValidatorFn[] = [ Validators.required, diff --git a/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.ts b/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.ts index 6f521655c0..a34afaef7c 100644 --- a/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.ts @@ -1,6 +1,14 @@ import { Logout } from './../../../../shared/store/registration.actions'; import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; -import { AfterViewInit, Component, OnInit, ViewChild, OnDestroy, AfterViewChecked, ChangeDetectorRef } from '@angular/core'; +import { + AfterViewInit, + Component, + OnInit, + ViewChild, + OnDestroy, + AfterViewChecked, + ChangeDetectorRef, +} from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { MatStepper } from '@angular/material/stepper'; import { ActivatedRoute, Params } from '@angular/router'; @@ -15,7 +23,6 @@ import { User } from 'src/app/shared/models/user.model'; import { NavigationBarService } from 'src/app/shared/services/navigation-bar/navigation-bar.service'; import { AddNavPath } from 'src/app/shared/store/navigation.actions'; import { RegistrationState } from 'src/app/shared/store/registration.state'; -import { CreateProvider, UpdateProvider } from 'src/app/shared/store/user.actions'; import { Util } from 'src/app/shared/utils/utils'; import { CreateFormComponent } from '../../shared-cabinet/create-form/create-form.component'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; @@ -24,20 +31,26 @@ import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { MatDialog } from '@angular/material/dialog'; import { FeaturesList } from 'src/app/shared/models/featuresList.model'; import { MetaDataState } from 'src/app/shared/store/meta-data.state'; +import { CreateProvider, UpdateProvider } from 'src/app/shared/store/provider.actions'; @Component({ selector: 'app-create-provider', templateUrl: './create-provider.component.html', styleUrls: ['./create-provider.component.scss'], - providers: [{ - provide: STEPPER_GLOBAL_OPTIONS, - useValue: { displayDefaultIndicatorType: false } - }] + providers: [ + { + provide: STEPPER_GLOBAL_OPTIONS, + useValue: { displayDefaultIndicatorType: false }, + }, + ], }) -export class CreateProviderComponent extends CreateFormComponent implements OnInit, AfterViewInit, OnDestroy, AfterViewChecked { +export class CreateProviderComponent + extends CreateFormComponent + implements OnInit, AfterViewInit, OnDestroy, AfterViewChecked +{ provider: Provider; isAgreed: boolean; - isNotRobot: boolean; + isNotRobot: boolean; InfoFormGroup: FormGroup; ActualAddressFormGroup: FormGroup; @@ -49,21 +62,27 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn AgreementFormControl = new FormControl(false); @ViewChild('stepper') stepper: MatStepper; - - constructor(store: Store, route: ActivatedRoute, navigationBarService: NavigationBarService, private changeDetector : ChangeDetectorRef, private matDialog: MatDialog,) { + + constructor( + store: Store, + route: ActivatedRoute, + navigationBarService: NavigationBarService, + private changeDetector: ChangeDetectorRef, + private matDialog: MatDialog + ) { super(store, route, navigationBarService); } ngOnInit(): void { this.determineEditMode(); - this.RobotFormControl.valueChanges.pipe( - takeUntil(this.destroy$), - ).subscribe((val: boolean) => this.isNotRobot = val); + this.RobotFormControl.valueChanges + .pipe(takeUntil(this.destroy$)) + .subscribe((val: boolean) => (this.isNotRobot = val)); - this.AgreementFormControl.valueChanges.pipe( - takeUntil(this.destroy$), - ).subscribe((val: boolean) => this.isAgreed = val); + this.AgreementFormControl.valueChanges + .pipe(takeUntil(this.destroy$)) + .subscribe((val: boolean) => (this.isAgreed = val)); } ngAfterViewInit(): void { @@ -73,7 +92,7 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn }); } } - ngAfterViewChecked(){ + ngAfterViewChecked() { this.changeDetector.detectChanges(); } @@ -84,13 +103,17 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn addNavPath(): void { const userRole = this.store.selectSnapshot(RegistrationState.role); - const subRole = this.store.selectSnapshot(RegistrationState.subrole); + const subRole = this.store.selectSnapshot(RegistrationState.subrole); const personalCabinetTitle = Util.getPersonalCabinetTitle(userRole, subRole); - - this.store.dispatch(new AddNavPath(this.navigationBarService.createNavPaths( - { name: personalCabinetTitle, path: '/personal-cabinet/provider/info', isActive: false, disable: false }, - { name: NavBarName.EditInstitutions, isActive: false, disable: true } - ))); + + this.store.dispatch( + new AddNavPath( + this.navigationBarService.createNavPaths( + { name: personalCabinetTitle, path: '/personal-cabinet/provider/info', isActive: false, disable: false }, + { name: NavBarName.EditInstitutions, isActive: false, disable: true } + ) + ) + ); } /** @@ -108,8 +131,17 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn if (this.editMode) { legalAddress = new Address(this.LegalAddressFormGroup.value, this.provider.legalAddress); - actulaAdress = this.ActualAddressFormGroup.disabled ? null : new Address(this.ActualAddressFormGroup.value, this.provider.actualAddress); - provider = new Provider(this.InfoFormGroup.value, legalAddress, actulaAdress, this.PhotoFormGroup.value, user, this.provider); + actulaAdress = this.ActualAddressFormGroup.disabled + ? null + : new Address(this.ActualAddressFormGroup.value, this.provider.actualAddress); + provider = new Provider( + this.InfoFormGroup.value, + legalAddress, + actulaAdress, + this.PhotoFormGroup.value, + user, + this.provider + ); this.store.dispatch(new UpdateProvider(provider, isRelease3)); } else { legalAddress = new Address(this.LegalAddressFormGroup.value); @@ -163,7 +195,7 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn form.get(key).markAsTouched(); }); } - + /** * This method marks each control of form in the array of forms in ContactsFormGroup as touched */ @@ -175,23 +207,23 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn }); } - onCancel(){ + onCancel() { const isRegistered = this.store.selectSnapshot(RegistrationState.user).isRegistered; if (!isRegistered) { - const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { - width: Constants.MODAL_SMALL, - data: { - type: ModalConfirmationType.leaveRegistration, - property: '', - }, - }); - - dialogRef.afterClosed().subscribe((result: boolean) => { - if (result) { - this.store.dispatch(new Logout()); - } - }); + const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { + width: Constants.MODAL_SMALL, + data: { + type: ModalConfirmationType.leaveRegistration, + property: '', + }, + }); + + dialogRef.afterClosed().subscribe((result: boolean) => { + if (result) { + this.store.dispatch(new Logout()); + } + }); } } } diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop.component.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop.component.ts index 2dbc4523f4..d28af080e8 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop.component.ts @@ -1,4 +1,4 @@ -import { ResetProviderWorkshopDetails } from './../../../../shared/store/user.actions'; +import { GetWorkshopById, ResetProviderWorkshopDetails } from './../../../../shared/store/user.actions'; import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; import { Component, OnInit, OnDestroy } from '@angular/core'; import { FormArray, FormGroup } from '@angular/forms'; @@ -13,13 +13,12 @@ import { Provider } from 'src/app/shared/models/provider.model'; import { Teacher } from 'src/app/shared/models/teacher.model'; import { Workshop } from 'src/app/shared/models/workshop.model'; import { NavigationBarService } from 'src/app/shared/services/navigation-bar/navigation-bar.service'; -import { UserWorkshopService } from 'src/app/shared/services/workshops/user-workshop/user-workshop.service'; import { AddNavPath } from 'src/app/shared/store/navigation.actions'; import { RegistrationState } from 'src/app/shared/store/registration.state'; -import { CreateWorkshop, GetWorkshopById, UpdateWorkshop } from 'src/app/shared/store/user.actions'; import { UserState } from 'src/app/shared/store/user.state'; import { Util } from 'src/app/shared/utils/utils'; import { CreateFormComponent } from '../../shared-cabinet/create-form/create-form.component'; +import { CreateWorkshop, UpdateWorkshop } from 'src/app/shared/store/provider.actions'; @Component({ selector: 'app-create-workshop', diff --git a/src/app/shell/personal-cabinet/provider/provider-admins/provider-admins.component.ts b/src/app/shell/personal-cabinet/provider/provider-admins/provider-admins.component.ts index bdcaccafb6..aa1a23b377 100644 --- a/src/app/shell/personal-cabinet/provider/provider-admins/provider-admins.component.ts +++ b/src/app/shell/personal-cabinet/provider/provider-admins/provider-admins.component.ts @@ -12,16 +12,12 @@ import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { NoResultsTitle } from 'src/app/shared/enum/no-results'; import { providerAdminRole } from 'src/app/shared/enum/provider-admin'; import { ProviderAdmin, ProviderAdminTable } from 'src/app/shared/models/providerAdmin.model'; -import { - BlockProviderAdminById, - DeleteProviderAdminById, - GetAllProviderAdmins, -} from 'src/app/shared/store/user.actions'; -import { UserState } from 'src/app/shared/store/user.state'; import { Constants } from 'src/app/shared/constants/constants'; import { PushNavPath } from 'src/app/shared/store/navigation.actions'; import { NavBarName } from 'src/app/shared/enum/navigation-bar'; import { ProviderComponent } from '../provider.component'; +import { BlockProviderAdminById, DeleteProviderAdminById, GetAllProviderAdmins } from 'src/app/shared/store/provider.actions'; +import { ProviderState } from './../../../../shared/store/provider.state'; @Component({ selector: 'app-provider-admins', @@ -34,9 +30,9 @@ export class ProviderAdminsComponent extends ProviderComponent implements OnInit readonly noProviderAdmins = NoResultsTitle.noUsers; readonly constants = Constants; - @Select(UserState.isLoading) + @Select(ProviderState.isLoading) isLoadingCabinet$: Observable; - @Select(UserState.providerAdmins) + @Select(ProviderState.providerAdmins) providerAdmins$: Observable; providerAdmins: ProviderAdminTable[] = []; diff --git a/src/app/shell/personal-cabinet/provider/provider-applciations/provider-applciations.component.ts b/src/app/shell/personal-cabinet/provider/provider-applciations/provider-applciations.component.ts index 5d00e06e98..57442467f4 100644 --- a/src/app/shell/personal-cabinet/provider/provider-applciations/provider-applciations.component.ts +++ b/src/app/shell/personal-cabinet/provider/provider-applciations/provider-applciations.component.ts @@ -10,7 +10,6 @@ import { Workshop } from 'src/app/shared/models/workshop.model'; import { Observable } from 'rxjs'; import { GetApplicationsByProviderId, - GetProviderAdminWorkshops, GetWorkshopsByProviderId, UpdateApplication } from 'src/app/shared/store/user.actions'; @@ -20,6 +19,7 @@ import { EntityType, Role } from 'src/app/shared/enum/role'; import { CabinetDataComponent } from '../../shared-cabinet/cabinet-data.component'; import { PushNavPath } from 'src/app/shared/store/navigation.actions'; import { NavBarName } from 'src/app/shared/enum/navigation-bar'; +import { GetProviderAdminWorkshops } from 'src/app/shared/store/provider.actions'; @Component({ selector: 'app-provider-applciations', diff --git a/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.html b/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.html index a1f3bce587..468a796963 100644 --- a/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.html +++ b/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.html @@ -8,8 +8,7 @@ class="card" *ngFor="let workshop of workshops$ | async" [workshop]="workshop" - [isMainPage]="false" - [userRoleView]="Role.provider" + [isCabinetView]="true" (deleteWorkshop)="onDelete($event)">
diff --git a/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.spec.ts b/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.spec.ts index 1b1c5af8be..0450f56754 100644 --- a/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.spec.ts +++ b/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.spec.ts @@ -51,7 +51,5 @@ describe('ProviderAdminWorkshopsComponent', () => { class MockWorkshopCardComponent { @Input() workshop: Workshop; - @Input() isMainPage: boolean; - @Input() userRoleView: string; - @Input() application: Application; + @Input() isCabinetView: boolean; } \ No newline at end of file diff --git a/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.ts b/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.ts index feb61f5162..4cfc97b26e 100644 --- a/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.ts +++ b/src/app/shell/personal-cabinet/provider/provider-workshops/provider-workshops.component.ts @@ -1,10 +1,8 @@ -import { DeleteWorkshopById, GetProviderAdminWorkshops } from 'src/app/shared/store/user.actions'; import { Component, OnInit, OnDestroy } from '@angular/core'; -import { Select, Store } from '@ngxs/store'; +import { Actions, ofAction, Select, Store } from '@ngxs/store'; import { Observable } from 'rxjs'; -import { WorkshopCard } from 'src/app/shared/models/workshop.model'; -import { GetWorkshopsByProviderId } from 'src/app/shared/store/user.actions'; -import { UserState } from 'src/app/shared/store/user.state'; +import { takeUntil } from 'rxjs/operators'; +import { ProviderWorkshopCard } from 'src/app/shared/models/workshop.model'; import { Constants } from 'src/app/shared/constants/constants'; import { MatDialog } from '@angular/material/dialog'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; @@ -12,6 +10,13 @@ import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { Role } from 'src/app/shared/enum/role'; import { NavBarName } from 'src/app/shared/enum/navigation-bar'; import { PushNavPath } from 'src/app/shared/store/navigation.actions'; +import { + DeleteWorkshopById, + GetProviderAdminWorkshops, + GetProviderWorkshops, + OnUpdateWorkshopStatusSuccess, +} from 'src/app/shared/store/provider.actions'; +import { ProviderState } from 'src/app/shared/store/provider.state'; import { ProviderComponent } from '../provider.component'; @Component({ @@ -22,10 +27,10 @@ import { ProviderComponent } from '../provider.component'; export class ProviderWorkshopsComponent extends ProviderComponent implements OnInit, OnDestroy { readonly constants: typeof Constants = Constants; - @Select(UserState.workshops) - workshops$: Observable; + @Select(ProviderState.providerWorkshops) + workshops$: Observable; - constructor(protected store: Store, protected matDialog: MatDialog) { + constructor(protected store: Store, protected matDialog: MatDialog, private actions$: Actions) { super(store, matDialog); } @@ -46,8 +51,16 @@ export class ProviderWorkshopsComponent extends ProviderComponent implements OnI * This method get provider workshop according to the subrole */ initProviderData(): void { + this.getProviderWorkshops(); + this.actions$ + .pipe(ofAction(OnUpdateWorkshopStatusSuccess)) + .pipe(takeUntil(this.destroy$)) + .subscribe(() => this.getProviderWorkshops()); + } + + getProviderWorkshops(): void { if (this.subRole === Role.None) { - this.store.dispatch(new GetWorkshopsByProviderId(this.provider.id)); + this.store.dispatch(new GetProviderWorkshops(this.provider.id)); } else { this.store.dispatch(new GetProviderAdminWorkshops()); } @@ -55,9 +68,9 @@ export class ProviderWorkshopsComponent extends ProviderComponent implements OnI /** * This method delete workshop By Workshop Id - * @param workshop: WorkshopCard + * @param workshop: ProviderWorkshopCard */ - onDelete(workshop: WorkshopCard): void { + onDelete(workshop: ProviderWorkshopCard): void { const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { width: Constants.MODAL_SMALL, data: { diff --git a/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/application-card.component.ts b/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/application-card.component.ts index 2b50ced3f5..8dcc95c8ad 100644 --- a/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/application-card.component.ts +++ b/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/application-card.component.ts @@ -22,10 +22,11 @@ import { Store } from '@ngxs/store'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { ReasonModalWindowComponent } from 'src/app/shell/personal-cabinet/shared-cabinet/applications/reason-modal-window/reason-modal-window.component'; -import { BlockParent, UnBlockParent, UpdateApplication } from 'src/app/shared/store/user.actions'; +import { UpdateApplication } from 'src/app/shared/store/user.actions'; import { Provider } from 'src/app/shared/models/provider.model'; import { RegistrationState } from 'src/app/shared/store/registration.state'; import { BlockedParent } from 'src/app/shared/models/block.model'; +import { BlockParent, UnBlockParent } from 'src/app/shared/store/provider.actions'; @Component({ selector: 'app-application-card', diff --git a/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/info-status/info-status.component.ts b/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/info-status/info-status.component.ts index 22a6b31998..b17ff938b8 100644 --- a/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/info-status/info-status.component.ts +++ b/src/app/shell/personal-cabinet/shared-cabinet/applications/application-card/info-status/info-status.component.ts @@ -1,3 +1,4 @@ +import { ProviderState } from 'src/app/shared/store/provider.state'; import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; @@ -8,21 +9,20 @@ import { Application } from '../../../../../../shared/models/application.model'; import { BlockedParent } from '../../../../../../shared/models/block.model'; import { Provider } from '../../../../../../shared/models/provider.model'; import { RegistrationState } from '../../../../../../shared/store/registration.state'; -import { GetBlockedParents, OnClearBlockedParents } from '../../../../../../shared/store/user.actions'; -import { UserState } from '../../../../../../shared/store/user.state'; +import { GetBlockedParents, OnClearBlockedParents } from 'src/app/shared/store/provider.actions'; @Component({ selector: 'app-info-status', templateUrl: './info-status.component.html', - styleUrls: ['./info-status.component.scss'] + styleUrls: ['./info-status.component.scss'], }) -export class InfoStatusComponent implements OnInit, OnDestroy{ +export class InfoStatusComponent implements OnInit, OnDestroy { readonly applicationTitles = ApplicationTitles; readonly applicationStatusDescription = ApplicationStatusDescription; readonly applicationIcons = ApplicationIcons; readonly applicationStatus = ApplicationStatus; - @Select(UserState.blockedParent) + @Select(ProviderState.blockedParent) blockedParent$: Observable; destroy$: Subject = new Subject(); @@ -30,34 +30,36 @@ export class InfoStatusComponent implements OnInit, OnDestroy{ status: ApplicationStatus; reason: string; - constructor(private store: Store) { } + constructor(private store: Store) {} ngOnInit(): void { - this.status = this.application.isBlocked ? ApplicationStatus.Blocked : ApplicationStatus[this.application.status]; - this.reason = !this.application.isBlocked && this.application.rejectionMessage; + this.status = this.application.isBlocked ? ApplicationStatus.Blocked : ApplicationStatus[this.application.status]; + this.reason = !this.application.isBlocked && this.application.rejectionMessage; } onGetBlockedParent(): void { - if(this.application.isBlocked){ + if (this.application.isBlocked) { const providerId = this.store.selectSnapshot(RegistrationState.provider).id; - this.store.dispatch(new GetBlockedParents(providerId,this.application.parentId)); + this.store.dispatch(new GetBlockedParents(providerId, this.application.parentId)); this.blockedParent$ - .pipe(takeUntil(this.destroy$), - filter((blockedParent:BlockedParent)=>!!blockedParent)) - .subscribe((blockedParent:BlockedParent)=>{ - this.reason = blockedParent.reason; - }); + .pipe( + takeUntil(this.destroy$), + filter((blockedParent: BlockedParent) => !!blockedParent) + ) + .subscribe((blockedParent: BlockedParent) => { + this.reason = blockedParent.reason; + }); } } onMenuClosed(): void { - if(this.application.isBlocked){ - this.store.dispatch(new OnClearBlockedParents()) + if (this.application.isBlocked) { + this.store.dispatch(new OnClearBlockedParents()); } } -ngOnDestroy(): void{ - this.destroy$.next(true); - this.destroy$.unsubscribe(); + ngOnDestroy(): void { + this.destroy$.next(true); + this.destroy$.unsubscribe(); } } diff --git a/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.html b/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.html index 2273fcb8ee..7496e97254 100644 --- a/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.html +++ b/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.html @@ -1,14 +1,17 @@ - +
- +
- +
diff --git a/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.spec.ts b/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.spec.ts index 53732d394f..ec203050f2 100644 --- a/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.spec.ts +++ b/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.spec.ts @@ -60,8 +60,7 @@ class MockOrderingComponent { }) class MockListWorkshopCardComponent { @Input() workshop: Workshop; - @Input() isMainPage: boolean; - @Input() userRoleView: string; + @Input() isCreateFormView: boolean; } @Component({ selector: 'app-paginator', diff --git a/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.html b/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.html index e2b6f47e16..01f1762954 100644 --- a/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.html +++ b/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.html @@ -1,14 +1,17 @@
- +
- - + +
@@ -19,29 +22,47 @@
- -
- +
- {{currentWorkShopIndex+1}} з {{selectedWorkshops.length}} гуртків
+ {{ currentWorkShopIndex + 1 }} з {{ selectedWorkshops.length }} гуртків +
-
- +
diff --git a/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.spec.ts b/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.spec.ts index 852880e82c..6017421b3c 100644 --- a/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.spec.ts +++ b/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.spec.ts @@ -52,8 +52,7 @@ describe('WorkshopMapViewListComponent', () => { }) class MockMapListWorkshopCardComponent { @Input() workshop: Workshop; - @Input() isMainPage: boolean; - @Input() userRoleView: string; + @Input() isCreateFormView: boolean; @Input() isHorizontalView: boolean; } @Component({