import React, { useState } from "react"; import "../Card.css"; import { PrivateRoutes, PublicRoutes } from "../../../models/routes"; import { useDeleteTeacher } from "../../../services/teacher.services"; const API_URL = process.env.REACT_APP_API_URL; const CardProfesor = ({ profesor, edificioNombre, permissions }) => { const [showDialog, setShowDialog] = useState(false); const [confirmText, setConfirmText] = useState(""); const { deleteTeacher } = useDeleteTeacher(); const defaultImage = "https://static.vecteezy.com/system/resources/thumbnails/020/765/399/small_2x/default-profile-account-unknown-icon-black-silhouette-free-vector.jpg"; const fotoProfesor = profesor.fotografia || defaultImage; const handleDeleteClick = () => { setShowDialog(true); }; const handleConfirmDelete = async () => { if (confirmText.toLowerCase() === "aceptar") { await deleteTeacher(profesor.id_profesor); setShowDialog(false); setConfirmText(""); } }; const handleEditClick = () => { window.location.href = `${PrivateRoutes.EDITARPROFESOR}${profesor.id_profesor}`; }; const handleViewProfesor = () => { window.location.href = `${PublicRoutes.DATAPROFESOR}${profesor.id_profesor}`; }; return (
¿Deseas eliminar al profesor {profesor.nombre}?
Para borrar al profesor, escribe "aceptar".
setConfirmText(e.target.value)} />