Commit 1f207f9b authored by RenanMontenegro3's avatar RenanMontenegro3

fix: correção no erro relacionado ao envio de comentário no status "em...

fix: correção no erro relacionado ao envio de comentário no status "em processamento " em aceite-edit
parent 22b7ffcc
...@@ -573,10 +573,14 @@ selectedCategoriaNome: string = ''; ...@@ -573,10 +573,14 @@ selectedCategoriaNome: string = '';
this.empForm.get('status')?.setValue(value); this.empForm.get('status')?.setValue(value);
// Lógica adicional (opcional) // Lógica adicional (opcional)
if (value === 'aceito') { // Se for 'N' (Em Processamento), limpar observações/comentários
this.empForm.get('motivoNegacao')?.reset(); // Limpa o campo de motivo if (value === 'N') {
} else if (value === 'negado') { this.empForm.get('obs')?.setValue('');
this.empForm.get('bercos')?.reset(); // Limpa o campo de berços this.empForm.get('restricoes')?.setValue('');
} else if (value === 'Y') {
// exemplo: quando aceito, não mexer
} else if (value === 'NE') {
// exemplo: quando negado, não mexer
} }
} }
...@@ -607,9 +611,14 @@ selectedCategoriaNome: string = ''; ...@@ -607,9 +611,14 @@ selectedCategoriaNome: string = '';
onFormSubmit() { onFormSubmit() {
console.log(JSON.stringify(this.empForm.value)); console.log(JSON.stringify(this.empForm.value));
if (this.empForm.valid) { if (this.empForm.valid) {
const payload: any = { ...this.empForm.value };
if (payload.status === 'N') {
payload.obs = '';
payload.restricoes = '';
}
if (this.selectedFile) { if (this.selectedFile) {
this._empService.updateAceite(this.data.id, this.empForm.value, this.selectedFile).subscribe({ this._empService.updateAceite(this.data.id, payload, this.selectedFile).subscribe({
next: () => { next: () => {
this._dialogRef.close(true); this._dialogRef.close(true);
this.toastService.success('Aceite editado com sucesso'); this.toastService.success('Aceite editado com sucesso');
...@@ -619,7 +628,7 @@ selectedCategoriaNome: string = ''; ...@@ -619,7 +628,7 @@ selectedCategoriaNome: string = '';
}, },
}); });
} else { } else {
this._empService.updateAceite(this.data.id, this.empForm.value, null).subscribe({ this._empService.updateAceite(this.data.id, payload, null).subscribe({
next: () => { next: () => {
this._dialogRef.close(true); this._dialogRef.close(true);
this.toastService.success('Aceite editado com sucesso'); this.toastService.success('Aceite editado com sucesso');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment