Добавил автоопределение страны

master
Sipachev Igor 3 years ago
parent 576dfd3c5d
commit 8b8c0d64f4
  1. 40
      popup/src/api/CountryResolver.ts
  2. 5
      popup/src/components/person-tab/script.ts
  3. 8
      popup/src/components/person-tab/template.html

@ -0,0 +1,40 @@
import { Country } from '@/classes/Enum/Country'
export class CountryResolver {
resolve (): Promise<Country> {
const promise = new Promise((resolve) => {
if (typeof chrome.tabs === 'undefined') {
const country = this.grabCountry(location.href || '')
resolve(country)
return
}
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
for (const tab of tabs) {
const country = this.grabCountry(tab.url || '')
resolve(country)
return
}
})
})
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
return promise.then((country) => {
console.log('country', country)
return country
})
}
grabCountry (url: string): Country {
const isNordecum = url.indexOf('smspinigai') > -1 ||
url.indexOf('paskolos') > -1 ||
url.indexOf('nordecum') > -1
if (isNordecum) {
return Country.LITHUANIA
}
return Country.ESTONIA
}
}
export default new CountryResolver()

@ -10,6 +10,7 @@ import { Target } from '@/classes/Enum/Target'
import sender from '@/classes/Service/Browser/Chrome/Sender' import sender from '@/classes/Service/Browser/Chrome/Sender'
import { Action } from '@/classes/Enum/Action' import { Action } from '@/classes/Enum/Action'
import Mocks from '@/components/mocks/main.vue' import Mocks from '@/components/mocks/main.vue'
import countryResolver from '@/api/CountryResolver'
Vue.use(VueClipboard) Vue.use(VueClipboard)
@ -23,6 +24,10 @@ export default class PersonTab extends Vue {
person = new Person() person = new Person()
copyText = '' copyText = ''
async mounted () {
this.person.country = await countryResolver.resolve()
}
get allowedMonths () { get allowedMonths () {
const result = [] const result = []
for (let i = 1; i <= 12; i++) { for (let i = 1; i <= 12; i++) {

@ -17,11 +17,9 @@
<div class="form-row"> <div class="form-row">
<div class="form-row__item"> <div class="form-row__item">
<label> <label>
Country Country:
<select v-model="person.country"> <span v-if="person.country === 'ee'">Estonia</span>
<option value="ee">Estonia</option> <span v-if="person.country === 'lt'">Lithuania</span>
<option value="lt">Lithuania</option>
</select>
</label> </label>
</div> </div>
<div class="form-row__item"> <div class="form-row__item">

Loading…
Cancel
Save