feat: support storage provider to terms of use file (#221)

Signed-off-by: WindSpiritSR <simon343riley@gmail.com>
This commit is contained in:
WindSpiritSR
2021-08-10 10:43:33 +08:00
committed by Yang Luo
parent 718fc4df74
commit 8c6f0a31b6
9 changed files with 113 additions and 55 deletions

View File

@ -72,6 +72,7 @@ class SignupPage extends React.Component {
validPhone: false,
region: "",
isTermsOfUseVisible: false,
termsOfUseContent: "",
};
this.form = React.createRef();
@ -95,6 +96,7 @@ class SignupPage extends React.Component {
this.setState({
application: application,
});
this.getTermsofuseContent(application.termsOfUse);
});
}
@ -118,6 +120,16 @@ class SignupPage extends React.Component {
}
}
getTermsofuseContent(url) {
fetch(url, {
method: "GET",
}).then(r => {
r.text().then(res => {
this.setState({termsOfUseContent: res})
})
})
}
onUpdateAccount(account) {
this.props.onUpdateAccount(account);
}
@ -407,23 +419,25 @@ class SignupPage extends React.Component {
<Modal
title={i18next.t("signup:Terms of Use")}
visible={this.state.isTermsOfUseVisible}
width={"55vw"}
closable={false}
footer={[
<Button key="agree" type="primary" onClick={() => {
this.setState({
isTermsOfUseVisible: false,
});
}}>
{i18next.t("user:OK")}
</Button>,
// <Button key="decline" onClick={() => {
// this.props.history.goBack();
// }}>
// {i18next.t("signup:Decline")}
// </Button>,
]}
okText={i18next.t("signup:Accept")}
cancelText={i18next.t("signup:Decline")}
onOk={() => {
this.form.current.setFieldsValue({agreement: true})
this.setState({
isTermsOfUseVisible: false,
});
}}
onCancel={() => {
this.form.current.setFieldsValue({agreement: false})
this.setState({
isTermsOfUseVisible: false,
});
this.props.history.goBack();
}}
>
<div dangerouslySetInnerHTML={{__html: this.state.application?.termsOfUse}} />
<iframe style={{border: 0, width: "100%", height: "60vh"}} srcDoc={this.state.termsOfUseContent}/>
</Modal>
)
}