issue-159 Add delete button to part profile (for part owner)

schema had to be update to add a deleted boolean to part.
Easier than setting up cascading deletes for comments and reactions.
resolves #159
This commit is contained in:
Kurt Hutten
2020-12-13 12:25:54 +11:00
parent 6b97307c3f
commit 2b763f23d8
14 changed files with 326 additions and 21 deletions

View File

@@ -0,0 +1,38 @@
import Dialog from '@material-ui/core/Dialog'
import Button from 'src/components/Button'
const ConfirmDialog = ({ open, onClose, message, onConfirm }) => {
return (
<Dialog open={open} onClose={onClose}>
<div className="bg-gray-100 max-w-3xl rounded-lg shadow-lg">
<div className="p-4">
<span className="text-gray-600 text-center">{message}</span>
<div className="flex gap-4">
<Button
className="mt-4 ml-auto shadow-md hover:shadow-lg bg-indigo-200 relative z-20"
shouldAnimateHover
iconName={'save'}
onClick={onClose}
>
Don't delete
</Button>
<Button
className="mt-4 ml-auto shadow-md hover:shadow-lg bg-red-200 relative z-20"
shouldAnimateHover
iconName={'trash'}
onClick={() => {
onClose()
onConfirm()
}}
type="danger"
>
Yes, Delete
</Button>
</div>
</div>
</div>
</Dialog>
)
}
export default ConfirmDialog

View File

@@ -0,0 +1,7 @@
import ConfirmDialog from './ConfirmDialog'
export const generated = () => {
return <ConfirmDialog />
}
export default { title: 'Components/ConfirmDialog' }

View File

@@ -0,0 +1,11 @@
import { render } from '@redwoodjs/testing'
import ConfirmDialog from './ConfirmDialog'
describe('ConfirmDialog', () => {
it('renders successfully', () => {
expect(() => {
render(<ConfirmDialog />)
}).not.toThrow()
})
})