|
|
@@ -12,6 +12,7 @@ import { ModalTarea } from '../../../Profesor/pages/tareas/tareas.component';
|
|
|
import * as XLSX from 'xlsx';
|
|
|
import { TareasService } from '../../services/tareas.service';
|
|
|
import { MAT_DATE_LOCALE, provideNativeDateAdapter } from '@angular/material/core';
|
|
|
+import Swal from 'sweetalert2';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-tareas',
|
|
|
@@ -99,7 +100,45 @@ export class TareasComponent {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ completarTarea(idTarea: any) {
|
|
|
+ const data = {
|
|
|
+ idTarea: idTarea,
|
|
|
+ idUsuario: this.userDataS[0] ? this.userDataS[0] : this.userData[0]
|
|
|
+ };
|
|
|
|
|
|
+ Swal.fire({
|
|
|
+ title: '¿Quieres cambiar el estado de la tarea?',
|
|
|
+ text: 'Se marcará o desmarcará como completada.',
|
|
|
+ icon: 'question',
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonText: 'Sí, cambiar estado',
|
|
|
+ cancelButtonText: 'Cancelar',
|
|
|
+ confirmButtonColor: '#3085d6',
|
|
|
+ cancelButtonColor: '#d33'
|
|
|
+ }).then((result) => {
|
|
|
+ if (result.isConfirmed) {
|
|
|
+ this.tareasService.completarTarea(data).subscribe({
|
|
|
+ next: (response: any) => {
|
|
|
+ Swal.fire({
|
|
|
+ title: '¡Hecho!',
|
|
|
+ text: response.mensaje,
|
|
|
+ icon: 'success',
|
|
|
+ timer: 1500,
|
|
|
+ showConfirmButton: false
|
|
|
+ });
|
|
|
+ this.getTareas(); // Actualiza la lista
|
|
|
+ },
|
|
|
+ error: (err) => {
|
|
|
+ Swal.fire({
|
|
|
+ title: 'Error',
|
|
|
+ text: 'No se pudo cambiar el estado de la tarea.',
|
|
|
+ icon: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
public allInfo: any;
|
|
|
public files: any;
|
|
|
@@ -183,7 +222,7 @@ export class TareasComponent {
|
|
|
}
|
|
|
|
|
|
onFechaSeleccionada(event: any): void {
|
|
|
-
|
|
|
+
|
|
|
this.fechaSeleccionada = event.value;
|
|
|
if (!this.fechaSeleccionada) return;
|
|
|
const fechaFormateada = this.formatFecha(this.fechaSeleccionada);
|