Fix interiors
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
|||||||
InteriorsFilter,
|
InteriorsFilter,
|
||||||
InteriorType,
|
InteriorType,
|
||||||
} from '../types/interior-types';
|
} from '../types/interior-types';
|
||||||
import { Orientation, ProductGroup } from '../types/product-types';
|
import { Orientation } from '../types/product-types';
|
||||||
import { Maybe } from '../types/types';
|
import { Maybe } from '../types/types';
|
||||||
import { BaseSQLDataSource } from './BaseSQLDataSource';
|
import { BaseSQLDataSource } from './BaseSQLDataSource';
|
||||||
import { ImageServerApi } from './imageserver-api';
|
import { ImageServerApi } from './imageserver-api';
|
||||||
@@ -18,22 +18,18 @@ export class InteriorAPI extends BaseSQLDataSource {
|
|||||||
this.imageServerApi = imageServerApi;
|
this.imageServerApi = imageServerApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
getInteriorType(productGroup: ProductGroup): string {
|
getInteriorType(roomTypePart: string): string {
|
||||||
switch (productGroup) {
|
switch (roomTypePart) {
|
||||||
case ProductGroup.DESIGNER_WALLPAPER:
|
case 'wallpaper':
|
||||||
case ProductGroup.WALLPAPER:
|
|
||||||
case ProductGroup.PHOTO_WALLPAPER:
|
|
||||||
return InteriorType[InteriorType.WALLPAPER];
|
return InteriorType[InteriorType.WALLPAPER];
|
||||||
case ProductGroup.CANVAS:
|
case 'painting':
|
||||||
return InteriorType[InteriorType.PAINTING];
|
return InteriorType[InteriorType.PAINTING];
|
||||||
case ProductGroup.POSTER:
|
case 'poster':
|
||||||
return InteriorType[InteriorType.POSTER];
|
return InteriorType[InteriorType.POSTER];
|
||||||
case ProductGroup.FRAMED_PRINT:
|
case 'framed-print':
|
||||||
return InteriorType[InteriorType.FRAMED_PRINT];
|
return InteriorType[InteriorType.FRAMED_PRINT];
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(`Unknown room type: ${roomTypePart}`);
|
||||||
`Could not define interior type from product group [${productGroup}]`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,12 +51,13 @@ export class InteriorAPI extends BaseSQLDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decorateRow(row: any): Interior {
|
decorateRow(row: any): Interior {
|
||||||
|
console.log('row', row);
|
||||||
if (row.roomName) {
|
if (row.roomName) {
|
||||||
const parts = row.roomName.split('_');
|
const parts = row.roomName.split('_');
|
||||||
row.roomNumber = this.getInteriorRoomNumber(parts[0]);
|
row.roomNumber = this.getInteriorRoomNumber(parts[0]);
|
||||||
|
row.type = this.getInteriorType(parts[1]);
|
||||||
row.orientation = this.getInteriorOrientation(parts[2]);
|
row.orientation = this.getInteriorOrientation(parts[2]);
|
||||||
}
|
}
|
||||||
row.type = this.getInteriorType(row.productGroup);
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,6 +75,7 @@ export class InteriorAPI extends BaseSQLDataSource {
|
|||||||
...row,
|
...row,
|
||||||
roomName: row.name,
|
roomName: row.name,
|
||||||
roomType: row.roomtype,
|
roomType: row.roomtype,
|
||||||
|
id: row.s3_suffix,
|
||||||
};
|
};
|
||||||
this.decorateRow(res);
|
this.decorateRow(res);
|
||||||
return res;
|
return res;
|
||||||
@@ -118,7 +116,7 @@ export class InteriorAPI extends BaseSQLDataSource {
|
|||||||
return rows.map((row) => {
|
return rows.map((row) => {
|
||||||
const res = {
|
const res = {
|
||||||
...row,
|
...row,
|
||||||
id: row.interiorId,
|
id: row.uri,
|
||||||
};
|
};
|
||||||
this.decorateRow(res);
|
this.decorateRow(res);
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Reference in New Issue
Block a user