Created
March 23, 2017 11:00
-
-
Save riccoski/5ca97a7412b5be71869f55de4f0098c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { computed, observable } from "mobx" | |
export default class VATNumber { | |
@observable valid | |
@observable format_valid | |
@observable query | |
@observable country_code | |
@observable vat_number | |
@observable company_name | |
@observable company_address | |
store = null | |
constructor(store, data) { | |
if ( data != null ) { | |
Object.assign(this, { ...data }); | |
} | |
this.store = store | |
} | |
updateFromServer(data) { | |
if ( data != null ) { | |
Object.assign(this, { ...data }); | |
} | |
console.log("is valid", this.valid); | |
} | |
@computed get asJSON() { | |
return { | |
country_code: this.country_code, | |
vat_number: this.query | |
} | |
} | |
@computed get isInvalid() { | |
console.log("this.valid", this.valid); | |
return (this.valid === false) | |
} | |
@computed get isValid() { | |
console.log("this.valid", this.valid); | |
return (this.valid === true) | |
} | |
validate() { | |
this.store.validateVATNum(this.asJSON) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment