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:
38
web/src/components/ConfirmDialog/ConfirmDialog.js
Normal file
38
web/src/components/ConfirmDialog/ConfirmDialog.js
Normal 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
|
||||
@@ -0,0 +1,7 @@
|
||||
import ConfirmDialog from './ConfirmDialog'
|
||||
|
||||
export const generated = () => {
|
||||
return <ConfirmDialog />
|
||||
}
|
||||
|
||||
export default { title: 'Components/ConfirmDialog' }
|
||||
11
web/src/components/ConfirmDialog/ConfirmDialog.test.js
Normal file
11
web/src/components/ConfirmDialog/ConfirmDialog.test.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { render } from '@redwoodjs/testing'
|
||||
|
||||
import ConfirmDialog from './ConfirmDialog'
|
||||
|
||||
describe('ConfirmDialog', () => {
|
||||
it('renders successfully', () => {
|
||||
expect(() => {
|
||||
render(<ConfirmDialog />)
|
||||
}).not.toThrow()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user