Files
Jobhero_front/src/app/pages/report-discussion/report-discussion.page.ts
Carlos c677fdcb59 feat: Reportes, chat de discusión y mejoras de navegación
- Tab "Reportados" en Contratos (cliente) y tab "Reportadas" en Postulaciones (proveedor) con skeleton loading e ionViewWillEnter
- Modal de chat para discusión de reportes: burbujas por rol (propio/otro/moderador), skeleton, input con cámara y envío
- Endpoints GET/POST contracts/reports/{id}/comments en ichamba.service
- userId guardado en AuthService desde auth/user para identificar mensajes propios
- Botón "Postularse" corregido con slot=end en ion-item
- Todas las secciones de tabs migradas de ngOnInit a ionViewWillEnter + ChangeDetectorRef.detectChanges()
- Android navigation bar reactiva al tema del sistema vía values/values-night styles.xml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 21:05:24 -06:00

81 lines
2.1 KiB
TypeScript

import { Component, Input, OnInit, ViewChild, ChangeDetectorRef } from '@angular/core';
import { IonContent, ModalController } from '@ionic/angular';
import { IchambaService } from 'src/app/services/ichamba.service';
import { AuthService } from 'src/app/services/auth.service';
import { AlertService } from 'src/app/services/alert.service';
@Component({
selector: 'app-report-discussion',
templateUrl: './report-discussion.page.html',
styleUrls: ['./report-discussion.page.scss'],
standalone: false
})
export class ReportDiscussionPage implements OnInit {
@Input() reportId: any;
@ViewChild('content') content!: IonContent;
messages: any[] = [];
newMessage: string = '';
currentUserId: any;
loading = true;
sending = false;
constructor(
private modalCtrl: ModalController,
private ichambaService: IchambaService,
private authService: AuthService,
private alertService: AlertService,
private cdr: ChangeDetectorRef,
) {}
ngOnInit() {
this.currentUserId = this.authService.userId;
this.loadMessages();
}
loadMessages() {
this.loading = true;
this.ichambaService.getReportDiscussion(this.reportId).subscribe({
next: data => {
this.messages = data;
this.loading = false;
this.cdr.detectChanges();
setTimeout(() => this.content.scrollToBottom(300), 100);
},
error: () => {
this.loading = false;
this.cdr.detectChanges();
}
});
}
sendMessage() {
const text = this.newMessage.trim();
if (!text || this.sending) return;
this.newMessage = '';
this.sending = true;
this.ichambaService.sendReportMessage(this.reportId, text).subscribe({
next: (msg: any) => {
this.messages.push(msg);
this.sending = false;
this.cdr.detectChanges();
setTimeout(() => this.content.scrollToBottom(300), 100);
},
error: () => {
this.sending = false;
this.alertService.presentToast('No se pudo enviar el mensaje.');
}
});
}
attachPhoto() {
// TODO: implementar captura y envío de foto
}
dismiss() {
this.modalCtrl.dismiss();
}
}