summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/containers/app/sidebars/topology/room/DeleteRoomContainer.js
blob: 3560c3818f57407b6a01545fd6b0cfa40f00cc57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { useState } from 'react'
import { useDispatch } from 'react-redux'
import { Button } from 'reactstrap'
import ConfirmationModal from '../../../../../components/modals/ConfirmationModal'
import { deleteRoom } from '../../../../../redux/actions/topology/room'

const DeleteRoomContainer = () => {
    const dispatch = useDispatch()
    const [isVisible, setVisible] = useState(false)
    const callback = (isConfirmed) => {
        if (isConfirmed) {
            dispatch(deleteRoom())
        }
        setVisible(false)
    }
    return (
        <>
            <Button color="danger" outline block onClick={() => setVisible(true)}>
                <span className="fa fa-trash mr-2" />
                Delete this room
            </Button>
            <ConfirmationModal
                title="Delete this room"
                message="Are you sure you want to delete this room?"
                show={isVisible}
                callback={callback}
            />
        </>
    )
}

export default DeleteRoomContainer