flowrix 1.0.1-beta.130 → 1.0.1-beta.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -53,11 +53,13 @@ export declare function useLocation(): {
|
|
|
53
53
|
changeStates: (selectedCountry: string | number) => void;
|
|
54
54
|
changeLocation: (data?: Partial<LocationInputs>) => Promise<void>;
|
|
55
55
|
updateLocationData: (data?: Partial<LocationInputs>) => Promise<void>;
|
|
56
|
-
getLocation: () => Promise<void>;
|
|
56
|
+
getLocation: (skipBrowserRequest?: boolean) => Promise<void>;
|
|
57
57
|
checkCurrentLocation: () => void;
|
|
58
58
|
initLocationInputs: () => void;
|
|
59
59
|
loadLocation: () => LocationData | null;
|
|
60
60
|
checkLocationPermission: () => Promise<string>;
|
|
61
61
|
initializeCountriesAndStates: () => Promise<void>;
|
|
62
|
+
requestBrowserLocation: () => Promise<boolean>;
|
|
63
|
+
openLocationModal: () => void;
|
|
62
64
|
};
|
|
63
65
|
export {};
|
|
@@ -134,37 +134,40 @@ export function useLocation() {
|
|
|
134
134
|
return "error";
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
-
const
|
|
138
|
-
return new Promise((resolve
|
|
137
|
+
const requestBrowserLocation = async () => {
|
|
138
|
+
return new Promise((resolve) => {
|
|
139
139
|
if (!navigator.geolocation) {
|
|
140
|
-
|
|
140
|
+
console.log("Geolocation not supported");
|
|
141
|
+
resolve(false);
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
144
|
navigator.geolocation.getCurrentPosition(
|
|
144
145
|
async (position) => {
|
|
145
146
|
try {
|
|
146
147
|
await processGeolocation(position);
|
|
147
|
-
resolve();
|
|
148
|
+
resolve(true);
|
|
148
149
|
} catch (error) {
|
|
149
|
-
|
|
150
|
+
console.error("Error processing geolocation:", error);
|
|
151
|
+
resolve(false);
|
|
150
152
|
}
|
|
151
153
|
},
|
|
152
|
-
|
|
153
|
-
console.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (changeLocationBtn) {
|
|
160
|
-
changeLocationBtn.click();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
reject(error);
|
|
154
|
+
(error) => {
|
|
155
|
+
console.log("Geolocation denied or failed:", error.message);
|
|
156
|
+
resolve(false);
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
timeout: 1e4,
|
|
160
|
+
maximumAge: 0
|
|
164
161
|
}
|
|
165
162
|
);
|
|
166
163
|
});
|
|
167
164
|
};
|
|
165
|
+
const getBrowserLocation = async () => {
|
|
166
|
+
const success = await requestBrowserLocation();
|
|
167
|
+
if (!success) {
|
|
168
|
+
throw new Error("Browser location unavailable");
|
|
169
|
+
}
|
|
170
|
+
};
|
|
168
171
|
const processGeolocation = async (position) => {
|
|
169
172
|
const lat = position.coords.latitude;
|
|
170
173
|
const lng = position.coords.longitude;
|
|
@@ -199,9 +202,7 @@ export function useLocation() {
|
|
|
199
202
|
}
|
|
200
203
|
} catch (error) {
|
|
201
204
|
console.error("Geocoding error:", error);
|
|
202
|
-
|
|
203
|
-
await locationStore.getLocation();
|
|
204
|
-
}
|
|
205
|
+
throw error;
|
|
205
206
|
}
|
|
206
207
|
};
|
|
207
208
|
const extractLocationData = (results) => {
|
|
@@ -236,11 +237,11 @@ export function useLocation() {
|
|
|
236
237
|
const initializeCountriesAndStates = async () => {
|
|
237
238
|
try {
|
|
238
239
|
if (!countries.value || countries.value.length === 0) {
|
|
239
|
-
|
|
240
|
+
await countriesStore.getCountries();
|
|
240
241
|
}
|
|
241
242
|
await nextTick();
|
|
242
243
|
if (countries.value && countries.value.length > 0) {
|
|
243
|
-
|
|
244
|
+
getStates(companyCountryId.value);
|
|
244
245
|
const defaultCountry = countries.value.find((c) => c.id === companyCountryId.value);
|
|
245
246
|
if (defaultCountry) {
|
|
246
247
|
locationInputs.value.country = defaultCountry.name;
|
|
@@ -251,7 +252,7 @@ export function useLocation() {
|
|
|
251
252
|
console.error("Error initializing countries and states:", error);
|
|
252
253
|
}
|
|
253
254
|
};
|
|
254
|
-
const getLocation = async () => {
|
|
255
|
+
const getLocation = async (skipBrowserRequest = true) => {
|
|
255
256
|
try {
|
|
256
257
|
await initializeCountriesAndStates();
|
|
257
258
|
if (location.value) {
|
|
@@ -261,14 +262,6 @@ export function useLocation() {
|
|
|
261
262
|
if (profile.value) {
|
|
262
263
|
profile.value.iplocation = true;
|
|
263
264
|
}
|
|
264
|
-
if (window.GeocodingAPI && !location.value) {
|
|
265
|
-
try {
|
|
266
|
-
await getBrowserLocation();
|
|
267
|
-
return;
|
|
268
|
-
} catch (error) {
|
|
269
|
-
console.log("Browser location failed, falling back to IP location");
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
265
|
if (profile.value?.iplocation && !location.value) {
|
|
273
266
|
await locationStore.getLocation();
|
|
274
267
|
}
|
|
@@ -315,6 +308,12 @@ export function useLocation() {
|
|
|
315
308
|
}
|
|
316
309
|
return null;
|
|
317
310
|
};
|
|
311
|
+
const openLocationModal = () => {
|
|
312
|
+
const changeLocationBtn = document.querySelector(".change_location");
|
|
313
|
+
if (changeLocationBtn) {
|
|
314
|
+
changeLocationBtn.click();
|
|
315
|
+
}
|
|
316
|
+
};
|
|
318
317
|
watch(location, (newLocation) => {
|
|
319
318
|
if (newLocation) {
|
|
320
319
|
initLocationInputs();
|
|
@@ -352,6 +351,10 @@ export function useLocation() {
|
|
|
352
351
|
initLocationInputs,
|
|
353
352
|
loadLocation,
|
|
354
353
|
checkLocationPermission,
|
|
355
|
-
initializeCountriesAndStates
|
|
354
|
+
initializeCountriesAndStates,
|
|
355
|
+
requestBrowserLocation,
|
|
356
|
+
// NEW
|
|
357
|
+
openLocationModal
|
|
358
|
+
// NEW
|
|
356
359
|
};
|
|
357
360
|
}
|