Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f4c0c5bf15 | |||
| a4b85e9c85 | |||
| 6dab5412c7 | |||
| 4949bd28aa |
@@ -1,5 +1,6 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import DarkModeContext from "../Contexts/DarkModeContext";
|
||||
import axios from 'axios'
|
||||
|
||||
function Default({ children }) {
|
||||
// dark mode setup
|
||||
@@ -12,6 +13,32 @@ function Default({ children }) {
|
||||
const queryParams = new URLSearchParams(location?.search);
|
||||
const country = queryParams.get("cnt")?.toUpperCase();
|
||||
|
||||
const getLocation = () => {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(data) => {
|
||||
const pos = data.coords;
|
||||
const position = {
|
||||
lat: pos.latitude,
|
||||
long: pos.longitude,
|
||||
};
|
||||
axios.get(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${position.lat}&lon=${position.long}&zoom=18&addressdetails=1`).then(res =>{
|
||||
localStorage.setItem("myloc", res?.data?.address?.country);
|
||||
// console.log('LOC', res?.data?.address?.country)
|
||||
// localStorage.setItem("myloc", JSON.stringify(position));
|
||||
}).catch(err => {
|
||||
console.log('ERR', err)
|
||||
})
|
||||
},
|
||||
(err) => {
|
||||
localStorage.setItem("myloc", JSON.stringify('not supported'));
|
||||
}
|
||||
);
|
||||
} else {
|
||||
localStorage.setItem("myloc", JSON.stringify('not supported'));
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
||||
setTheme("dark");
|
||||
@@ -39,6 +66,10 @@ function Default({ children }) {
|
||||
}
|
||||
},[countryMode])
|
||||
|
||||
useEffect(()=>{
|
||||
getLocation()
|
||||
},[])
|
||||
|
||||
return (
|
||||
<>
|
||||
<DarkModeContext.Provider value={{ theme, handleThemeSwitch, countryMode }}>
|
||||
|
||||
@@ -32,7 +32,7 @@ class usersService {
|
||||
}
|
||||
|
||||
blogData() {
|
||||
return this.getAuxEnd("/blogdata", null);
|
||||
return this.getAuxEnd("/blogdata", {});
|
||||
}
|
||||
|
||||
CompleteOauthLogin(reqData) {
|
||||
@@ -130,7 +130,7 @@ class usersService {
|
||||
}
|
||||
getApiGate() {
|
||||
// localStorage.setItem("session_token", ``);
|
||||
return this.postAuxEnd("/apigate", null);
|
||||
return this.postAuxEnd("/apigate", {});
|
||||
}
|
||||
|
||||
getLoadProfile() {
|
||||
@@ -141,7 +141,7 @@ class usersService {
|
||||
page: 0,
|
||||
limit: 100,
|
||||
};
|
||||
return this.postAuxEnd("/loadprofile", null);
|
||||
return this.postAuxEnd("/loadprofile", {});
|
||||
}
|
||||
|
||||
getUploadedList() {
|
||||
@@ -791,7 +791,7 @@ class usersService {
|
||||
|
||||
// Country Data {GET}
|
||||
getSignupCountryData() {
|
||||
return this.postAuxEnd("/signupcountry", null);
|
||||
return this.postAuxEnd("/signupcountry", {});
|
||||
}
|
||||
|
||||
// END POINT TO GET BANK NAME
|
||||
@@ -1529,7 +1529,7 @@ class usersService {
|
||||
*/
|
||||
|
||||
getUserReminders() {
|
||||
return this.getAuxEnd("/reminders", null);
|
||||
return this.getAuxEnd("/reminders", {});
|
||||
}
|
||||
//---------------------------------------- -----
|
||||
//---------------------------------------- -----
|
||||
@@ -1588,6 +1588,9 @@ class usersService {
|
||||
// Axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*'; //,axiosConfig
|
||||
// Axios.defaults.withCredentials = true;
|
||||
//debugger;
|
||||
if(localStorage && localStorage.getItem('myloc')){
|
||||
reqData.loc = localStorage.getItem('myloc')
|
||||
}
|
||||
return Axios.post(endPoint, reqData)
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
|
||||
Reference in New Issue
Block a user