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

Issue#2090-2091 error 404 #2095

Merged
merged 3 commits into from
May 18, 2023
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
1 change: 1 addition & 0 deletions src/app/shared/models/featuresList.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export interface FeaturesList {
release1: boolean;
release2: boolean;
release3: boolean;
images: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@ import { FeaturesList } from '../../../models/featuresList.model';
import { TruncatedItem } from '../../../models/item.model';
import { PaginationElement } from '../../../models/paginationElement.model';
import { SearchResponse } from '../../../models/search.model';
import {
ProviderWorkshopCard, Workshop, WorkshopCard, WorkshopCardParameters, WorkshopStatus
} from '../../../models/workshop.model';
import { ProviderWorkshopCard, Workshop, WorkshopCard, WorkshopCardParameters, WorkshopStatus } from '../../../models/workshop.model';
import { MetaDataState } from '../../../store/meta-data.state';

@Injectable({
providedIn: 'root'
})
export class UserWorkshopService {
isRelease3: boolean;
private isRelease3: boolean;

constructor(private http: HttpClient, private store: Store) {}

/**
* This method get related workshops for provider admins personal cabinet
*/
getProviderAdminsWorkshops(parameters: PaginationParameters): Observable<SearchResponse<ProviderWorkshopCard[]>> {
public getProviderAdminsWorkshops(parameters: PaginationParameters): Observable<SearchResponse<ProviderWorkshopCard[]>> {
let params = new HttpParams().set('From', parameters.from.toString()).set('Size', parameters.size.toString());

return this.http.get<SearchResponse<ProviderWorkshopCard[]>>('/api/v1/ProviderAdmin/ManagedWorkshops', { params });
Expand All @@ -35,7 +33,7 @@ export class UserWorkshopService {
/**
* This method get related workshops for provider personal cabinet
*/
getProviderViewWorkshops(workshopCardParameters: WorkshopCardParameters): Observable<SearchResponse<ProviderWorkshopCard[]>> {
public getProviderViewWorkshops(workshopCardParameters: WorkshopCardParameters): Observable<SearchResponse<ProviderWorkshopCard[]>> {
const params = new HttpParams().set('From', workshopCardParameters.from.toString()).set('Size', workshopCardParameters.size.toString());

return this.http.get<SearchResponse<ProviderWorkshopCard[]>>(
Expand All @@ -49,7 +47,7 @@ export class UserWorkshopService {
/**
* This method get workshops by Provider id for details page
*/
getWorkshopsByProviderId(providerParameters: ProviderParameters): Observable<SearchResponse<WorkshopCard[]>> {
public getWorkshopsByProviderId(providerParameters: ProviderParameters): Observable<SearchResponse<WorkshopCard[]>> {
let params = new HttpParams().set('From', providerParameters.from.toString()).set('Size', providerParameters.size.toString());

if (providerParameters.excludedWorkshopId) {
Expand All @@ -63,32 +61,32 @@ export class UserWorkshopService {
* This method get workshops by Workshop id
* @param id: string
*/
getWorkshopById(id: string): Observable<Workshop> {
public getWorkshopById(id: string): Observable<Workshop> {
return this.http.get<Workshop>(`/api/v1/Workshop/GetById/${id}`);
}

getWorkshopListByProviderId(id: string): Observable<TruncatedItem[]> {
public getWorkshopListByProviderId(id: string): Observable<TruncatedItem[]> {
return this.http.get<TruncatedItem[]>(`/api/v1/Workshop/GetWorkshopListByProviderId/${id}`);
}

getWorkshopListByProviderAdminId(id: string): Observable<TruncatedItem[]> {
public getWorkshopListByProviderAdminId(id: string): Observable<TruncatedItem[]> {
return this.http.get<TruncatedItem[]>(`/api/v1/Workshop/GetWorkshopListByProviderAdminId/${id}`);
}

/**
* This method create workshop
* @param workshop: Workshop
*/
createWorkshop(workshop: Workshop): Observable<Workshop> {
public createWorkshop(workshop: Workshop): Observable<Workshop> {
this.isRelease3 = this.store.selectSnapshot<FeaturesList>(MetaDataState.featuresList).release3;
return this.isRelease3 ? this.createWorkshopV2(workshop) : this.createWorkshopV1(workshop);
}

createWorkshopV1(workshop: Workshop): Observable<Workshop> {
public createWorkshopV1(workshop: Workshop): Observable<Workshop> {
return this.http.post<Workshop>('/api/v1/Workshop/Create', workshop);
}

createWorkshopV2(workshop: Workshop): Observable<Workshop> {
public createWorkshopV2(workshop: Workshop): Observable<Workshop> {
const formData = this.createFormData(workshop);
return this.http.post<Workshop>('/api/v2/Workshop/Create', formData);
}
Expand All @@ -97,16 +95,16 @@ export class UserWorkshopService {
* This method update workshop
* @param workshop: Workshop
*/
updateWorkshop(workshop: Workshop): Observable<Workshop> {
public updateWorkshop(workshop: Workshop): Observable<Workshop> {
this.isRelease3 = this.store.selectSnapshot<FeaturesList>(MetaDataState.featuresList).release2;
return this.isRelease3 ? this.updateWorkshopV2(workshop) : this.updateWorkshopV1(workshop);
}

updateWorkshopV1(workshop: Workshop): Observable<Workshop> {
public updateWorkshopV1(workshop: Workshop): Observable<Workshop> {
return this.http.put<Workshop>('/api/v1/Workshop/Update', workshop);
}

updateWorkshopV2(workshop: Workshop): Observable<Workshop> {
public updateWorkshopV2(workshop: Workshop): Observable<Workshop> {
const formData = this.createFormData(workshop);
return this.http.put<Workshop>('/api/v2/Workshop/Update', formData);
}
Expand All @@ -115,12 +113,12 @@ export class UserWorkshopService {
* This method update workshop status
* @param workshopStatus: WorkshopStatus
*/
updateWorkshopStatus(workshopStatus: WorkshopStatus): Observable<WorkshopStatus> {
public updateWorkshopStatus(workshopStatus: WorkshopStatus): Observable<WorkshopStatus> {
return this.http.put<WorkshopStatus>('/api/v1/Workshop/UpdateStatus', workshopStatus);
}

deleteWorkshop(id: string): Observable<void> {
return this.http.delete<void>(`/api/v2/Workshop/Delete/${id}`);
public deleteWorkshop(id: string): Observable<void> {
return this.http.delete<void>(`/api/v1/Workshop/Delete/${id}`);
}

private createFormData(workshop: Workshop): FormData {
Expand Down
34 changes: 19 additions & 15 deletions src/app/shared/store/meta-data.state.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { EMPTY_RESULT } from './../constants/constants';
import { Injectable } from '@angular/core';
import { Action, Selector, State, StateContext } from '@ngxs/store';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';

import { Injectable } from '@angular/core';
import { Action, Selector, State, StateContext } from '@ngxs/store';

import { Constants, EMPTY_RESULT } from '../constants/constants';
import { AchievementType } from '../models/achievement.model';
import { Direction } from '../models/category.model';
import { Codeficator } from '../models/codeficator.model';
import { FeaturesList } from '../models/featuresList.model';
import { InstituitionHierarchy, Institution, InstitutionFieldDescription } from '../models/institution.model';
import { DataItem } from '../models/item.model';
import { Rate } from '../models/rating';
import { SearchResponse } from '../models/search.model';
import { AchievementsService } from '../services/achievements/achievements.service';
import { ChildrenService } from '../services/children/children.service';
import { CodeficatorService } from '../services/codeficator/codeficator.service';
import { DirectionsService } from '../services/directions/directions.service';
import { FeatureManagementService } from '../services/feature-management/feature-management.service';
import { InstitutionsService } from '../services/institutions/institutions.service';
import { ProviderService } from '../services/provider/provider.service';
import { RatingService } from '../services/rating/rating.service';
import { Constants } from '../constants/constants';
import { InstituitionHierarchy, Institution, InstitutionFieldDescription } from './../models/institution.model';
import { InstitutionsService } from '../services/institutions/institutions.service';
import {
GetSocialGroup,
GetDirections,
GetInstitutionStatuses,
ClearCodeficatorSearch,
ClearRatings,
GetAchievementsType,
Expand All @@ -30,16 +30,17 @@ import {
GetAllInstitutionsHierarchy,
GetCodeficatorById,
GetCodeficatorSearch,
GetDirections,
GetFeaturesList,
GetFieldDescriptionByInstitutionId,
GetInstitutionHierarchyChildrenById,
GetInstitutionHierarchyParentsById,
GetInstitutionStatuses,
GetProviderTypes,
GetRateByEntityId,
ResetInstitutionHierarchy,
GetProviderTypes
GetSocialGroup,
ResetInstitutionHierarchy
} from './meta-data.actions';
import { SearchResponse } from '../models/search.model';
import { DataItem } from '../models/item.model';

export interface MetaDataStateModel {
directions: Direction[];
Expand Down Expand Up @@ -68,7 +69,7 @@ export interface MetaDataStateModel {
achievementsTypes: null,
rating: null,
isLoading: false,
featuresList: { release1: true, release2: true, release3: false },
featuresList: null,
institutions: null,
institutionFieldDesc: null,
instituitionsHierarchyAll: null,
Expand Down Expand Up @@ -299,7 +300,10 @@ export class MetaDataState {
}

@Action(GetCodeficatorSearch)
getCodeficatorSearch({ patchState }: StateContext<MetaDataStateModel>, { name, categories }: GetCodeficatorSearch): Observable<Codeficator[]> {
getCodeficatorSearch(
{ patchState }: StateContext<MetaDataStateModel>,
{ name, categories }: GetCodeficatorSearch
): Observable<Codeficator[]> {
patchState({ isLoading: true });
return this.codeficatorService.searchCodeficator(name, categories).pipe(
tap((codeficatorSearch: Codeficator[]) => {
Expand Down