import { useMutation, useFlash } from '@redwoodjs/web' import { Link, routes, navigate } from '@redwoodjs/router' const DELETE_PART_MUTATION = gql` mutation DeletePartMutation($id: String!) { deletePart(id: $id) { id } } ` const jsonDisplay = (obj) => { return (
{JSON.stringify(obj, null, 2)}
)
}
const timeTag = (datetime) => {
return (
)
}
const checkboxInputTag = (checked) => {
return
}
const Part = ({ part }) => {
const { addMessage } = useFlash()
const [deletePart] = useMutation(DELETE_PART_MUTATION, {
onCompleted: () => {
navigate(routes.parts())
addMessage('Part deleted.', { classes: 'rw-flash-success' })
},
})
const onDeleteClick = (id) => {
if (confirm('Are you sure you want to delete part ' + id + '?')) {
deletePart({ variables: { id } })
}
}
return (
<>
| Id | {part.id} |
|---|---|
| Title | {part.title} |
| Description | {part.description} |
| Code | {part.code} |
| Main image | {part.mainImage} |
| Created at | {timeTag(part.createdAt)} |
| Updated at | {timeTag(part.updatedAt)} |
| User id | {part.userId} |