Skip to content

Commit

Permalink
Merge branch 'develop' into Issue-#1425-Search-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
koliaBp authored Sep 1, 2022
2 parents fb4c7e6 + ada15ee commit b102845
Show file tree
Hide file tree
Showing 38 changed files with 1,006 additions and 818 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<mat-card *ngIf="workshopData">
<ng-container *ngIf="isMainPage || userRoleView !== Role.provider; then UserActions; else ProviderActions">
</ng-container>
<ng-container *ngIf="!isCabinetView; then UserActions; else ProviderActions"> </ng-container>

<div [ngClass]="isHorizontalView ? 'horizontal-card' : 'card'">
<div class="card-img card-img-full" fxLayout="row" fxLayoutAlign="center">
Expand All @@ -10,7 +9,8 @@
[src]="workshopData['_meta']"
alt="{{ workshopData.title }}" />
</div>
<div [ngClass]="isMainPage && isHorizontalView ? 'wrap-for-details wrap-for-details-map' : 'wrap-for-details'">

<div [ngClass]="isHorizontalView ? 'wrap-for-details wrap-for-details-map' : 'wrap-for-details'">
<mat-card-header>
<mat-card-title
[matTooltip]="workshopData.title"
Expand All @@ -19,7 +19,7 @@
[matTooltipPosition]="tooltipPosition"
class="card-title">
<a
*ngIf="userRoleView === Role.provider"
*ngIf="isCabinetView"
matTooltip="Детальніше"
matTooltipPosition="above"
[routerLink]="['/details/workshop', workshopData.workshopId]">
Expand All @@ -33,19 +33,17 @@
</mat-card-header>

<mat-card-content fxLayout="column" fxLayoutAlign="space-between">
<ng-container
*ngIf="isMainPage || userRoleView !== Role.provider; then UserWorkshopView; else ProviderWorkshopView">
</ng-container>
<ng-container *ngIf="isCabinetView; then ProviderWorkshopView; else UserWorkshopView"></ng-container>
</mat-card-content>

<mat-card-footer *ngIf="!isCreateApplicationView" class="card-footer">
<ng-container *ngIf="userRoleView !== Role.provider">
<mat-card-footer *ngIf="!isCreateFormView" class="card-footer">
<ng-container *ngIf="!isCabinetView">
<a class="more-details" [routerLink]="['/details/workshop', workshopData.workshopId]">
<span class="card_link">Детальніше</span>
<mat-icon>arrow_forward</mat-icon>
</a>
</ng-container>
<ng-container *ngIf="userRoleView === Role.provider">
<ng-container *ngIf="isCabinetView">
<a class="more-details" [routerLink]="['/create-achievement', workshopData.workshopId]">
<mat-icon>add</mat-icon>
<span class="card_link">Додати досягнення</span>
Expand Down Expand Up @@ -80,15 +78,15 @@
</ng-template>

<ng-template #UserActions>
<div *ngIf="!isHorizontalView" fxLayout="row" fxLayoutAlign="end start" class="actions">
<div *ngIf="!isHorizontalView && role !== Role.provider" fxLayout="row" fxLayoutAlign="end start" class="actions">
<ng-container *ngIf="isFavorite; then favorite; else notFavorite"></ng-container>
</div>
</ng-template>

<ng-template #favorite>
<div
(click)="role === Role.parent && onDisLike(this.favoriteWorkshopId?.id)"
class="actions_btn action-icon favorite-icon">
class="actions_btn action-icon favorite-icon"
(click)="role === Role.parent && onDisLike(this.favoriteWorkshopId?.id)">
<mat-icon>favorite</mat-icon>
</div>
</ng-template>
Expand Down Expand Up @@ -122,7 +120,7 @@
</div>
<div class="provider-content" fxLayout="row" fxLayoutAlign="space-between center">
<p class="card_text"><i class="fas fa-user-clock card_icon"></i> Очікує підтвердження:</p>
<span class="card_text card_text_blue"> {{ pendingApplicationAmount }}</span>
<span class="card_text card_text_blue"> {{ workshopData.amountOfPendingApplications }}</span>
</div>
</ng-template>

