diff --git a/src/app/services/Repositorys/chat/data-source/room/room-remote-data-source.service.ts b/src/app/services/Repositorys/chat/data-source/room/room-remote-data-source.service.ts index d56c2d558..05672cae7 100644 --- a/src/app/services/Repositorys/chat/data-source/room/room-remote-data-source.service.ts +++ b/src/app/services/Repositorys/chat/data-source/room/room-remote-data-source.service.ts @@ -11,6 +11,7 @@ import { RoomByIdInputDTO, RoomByIdInputDTOSchema } from '../../dto/room/roomByI import { RoomByIdOutputDTO, RoomByIdOutputDTOSchema } from '../../dto/room/roomByIdOutputDTO'; import { APIReturn } from 'src/app/services/decorators/api-validate-schema.decorator'; import { UserRemoveListInputDTO, UserRemoveListInputDTOSchema } from '../../dto/room/userRemoveListInputDTO'; +import { RoomUpdateInputDTO } from '../../dto/room/roomUpdateInputDTO'; @Injectable({ providedIn: 'root' @@ -40,8 +41,12 @@ export class RoomRemoteDataSourceService { return await this.httpService.get(`${this.baseUrl}/Room/${id}`); } - async updateRoom(id: string, room: any): Promise> { - return await this.httpService.put(`${this.baseUrl}/Room/${id}`, room); + @ValidateSchema(AddMemberToRoomInputDTOSchema) + //@APIReturn(RoomByIdOutputDTOSchema,'update/Room/${id}') + async updateRoom(data: RoomUpdateInputDTO): Promise> { + const id = data.roomId + delete data.roomId + return await this.httpService.put(`${this.baseUrl}/Room/${id}`, data); } async deleteRoom(id: string): Promise> { diff --git a/src/app/services/Repositorys/chat/dto/room/roomUpdateInputDTO.ts b/src/app/services/Repositorys/chat/dto/room/roomUpdateInputDTO.ts new file mode 100644 index 000000000..e6d5e5676 --- /dev/null +++ b/src/app/services/Repositorys/chat/dto/room/roomUpdateInputDTO.ts @@ -0,0 +1,9 @@ +import { z } from "zod"; + +export const RoomUpdateInputDTOSchema = z.object({ + roomName: z.string(), + roomId: z.string(), + roomType: z.number(), +}); + +export type RoomUpdateInputDTO = z.infer diff --git a/src/app/services/Repositorys/chat/dto/room/roomUpdateOutputDTO.ts b/src/app/services/Repositorys/chat/dto/room/roomUpdateOutputDTO.ts new file mode 100644 index 000000000..d323e7bef --- /dev/null +++ b/src/app/services/Repositorys/chat/dto/room/roomUpdateOutputDTO.ts @@ -0,0 +1,8 @@ +import { z } from "zod"; + +export const RoomUpdateOutputDTOSchema = z.object({ + roomName: z.string(), + roomType: z.number(), +}); + +export type RoomUpdateOutputDTO = z.infer diff --git a/src/app/services/Repositorys/chat/repository/room-repository.service.ts b/src/app/services/Repositorys/chat/repository/room-repository.service.ts index 48ef8369f..fcee03432 100644 --- a/src/app/services/Repositorys/chat/repository/room-repository.service.ts +++ b/src/app/services/Repositorys/chat/repository/room-repository.service.ts @@ -10,6 +10,7 @@ import { roomListDetermineChanges } from '../async/rooms/roomListChangeDetector' import { UserRemoveListInputDTO } from '../dto/room/userRemoveListInputDTO'; import { roomMemberListDetermineChanges } from '../async/rooms/roomMembersChangeDetector'; import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync'; +import { RoomUpdateInputDTO } from '../dto/room/roomUpdateInputDTO'; @Injectable({ providedIn: 'root' @@ -53,6 +54,11 @@ export class RoomRepositoryService { } + @captureAndReraiseAsync('RoomRepositoryService/updateRoomBy') + async updateRoomBy(data: RoomUpdateInputDTO) { + this.roomRemoteDataSourceService.updateRoom(data) + } + @captureAndReraiseAsync('RoomRepositoryService/getRoomById') async getRoomById(id: RoomByIdInputDTO) { const result = await this.roomRemoteDataSourceService.getRoom(id) diff --git a/src/app/shared/chat/edit-group/edit-group.page.html b/src/app/shared/chat/edit-group/edit-group.page.html index 75532b7e5..b636be1f0 100644 --- a/src/app/shared/chat/edit-group/edit-group.page.html +++ b/src/app/shared/chat/edit-group/edit-group.page.html @@ -12,7 +12,7 @@
Alterar assunto
- + ..1 @@ -38,7 +38,7 @@ - - + + diff --git a/src/app/shared/chat/edit-group/edit-group.page.ts b/src/app/shared/chat/edit-group/edit-group.page.ts index 1fc69451b..49be9b500 100644 --- a/src/app/shared/chat/edit-group/edit-group.page.ts +++ b/src/app/shared/chat/edit-group/edit-group.page.ts @@ -40,24 +40,24 @@ export class EditGroupPage implements OnInit { getRoomInfo(){ this.chatService.getRoomInfo(this.roomId).subscribe(room=>{ this.room = room['room']; - + try { this.groupName = this.room.name.split('-').join(' '); } catch (error) { this.groupName = this.room.name; } - + }); } - close(){ + close() { //this.modalController.dismiss(); this.closeAllDesktopComponents.emit(); this.openGroupMessage.emit(this.roomId); } - changeGroupName(){ - if(this.groupName.trim().length > 1){ + changeGroupName() { + if(this.groupName.trim().length > 1) { let name = this.groupName.split(' ').join('-'); let body = { "roomId": this.room._id, @@ -68,7 +68,7 @@ export class EditGroupPage implements OnInit { }); } else{ - + } this.updateGroup(); } @@ -96,13 +96,13 @@ export class EditGroupPage implements OnInit { text: 'Ok', cssClass: 'btn-cancel', handler:(value:any)=>{ - + this.selectedDuration = [ value.days.value, value.hours.value, value.minutes.value, ] - + if(value.days.value != null && value.hours.value != null && value.minutes.value != null){ if(value.days.value > 0){ if(value.days.value == 1){ diff --git a/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts b/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts index 7a47f1c5c..153524bfe 100644 --- a/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts +++ b/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts @@ -10,6 +10,7 @@ import { SessionStore } from 'src/app/store/session.service'; import { HttpRequest } from '@angular/common/http'; import { ZodError } from 'zod'; import { HttpResponse } from '@microsoft/signalr'; +import { ToastService } from 'src/app/services/toast.service'; @Component({ selector: 'app-group-contacts', @@ -39,6 +40,7 @@ export class GroupContactsPage implements OnInit { private contactsRepositoryService: ContactRepositoryService, private RoomRepositoryService: RoomRepositoryService, private httpErrorHandle: HttpErrorHandle, + private toastService: ToastService, ) {} ngOnInit(): void { @@ -107,7 +109,7 @@ export class GroupContactsPage implements OnInit { } else if (getallChatUsers.isErr() && getallChatUsers.error instanceof HttpResponse) { this.httpErrorHandle.httpStatusHandle(getallChatUsers.error) } else { - alert('else') + this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.") } const currentMemberIds = this.currentMembers.map(e => e.wxUserId)