Migrates every component from class-based vue-property-decorator to
<script setup> + Composition API. Replaces Vuex 3 + vuex-class with a
single Pinia store (persisted via pinia-plugin-persistedstate). Swaps
Bulma + bulma-{checkradio,switch,pricingtable} for DaisyUI 5 utilities
on Tailwind 4. Replaces register-service-worker with vite-plugin-pwa
(workbox, skipWaiting/clientsClaim preserved).
Plugins replaced:
- vue-class-component / vue-property-decorator -> <script setup>
- vuex / vuex-class / vuex-persist -> pinia + persistedstate
- vue-i18n 8 -> vue-i18n 11 (composition mode, legacy: false)
- vue-click-outside -> @vueuse/core onClickOutside
- @xkeshi/vue-qrcode -> qrcode.vue
- vue-currency-input 1 -> vue-currency-input 3 (composable wrapper)
- bus-event (Vue instance) -> mitt
- Vue filters -> plain functions imported per component
BREAKING: drops Stripe / pricing entirely (Payment, PricingTable,
/pricing route, vue-stripe-checkout, bulma-pricingtable).
Clears unused Cypress and Jest test scaffolding; leaves a Vitest
harness behind for future tests.
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import ILocation from '@/models/ILocation'
|
|
import ILocationQuery from '@/models/ILocationQuery'
|
|
|
|
class MapService {
|
|
private key: string = import.meta.env.VITE_MAP_KEY || ''
|
|
|
|
public async getPosition(): Promise<ILocation | null> {
|
|
const position = await this.getCurrentPosition()
|
|
if (!position) {
|
|
return null
|
|
}
|
|
const { coords } = position
|
|
const location = {
|
|
lat: coords.latitude,
|
|
lon: coords.longitude
|
|
}
|
|
const place = await this.getPlace(location)
|
|
|
|
return {
|
|
...location,
|
|
place
|
|
}
|
|
}
|
|
|
|
public async getPlace(location: ILocation): Promise<string> {
|
|
const result = await fetch(this.url(location.lat, location.lon))
|
|
if (!result) {
|
|
return ''
|
|
}
|
|
const json: ILocationQuery = await result.json()
|
|
if (
|
|
!json ||
|
|
!json.resourceSets ||
|
|
!json.resourceSets.length ||
|
|
!json.resourceSets[0].resources.length
|
|
) {
|
|
return ''
|
|
}
|
|
const address = json.resourceSets[0].resources[0].address
|
|
return address ? address.locality : ''
|
|
}
|
|
|
|
private url(latitude: number, longitude: number) {
|
|
return `https://dev.virtualearth.net/REST/v1/Locations/${latitude},${longitude}?key=${this.key}`
|
|
}
|
|
|
|
private getCurrentPosition(): Promise<GeolocationPosition | null> {
|
|
return new Promise((resolve, reject) => {
|
|
if (!('geolocation' in navigator)) {
|
|
resolve(null)
|
|
return
|
|
}
|
|
navigator.geolocation.getCurrentPosition(resolve, reject)
|
|
})
|
|
}
|
|
}
|
|
|
|
export default new MapService()
|