import { ContactPointInfo, deleteContactPoint, getContactPoints, } from '@/api/contactPoints' import { useState } from 'preact/hooks' import { useMutation, useQuery } from 'react-query' import { ContactPointFormModal } from './components/ContactPointFormModal' import { DataTable } from '@/components/DataTable' import { ConfirmModal } from '@/components/ConfirmModal' import { PlusIcon } from '@/icons' export const ContactPointsTable = () => { const contactPoints = useQuery('/contact-points', () => getContactPoints()) const deleteMutation = useMutation(deleteContactPoint, { onSuccess: () => { contactPoints.refetch() setShowDelete(undefined) }, }) const [showNew, setShowNew] = useState(false) const [edited, setEdited] = useState() const [showDelete, setShowDelete] = useState() return (

Contact Points

c.name, scale: 1 }, { key: 'type', title: 'Type', render: (c) => c.type, width: '5rem', }, { key: 'actions', title: 'Actions', width: '10rem', className: 'actions', render: (c) => (
), }, ]} />
{(showNew || edited) && ( { setShowNew(false) setEdited(undefined) }} /> )} {showDelete && ( deleteMutation.mutate(showDelete.id)} onCancel={() => setShowDelete(undefined)} confirmText="Delete" > Do you want to delete {showDelete.name} contact point? )}
) }