finished add default icon for scene

This commit is contained in:
faris Aljohari
2024-10-28 01:51:27 -05:00
parent 5539f5f52a
commit 86fb73ab8d
8 changed files with 70 additions and 4 deletions

View File

@ -74,10 +74,10 @@ export class AddSceneTapToRunDto {
public unitUuid: string;
@ApiProperty({
description: 'Icon UUID',
required: true,
required: false,
})
@IsString()
@IsNotEmpty()
@IsOptional()
public iconUuid: string;
@ApiProperty({
description: 'show in home page',

View File

@ -28,6 +28,7 @@ import {
SceneIconRepository,
SceneRepository,
} from '@app/common/modules/scene/repositories';
import { SceneIconType } from '@app/common/constants/secne-icon-type.enum';
@Injectable()
export class SceneService {
@ -101,10 +102,16 @@ export class SceneService {
if (!response.success) {
throw new HttpException(response.msg, HttpStatus.BAD_REQUEST);
} else {
const defaultSceneIcon = await this.sceneIconRepository.findOne({
where: { iconType: SceneIconType.Default },
});
await this.sceneRepository.save({
sceneTuyaUuid: response.result.id,
sceneIcon: {
uuid: addSceneTapToRunDto.iconUuid,
uuid: addSceneTapToRunDto.iconUuid
? addSceneTapToRunDto.iconUuid
: defaultSceneIcon.uuid,
},
showInHomePage: addSceneTapToRunDto.showInHomePage,
unitUuid: unitUuid ? unitUuid : addSceneTapToRunDto.unitUuid,
@ -174,7 +181,7 @@ export class SceneService {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { actions, ...rest } = sceneData;
return {
rest,
...rest,
};
}),
);