add confirm box

This commit is contained in:
Jay
2017-04-26 15:05:03 +08:00
parent 27d2209ea2
commit b07e51ef7c
11 changed files with 481 additions and 407 deletions
@@ -75,13 +75,15 @@ class Location extends React.Component {
delLocation = (id) => {
if(!id) return ;
let {showDialog} = this.props;
fetch('/api/wristband/dellocation', getRequest({id}))
.then(response => response.json())
.then(json => {
if(json.status != 1) return showDialog(json.message);
this.getList();
})
let {showDialog, callConfirm} = this.props;
callConfirm('確定要刪除這筆定位點資料?', ()=>{
fetch('/api/wristband/dellocation', getRequest({id}))
.then(response => response.json())
.then(json => {
if(json.status != 1) return showDialog(json.message);
this.getList();
})
})
}
render() {
@@ -44,13 +44,16 @@ class WristbandInfo extends React.Component {
delWristband = (id) => {
if(!id) return ;
let {showDialog, callConfirm} = this.props;
fetch('/api/wristband/delwristband', getRequest({id}))
.then(response=>response.json())
.then(json=>{
if(json.status!=1) return showDialog(json.message);
this.getList();
})
callConfirm('確定要刪除這筆手環資料?', ()=>{
fetch('/api/wristband/delwristband', getRequest({id}))
.then(response=>response.json())
.then(json=>{
if(json.status!=1) return showDialog(json.message);
this.getList();
})
})
}
openModal = (type, data = {}) => {
+15
View File
@@ -0,0 +1,15 @@
import React from 'react';
import {Modal, Button} from 'semantic-ui-react';
const ConfirmBox = ({obj, getNext}) => (
<Modal open={obj && obj.msg != '' ? true : false} onClose={() => getNext()} style={{zIndex: "2001"}}>
<Modal.Content>{obj && obj.msg ? obj.msg : ''}</Modal.Content>
<Modal.Actions>
<Button onClick={() => getNext(true, obj.act)} content="Submit" />
<Button onClick={() => getNext()} content="Cancel" />
</Modal.Actions>
</Modal>
);
export default ConfirmBox;