-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfirmModal.tsx
28 lines (25 loc) · 1 KB
/
ConfirmModal.tsx
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
import React from "react";
import GenericModal from "./GenericModal";
import styled from "styled-components";
import { useDispatch } from "react-redux";
import {toggleModal} from "../Redux/modalSlice";
const ButtonDiv = styled.div`
display: flex;
`
// Generic component for confirmation modal
export default function ConfirmModal(props: { id: string, close: () => void, confirm: () => void, text: string,
header: string, innerText: string, onConfirm: () => void }) {
const dispatch = useDispatch();
return (
<GenericModal id={"confirmmodal"} close={() => {dispatch(toggleModal())}}>
<div>
<h2>{props.header}</h2>
<p>{props.innerText}</p>
<ButtonDiv>
<button className={"genericbutton"} onClick={() => dispatch(toggleModal())}>Cancel</button>
<button className={"genericbutton"} onClick={props.confirm}>Confirm</button>
</ButtonDiv>
</div>
</GenericModal>
)
}