Fix bug in payment.

This commit is contained in:
Gucheng Wang 2022-04-26 23:56:41 +08:00
parent 20fc7d1b58
commit e5c1f560c5
3 changed files with 18 additions and 10 deletions

View File

@ -31,7 +31,7 @@ import (
) )
func main() { func main() {
createDatabase := flag.Bool("createDatabase", false, "true if you need casdoor to create database") createDatabase := flag.Bool("createDatabase", false, "true if you need Casdoor to create database")
flag.Parse() flag.Parse()
object.InitAdapter(*createDatabase) object.InitAdapter(*createDatabase)

View File

@ -65,12 +65,6 @@ class PaymentEditPage extends React.Component {
} }
issueInvoice() { issueInvoice() {
const errorText = this.checkError();
if (errorText !== "") {
Setting.showMessage("error", errorText);
return;
}
alert("111") alert("111")
} }
@ -80,7 +74,7 @@ class PaymentEditPage extends React.Component {
renderModal() { renderModal() {
const ths = this; const ths = this;
const handleChangeMyTag = () => { const handleIssueInvoice = () => {
ths.issueInvoice(); ths.issueInvoice();
}; };
@ -98,7 +92,7 @@ class PaymentEditPage extends React.Component {
</div> </div>
} }
visible={this.state.isModalVisible} visible={this.state.isModalVisible}
onOk={handleChangeMyTag} onOk={handleIssueInvoice}
onCancel={handleCancel} onCancel={handleCancel}
okText={i18next.t("payment:Issue Invoice")} okText={i18next.t("payment:Issue Invoice")}
cancelText={i18next.t("general:Cancel")}> cancelText={i18next.t("general:Cancel")}>
@ -346,6 +340,12 @@ class PaymentEditPage extends React.Component {
{ {
this.state.payment.invoiceUrl === "" ? ( this.state.payment.invoiceUrl === "" ? (
<Button type={"primary"} onClick={() => { <Button type={"primary"} onClick={() => {
const errorText = this.checkError();
if (errorText !== "") {
Setting.showMessage("error", errorText);
return;
}
this.setState({ this.setState({
isModalVisible: true, isModalVisible: true,
}); });
@ -390,7 +390,7 @@ class PaymentEditPage extends React.Component {
return i18next.t("signup:The input is not invoice Tax ID!"); return i18next.t("signup:The input is not invoice Tax ID!");
} }
} else { } else {
if (this.state.payment.invoiceTitle === "" || !Setting.isValidInvoiceTitle(this.state.payment.invoiceTitle)) { if (!Setting.isValidInvoiceTitle(this.state.payment.invoiceTitle)) {
return i18next.t("signup:The input is not invoice title!"); return i18next.t("signup:The input is not invoice title!");
} }

View File

@ -206,12 +206,20 @@ export function isValidEmail(email) {
} }
export function isValidPhone(phone) { export function isValidPhone(phone) {
if (phone === "") {
return false;
}
// https://learnku.com/articles/31543, `^s*$` filter empty email individually. // https://learnku.com/articles/31543, `^s*$` filter empty email individually.
const phoneRegex = /^\s*$|^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/; const phoneRegex = /^\s*$|^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
return phoneRegex.test(phone); return phoneRegex.test(phone);
} }
export function isValidInvoiceTitle(invoiceTitle) { export function isValidInvoiceTitle(invoiceTitle) {
if (invoiceTitle === "") {
return false;
}
// https://blog.css8.cn/post/14210975.html // https://blog.css8.cn/post/14210975.html
const invoiceTitleRegex = /^[\(\)\\\u4e00-\u9fa5]{0,50}$/; const invoiceTitleRegex = /^[\(\)\\\u4e00-\u9fa5]{0,50}$/;
return invoiceTitleRegex.test(invoiceTitle); return invoiceTitleRegex.test(invoiceTitle);