mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
add interface
This commit is contained in:
@@ -4,6 +4,7 @@ import { HttpService } from 'src/app/services/http.service';
|
||||
import { RoomListOutPutDTO } from '../dto/roomListOutputDTO';
|
||||
import { RoomListInputDTO } from '../dto/roomInputDTO';
|
||||
import { RoomOutPutDTO } from '../dto/roomOutputDTO';
|
||||
import { AddMemberToRoomInputDTO } from '../dto/addMemberToRoomInputDto';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -42,8 +43,8 @@ export class RoomRemoteDataSourceService {
|
||||
return await this.httpService.delete<any>(`${this.baseUrl}/Room/${id}`);
|
||||
}
|
||||
|
||||
async addMemberToRoom(id: string, member: any): Promise<Result<any ,any>> {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Room/${id}/Member`, member);
|
||||
async addMemberToRoom(data: AddMemberToRoomInputDTO) {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Room/${data.id}/Member`, data.member);
|
||||
}
|
||||
|
||||
async removeMemberFromRoom(id: string, member: any): Promise<Result<any ,any>> {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const AddMemberToRoomInputDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
member: z.string(),
|
||||
});
|
||||
|
||||
export type AddMemberToRoomInputDTO = z.infer<typeof AddMemberToRoomInputDTOSchema>
|
||||
@@ -5,6 +5,8 @@ import { IRepositoryReturn } from '../../type';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { addRoom, RoomRemoteDataSourceState } from '../data-source/room-memory-data-source';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AddMemberToRoomInputDTO, AddMemberToRoomInputDTOSchema } from '../dto/addMemberToRoomInputDto';
|
||||
import { RoomOutPutDTO } from '../dto/roomOutputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -21,7 +23,7 @@ export class RoomRepositoryService {
|
||||
}
|
||||
|
||||
@ValidateSchema(RoomListInputDTOSchema)
|
||||
async create(data: RoomListInputDTO): IRepositoryReturn<any> {
|
||||
async create(data: RoomListInputDTO): IRepositoryReturn<RoomOutPutDTO> {
|
||||
const result = await this.roomRemoteDataSourceService.createRoom(data)
|
||||
|
||||
if(result.isOk()) {
|
||||
@@ -34,4 +36,11 @@ export class RoomRepositoryService {
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@ValidateSchema(AddMemberToRoomInputDTOSchema)
|
||||
async addMemberToRoom(data: AddMemberToRoomInputDTO): IRepositoryReturn<AddMemberToRoomInputDTO> {
|
||||
const result = await this.roomRemoteDataSourceService.addMemberToRoom(data)
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import { GroupContactsPage } from '../group-messages/group-contacts/group-contac
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { RoomRepositoryService } from 'src/app/services/Repositorys/chat/repository/room-repository.service';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { RoomRepositoryService } from 'src/app/services/Repositorys/chat/repository/room-repository.service';
|
||||
@Component({
|
||||
selector: 'app-new-group',
|
||||
templateUrl: './new-group.page.html',
|
||||
@@ -183,6 +183,8 @@ export class NewGroupPage implements OnInit{
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
this.addGroupMessage.emit(result);
|
||||
|
||||
} else if(result.error instanceof HttpErrorResponse) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user