Skip to content

Commit

Permalink
Fix bug in payment.
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Apr 26, 2022
1 parent 20fc7d1 commit e5c1f56
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

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()

object.InitAdapter(*createDatabase)
Expand Down
18 changes: 9 additions & 9 deletions web/src/PaymentEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ class PaymentEditPage extends React.Component {
}

issueInvoice() {
const errorText = this.checkError();
if (errorText !== "") {
Setting.showMessage("error", errorText);
return;
}

alert("111")
}

Expand All @@ -80,7 +74,7 @@ class PaymentEditPage extends React.Component {

renderModal() {
const ths = this;
const handleChangeMyTag = () => {
const handleIssueInvoice = () => {
ths.issueInvoice();
};

Expand All @@ -98,7 +92,7 @@ class PaymentEditPage extends React.Component {
</div>
}
visible={this.state.isModalVisible}
onOk={handleChangeMyTag}
onOk={handleIssueInvoice}
onCancel={handleCancel}
okText={i18next.t("payment:Issue Invoice")}
cancelText={i18next.t("general:Cancel")}>
Expand Down Expand Up @@ -346,6 +340,12 @@ class PaymentEditPage extends React.Component {
{
this.state.payment.invoiceUrl === "" ? (
<Button type={"primary"} onClick={() => {
const errorText = this.checkError();
if (errorText !== "") {
Setting.showMessage("error", errorText);
return;
}

this.setState({
isModalVisible: true,
});
Expand Down Expand Up @@ -390,7 +390,7 @@ class PaymentEditPage extends React.Component {
return i18next.t("signup:The input is not invoice Tax ID!");
}
} 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!");
}

Expand Down
8 changes: 8 additions & 0 deletions web/src/Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,20 @@ export function isValidEmail(email) {
}

export function isValidPhone(phone) {
if (phone === "") {
return false;
}

// 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}$/;
return phoneRegex.test(phone);
}

export function isValidInvoiceTitle(invoiceTitle) {
if (invoiceTitle === "") {
return false;
}

// https://blog.css8.cn/post/14210975.html
const invoiceTitleRegex = /^[\(\)\(\)\u4e00-\u9fa5]{0,50}$/;
return invoiceTitleRegex.test(invoiceTitle);
Expand Down

0 comments on commit e5c1f56

Please sign in to comment.