import React from "react"; import api from "../api.js"; import {useState} from "react"; export default function CloseVisitModal({visit}) { const modalId = `modal-${visit.id.replace(/\s+/g, '-')}`; const username = localStorage.getItem("username"); const [notes, setNotes] = useState(''); const handleCloseVisit = async () => { try { const response = await api.post('visits/close/', {id: visit.id, notes: notes}); if (response.status === 200) { onSuccess() } } catch (error) { alert(error.detail); } } const handleChange = (e) => { setNotes(e.target.value); } const onSuccess = () => { alert('Visit closed successfully!'); window.location.reload(); } return (