import { useMutation, useFlash } from '@redwoodjs/web' import { Link, routes } from '@redwoodjs/router' import { Image as CloudinaryImage } from 'cloudinary-react' import avatar from 'src/assets/harold.jpg' const DELETE_PART_MUTATION = gql` mutation DeletePartMutation($id: Int!) { deletePart(id: $id) { id } } ` const MAX_STRING_LENGTH = 150 const truncate = (text) => { let output = text if (text && text.length > MAX_STRING_LENGTH) { output = output.substring(0, MAX_STRING_LENGTH) + '...' } return output } const jsonTruncate = (obj) => { return truncate(JSON.stringify(obj, null, 2)) } const timeTag = (datetime) => { return ( ) } const checkboxInputTag = (checked) => { return } const PartsList = ({ parts }) => { const { addMessage } = useFlash() const [deletePart] = useMutation(DELETE_PART_MUTATION, { onCompleted: () => { addMessage('Part deleted.', { classes: 'rw-flash-success' }) }, }) const onDeleteClick = (id) => { if (confirm('Are you sure you want to delete part ' + id + '?')) { deletePart({ variables: { id }, refetchQueries: ['PARTS'] }) } } return (