-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbusiness.js
51 lines (39 loc) · 894 Bytes
/
business.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import API from '../api/businesses'
import locales from '../locales'
class Business {
constructor(id) {
this.id = id
this.data = {}
this.fetchPublicData()
}
get subscription() {
return this.data.subscription
}
get country() {
return this.data.country
}
get enabledWhitelist() {
return this.data.whitelist !== 'disabled'
}
get locale() {
return locales[this.data.locale]
}
get features() {
return this.data.features
}
// private
fetchPublicData() {
API.get(this.id)
.then(response => response.json())
.then(data => {
this.data = data
if(typeof document !== 'undefined') {
const linkTag = document.createElement('link')
linkTag.rel = 'stylesheet'
linkTag.href = data.style_url
document.head.append(linkTag)
}
})
}
}
export { Business }