Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direction ids property for workshop #1623

Merged
merged 5 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</a>
{{ workshopData.title }}
</mat-card-title>
<ng-container *ngFor="let id of workshopData.directionsId">
<ng-container *ngFor="let id of workshopData.directionIds">
<img class="img" mat-card-image [src]="categoryIcons[id]" />
</ng-container>
</mat-card-header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('WorkshopCardComponent', () => {
description: '',
direction: '',
rating: 1,
directionsId: [],
directionIds: [],
address: {
codeficatorAddressDto: {},
street: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ export class WorkshopCardComponent implements OnInit, OnDestroy {
canChangeWorkshopStatus: boolean;
workshopData: ProviderWorkshopCard | WorkshopCard;

private favoriteWorkshopId: string;

@Input() set workshop(workshop: WorkshopCard) {
this.workshopData = workshop;
this.imagesService.setWorkshopCoverImage(workshop);
}

@Input() isCabinetView: boolean = false;
@Input() isHorizontalView = false;
@Input() isCreateFormView = false;

@Output() deleteWorkshop = new EventEmitter<WorkshopCard>();
@Output() deleteWorkshop = new EventEmitter<WorkshopCard | ProviderWorkshopCard>();

@Select(UserState.favoriteWorkshops)
favoriteWorkshops$: Observable<Favorite[]>;
Expand All @@ -62,6 +59,8 @@ export class WorkshopCardComponent implements OnInit, OnDestroy {
role: Role;
destroy$: Subject<boolean> = new Subject<boolean>();

private favoriteWorkshopId: string;

constructor(private store: Store, private dialog: MatDialog, private imagesService: ImagesService) {}

ngOnInit(): void {
Expand Down
6 changes: 2 additions & 4 deletions src/app/shared/models/workshop.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ export class Workshop {
teachers: Teacher[];
rating?: number;
numberOfRatings?: number;
direction: string;
directions: Direction[];
directionIds: number[];
providerId: string;
providerTitle?: string;
payRate?: string;
Expand Down Expand Up @@ -116,7 +115,7 @@ export class WorkshopSectionItem extends SectionItem {
export interface WorkshopBaseCard {
workshopId: string;
title: string;
directionsId: number[];
directionIds: number[];
coverImageId?: string;
}

Expand Down Expand Up @@ -146,7 +145,6 @@ export interface WorkshopCard extends WorkshopBaseCard {
maxAge: number;
minAge: number;
price: number;
directionsId: number[];
address: Address;
}

Expand Down
15 changes: 7 additions & 8 deletions src/app/shared/services/images/images.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ import { environment } from 'src/environments/environment';
import { Constants } from '../../constants/constants';
import { CategoryIcons } from '../../enum/category-icons';
import { Provider } from '../../models/provider.model';
import { Workshop, WorkshopCard } from '../../models/workshop.model';
import { ProviderWorkshopCard, Workshop, WorkshopCard } from '../../models/workshop.model';
import { imgPath } from 'src/app/shared/models/carousel.model';

@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class ImagesService {
constructor() {}

constructor() { }

setWorkshopCoverImage(workshop: WorkshopCard): WorkshopCard {
workshop['_meta'] = workshop.coverImageId ?
environment.storageUrl + workshop.coverImageId :
CategoryIcons[workshop.directionsId[0]];
setWorkshopCoverImage(workshop: WorkshopCard | ProviderWorkshopCard): WorkshopCard | ProviderWorkshopCard {
workshop['_meta'] = workshop.coverImageId
? environment.storageUrl + workshop.coverImageId
: CategoryIcons[workshop.directionIds[0]];
return workshop;
}

Expand Down