mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
81 lines
1.9 KiB
TypeScript
81 lines
1.9 KiB
TypeScript
|
|
import { HttpClient } from '@angular/common/http';
|
||
|
|
import { Component, OnInit } from '@angular/core';
|
||
|
|
import { ModalController, NavParams } from '@ionic/angular';
|
||
|
|
import { AuthService } from 'src/app/services/auth.service';
|
||
|
|
import { ChatService } from 'src/app/services/chat.service';
|
||
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
||
|
|
import { ToastService } from 'src/app/services/toast.service';
|
||
|
|
|
||
|
|
@Component({
|
||
|
|
selector: 'app-set-room-owner',
|
||
|
|
templateUrl: './set-room-owner.page.html',
|
||
|
|
styleUrls: ['./set-room-owner.page.scss'],
|
||
|
|
})
|
||
|
|
export class SetRoomOwnerPage implements OnInit {
|
||
|
|
|
||
|
|
textSearch:string = "";
|
||
|
|
room:any;
|
||
|
|
members:any;
|
||
|
|
|
||
|
|
constructor(
|
||
|
|
private modalController: ModalController,
|
||
|
|
private http: HttpClient,
|
||
|
|
private chatService: ChatService,
|
||
|
|
private authService: AuthService,
|
||
|
|
private navParams: NavParams,
|
||
|
|
public ThemeService: ThemeService,
|
||
|
|
private toastService: ToastService,
|
||
|
|
) {
|
||
|
|
this.room = this.navParams.get('room');
|
||
|
|
this.members = this.navParams.get('members');
|
||
|
|
}
|
||
|
|
|
||
|
|
ngOnInit() {
|
||
|
|
console.log(this.room);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
async close(){
|
||
|
|
this.modalController.dismiss();
|
||
|
|
}
|
||
|
|
|
||
|
|
onChange(event){
|
||
|
|
this.textSearch = event.detail.value;
|
||
|
|
}
|
||
|
|
|
||
|
|
separateLetter(record, recordIndex, records){
|
||
|
|
if(recordIndex == 0){
|
||
|
|
return record.name[0];
|
||
|
|
}
|
||
|
|
|
||
|
|
let first_prev = records[recordIndex - 1].name[0];
|
||
|
|
let first_current = record.name[0];
|
||
|
|
|
||
|
|
if(first_prev != first_current){
|
||
|
|
return first_current;
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
setRoomOwner(user:any){
|
||
|
|
|
||
|
|
console.log(user);
|
||
|
|
console.log(this.room);
|
||
|
|
|
||
|
|
let body = {
|
||
|
|
"roomId": this.room._id,
|
||
|
|
"userId": user._id
|
||
|
|
}
|
||
|
|
|
||
|
|
this.chatService.addGroupOwner(body).subscribe((res)=>{
|
||
|
|
console.log(res);
|
||
|
|
|
||
|
|
this.close();
|
||
|
|
}, (error) => {
|
||
|
|
this.toastService._badRequest('Não foi possível completar a ação, por favor tente novamente.');
|
||
|
|
});
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|