Skip to content

Commit

Permalink
Refactor duplicated variables
Browse files Browse the repository at this point in the history
  • Loading branch information
benguozakinci@gmail.com authored and benguozakinci@gmail.com committed Jul 2, 2021
1 parent 165f857 commit 8f27089
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions resources/assets/js/views/common/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
'.,',
',.',
',,'
]
],
splice_value: null
}
},

Expand All @@ -46,13 +47,11 @@
this.form.sale_price = oldVal;
}

let splice_value;

if (newVal.search('^(?=.*?[0-9])[0-9.,]+$') == 0) {
for (let item of this.regex_condition) {
if (this.form.sale_price.includes(item)) {
splice_value = this.form.sale_price.replace(item, '');
this.form.sale_price = splice_value;
this.splice_value = this.form.sale_price.replace(item, '');
this.form.sale_price = this.splice_value;
}
}
}
Expand All @@ -63,13 +62,11 @@
this.form.purchase_price = oldVal;
}

let splice_value;

if (newVal.search('^(?=.*?[0-9])[0-9.,]+$') == 0) {
for (let item of this.regex_condition) {
if (this.form.purchase_price.includes(item)) {
splice_value = this.form.purchase_price.replace(item, '');
this.form.purchase_price = splice_value;
this.splice_value = this.form.purchase_price.replace(item, '');
this.form.purchase_price = this.splice_value;
}
}
}
Expand Down

0 comments on commit 8f27089

Please sign in to comment.