import { Box, Button } from '@mui/material'; import { useRouter } from 'next/dist/client/router'; import { useState } from 'react'; const row = { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }; const labelColumn = { fontWeight: 'bold', width: '25%', }; const valueColumn = { width: '75%', }; const cardTitle = { fontWeight: 'bold', fontSize: '1.2rem', display: 'flex', flexDirection: 'row', justifyContent: 'center', }; export default ({ queue_data, show_edit_delete = true }) => { const router = useRouter(); const [changing_page, setChangingPage] = useState(false); function handleDeleteItemClick({ queue_type, id }) { setChangingPage(true); fetch(`/api/patient_queue/delete_queue_item?queue_type=${queue_type}&id=${id}`, { method: 'GET', }) .then(response => response.json()) .then(data => { if (data.status === 'OK') { console.log('item deleted'); alert('item deleted'); router.reload(); } else { console.error(data.message); } }) .catch(err => { console.error(err); alert('error during removing queue'); }); } function handleEditItemClick({ id }) { setChangingPage(true); router.push(`/NonUrgentCaseEdit/${id}`); } return ( {`non-urgent-case ${queue_data.id}`} Name {queue_data.name || ''} HKID {queue_data.hkid || '-'} Mobile {queue_data.mobile || '-'} {/* */} ); };