mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
@@ -20,7 +20,7 @@ import * as fromRouter from '@ngrx/router-store';
|
||||
import { StoreRouterConnectingModule, RouterStateSerializer } from '@ngrx/router-store';
|
||||
import { CustomSerializer } from './core/reducers/router.reducer';
|
||||
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
|
||||
import { CatServiceModule, CatSearchService, CatImageService, CatSearchMockService } from 'projects/cat-service/src/lib';
|
||||
import { CatServiceModule } from 'cat-service';
|
||||
import { ProductCardComponent } from './components/product-card/product-card.component';
|
||||
import { ConfigService } from './core/services/config.service';
|
||||
import { ProductDetailsComponent } from './components/product-details/product-details.component';
|
||||
@@ -68,7 +68,7 @@ export function _basicAuthorizationInterceptorFactory(conf: ConfigService) {
|
||||
{ provide: APP_INITIALIZER, useFactory: _configInitializer, multi: true, deps: [ ConfigService ] },
|
||||
{ provide: RouterStateSerializer, useClass: CustomSerializer },
|
||||
{ provide: HTTP_INTERCEPTORS, useFactory: _basicAuthorizationInterceptorFactory, deps: [ConfigService], multi: true },
|
||||
{ provide: CatSearchService, useClass: CatSearchMockService } // Uncomment if u want to use the CatSearchMockService
|
||||
// { provide: CatSearchService, useClass: CatSearchMockService } // Uncomment if u want to use the CatSearchMockService
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
||||
@@ -4,7 +4,7 @@ import { FeedCard } from './core/models/feed-card.model';
|
||||
import { RecentArticleSearch } from './core/models/recent-article-search.model';
|
||||
import { Product } from './core/models/product.model';
|
||||
import { Filter } from './core/models/filter.model';
|
||||
import { ItemDTO } from 'projects/cat-service/src/lib';
|
||||
import { ItemDTO } from 'cat-service';
|
||||
import { RouterStateUrl } from './core/reducers/router.reducer';
|
||||
import * as fromRouter from '@ngrx/router-store';
|
||||
|
||||
|
||||
@@ -6,10 +6,8 @@ import { Process } from 'src/app/core/models/process.model';
|
||||
import { Product } from 'src/app/core/models/product.model';
|
||||
import { GetProducts } from 'src/app/core/actions/product.actions';
|
||||
import { Router } from '@angular/router';
|
||||
import { ItemDTO } from 'projects/cat-service/src/lib';
|
||||
import { procuctsMock } from 'mocks/products.mock';
|
||||
import { ProductMapping } from '../../core/mappings/product.mapping';
|
||||
import { map, flatMap, combineAll } from 'rxjs/operators';
|
||||
import { map, filter } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-search-results',
|
||||
@@ -51,6 +49,7 @@ export class SearchResultsComponent implements OnInit {
|
||||
|
||||
loadProducts() {
|
||||
this.store.select(state => state.itemsDTO).pipe(
|
||||
filter(f => Array.isArray(f)),
|
||||
map(items => items.map(item => this.productMapping.fromItemDTO(item)))
|
||||
).subscribe(data => this.products = data);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
import { ItemDTO } from 'projects/cat-service/src/lib';
|
||||
import { ItemDTO } from 'cat-service';
|
||||
|
||||
export const GET_PRODUCTS = 'GET_PRODUCTS';
|
||||
export const GET_PRODUCTS_SUCCESS = 'GET_PRODUCTS_SUCCESS';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Product } from '../models/product.model';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { ItemDTO, AvailabilityType } from 'projects/cat-service/src/lib';
|
||||
import { AvailabilityDTO, PriceDTO } from 'cat-service';
|
||||
import { AvailabilityDTO, PriceDTO, ItemDTO, AvailabilityType } from 'cat-service';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
|
||||
@@ -64,7 +63,8 @@ export class ProductMapping {
|
||||
type: itemFormatMap[item.pr.format],
|
||||
typeIcon: item.pr.format,
|
||||
location: '',
|
||||
publicationDate: item.pr.publicationDate
|
||||
publicationDate: item.pr.publicationDate,
|
||||
ean: item.pr.ean
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -18,4 +18,5 @@ export interface Product {
|
||||
recommandation: boolean;
|
||||
err: string;
|
||||
location: string;
|
||||
ean: string;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GET_PRODUCTS, GET_PRODUCTS_SUCCESS, GET_PRODUCTS_FAIL } from '../actions/product.actions';
|
||||
import { ItemDTO } from 'projects/cat-service/src/lib';
|
||||
import { ItemDTO } from 'cat-service';
|
||||
|
||||
export function productReducer(products: ItemDTO[] = [], action: any) {
|
||||
switch (action.type) {
|
||||
|
||||
@@ -67,6 +67,12 @@ export class ProductService {
|
||||
};
|
||||
|
||||
return this.searchService.search(queryToken).pipe(
|
||||
map(response => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
return response;
|
||||
}),
|
||||
map(response => response.result)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user