forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
confirm_modal_redux.tsx
42 lines (33 loc) · 1012 Bytes
/
confirm_modal_redux.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useCallback, useState} from 'react';
import ConfirmModal from 'components/confirm_modal';
type Props = Omit<React.ComponentProps<typeof ConfirmModal>, 'show'> & {
onExited: () => void;
};
export default function ConfirmModalRedux(props: Props) {
const {
onCancel,
onConfirm,
onExited,
...otherProps
} = props;
const [show, setShow] = useState(true);
const wrappedOnCancel = useCallback((checked) => {
onCancel?.(checked);
setShow(false);
}, [onCancel]);
const wrappedOnConfirm = useCallback((checked) => {
onConfirm?.(checked);
setShow(false);
}, [onConfirm]);
return (
<ConfirmModal
{...otherProps}
onCancel={wrappedOnCancel}
onConfirm={wrappedOnConfirm}
onExited={onExited}
show={show}
/>
);
}