Expand Down Expand Up @@ -164,7 +162,7 @@
<mat-icon class="card_icon">account_balance</mat-icon>
Форма власності: {{ ownershipTypeUkr[workshopData.providerOwnership] }}
</p>
<p class="card_text" [ngClass]="isMainPage && isHorizontalView ? 'hide' : ''">
<p class="card_text" [ngClass]="isHorizontalView ? 'hide' : ''">
<mat-icon class="card_icon">person</mat-icon>
{{ workshopData.minAge }} - {{ workshopData.maxAge }} років
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
60 changes: 28 additions & 32 deletions src/app/shared/components/workshop-card/workshop-card.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -22,17 +20,16 @@ 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',
templateUrl: './workshop-card.component.html',
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;
Expand All @@ -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<WorkshopCard>();
@Output() leaveWorkshop = new EventEmitter<Application>();

@Select(UserState.favoriteWorkshops)
favoriteWorkshops$: Observable<Favorite[]>;
@Select(RegistrationState.role)
role$: Observable<string>;
role: string;
role$: Observable<Role>;
role: Role;
destroy$: Subject<boolean> = new Subject<boolean>();

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 {
Expand Down Expand Up @@ -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);
}
Expand Down
42 changes: 30 additions & 12 deletions src/app/shared/models/workshop.model.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -95,7 +96,7 @@ export class Workshop {
if (about.price) {
this.price = about.price;
}
if(about.availableSeats){
if (about.availableSeats) {
this.availableSeats = about.availableSeats;
}
}
Expand All @@ -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[];
Expand All @@ -140,4 +158,4 @@ export interface WorkshopFilterCard {
export interface WorkshopStatus {
workshopId: string;
status: string;
}
}
20 changes: 10 additions & 10 deletions src/app/shared/services/provider/provider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ export class ProviderService {
* This method create Provider
* @param Provider
*/
createProvider(provider: Provider, isRelease3: boolean): Observable<object> {
createProvider(provider: Provider, isRelease3: boolean): Observable<Provider> {
return isRelease3 ? this.createProviderV2(provider) : this.createProviderV1(provider);
}

createProviderV1(provider: Provider): Observable<object> {
return this.http.post('/api/v1/Provider/Create', provider);
createProviderV1(provider: Provider): Observable<Provider> {
return this.http.post<Provider>('/api/v1/Provider/Create', provider);
}

createProviderV2(provider: Provider): Observable<object> {
createProviderV2(provider: Provider): Observable<Provider> {
const formData = Provider.createFormData(provider);
return this.http.post('/api/v2/Provider/Create', formData);
return this.http.post<Provider>('/api/v2/Provider/Create', formData);
}

/**
Expand All @@ -64,17 +64,17 @@ export class ProviderService {
* This method update Provider
* @param Provider
*/
updateProvider(provider: Provider, isRelease3: boolean): Observable<object> {
updateProvider(provider: Provider, isRelease3: boolean): Observable<Provider> {
return isRelease3 ? this.updateProviderV2(provider) : this.updateProviderV1(provider);
}

updateProviderV1(provider: Provider): Observable<object> {
return this.http.put('/api/v1/Provider/Update', provider);
updateProviderV1(provider: Provider): Observable<Provider> {
return this.http.put<Provider>('/api/v1/Provider/Update', provider);
}

updateProviderV2(provider: Provider): Observable<object> {
updateProviderV2(provider: Provider): Observable<Provider> {
const formData = Provider.createFormData(provider);
return this.http.put('/api/v2/Provider/Update', formData);
return this.http.put<Provider>('/api/v2/Provider/Update', formData);
}

/**
Expand Down
Loading

0 comments on commit b102845

Please sign in to comment.