mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
Merge pull request #114 from SyncrowIOT/SP-288-be-display-the-devices-lights-ac-and-curtains-in-wizard
add filter to get groups api
This commit is contained in:
@ -14,4 +14,5 @@ export enum ProductType {
|
||||
ONE_1TG = '1GT',
|
||||
WL = 'WL',
|
||||
GD = 'GD',
|
||||
CUR = 'CUR',
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import { convertKeysToCamelCase } from '@app/common/helper/camelCaseConverter';
|
||||
import { ProductRepository } from '@app/common/modules/product/repositories';
|
||||
import { PermissionType } from '@app/common/constants/permission-type.enum';
|
||||
import { In } from 'typeorm';
|
||||
import { ProductType } from '@app/common/constants/product-type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class GroupService {
|
||||
@ -44,8 +45,24 @@ export class GroupService {
|
||||
});
|
||||
|
||||
const uniqueGroupNames = [...new Set(groupNames)];
|
||||
|
||||
return uniqueGroupNames.map((groupName) => ({ groupName }));
|
||||
const groups = uniqueGroupNames.map((groupName) => ({
|
||||
groupName: groupName as ProductType,
|
||||
}));
|
||||
const allowedProductTypes = [
|
||||
ProductType.ONE_1TG,
|
||||
ProductType.TWO_2TG,
|
||||
ProductType.THREE_3TG,
|
||||
ProductType.THREE_G,
|
||||
ProductType.TWO_G,
|
||||
ProductType.ONE_G,
|
||||
ProductType.GD,
|
||||
ProductType.WH,
|
||||
ProductType.AC,
|
||||
ProductType.CUR,
|
||||
];
|
||||
return groups.filter((group) =>
|
||||
allowedProductTypes.includes(group.groupName),
|
||||
);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
'This unit does not have any groups',
|
||||
|
Reference in New Issue
Block a user