-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
StatConfirm.jsx
47 lines (40 loc) · 1.02 KB
/
StatConfirm.jsx
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
43
44
45
46
47
/**
* @author oldj
*/
import React, { useState, useEffect } from 'react'
import MyFrame from './MyFrame'
import Agent from '../Agent'
import { Modal } from 'antd'
const send_usage_data = 'send_usage_data'
const StatConfirm = (props) => {
let {lang} = props
let [show, setShow] = useState(false)
useEffect(() => {
Agent.pact('getPref')
.then(pref => {
console.log(pref)
if (typeof pref[send_usage_data] !== 'boolean') {
setShow(true)
}
})
})
const setSend = (is_send) => {
Agent.pact('setPref', send_usage_data, is_send)
.then(() => setShow(false))
}
return (
<MyFrame
show={show}
title={lang.pref_tab_usage_data_title}
body={<div className="ln">{lang.pref_tab_usage_data_desc}</div>}
onOK={() => setSend(true)}
onCancel={() => setSend(false)}
lang={lang}
width={400}
okText={lang.send_usage_data_ok}
cancelText={lang.send_usage_data_cancel}
maskClosable={false}
/>
)
}
export default StatConfirm