Compare commits

..

4 Commits

Author SHA1 Message Date
victorAnumudu f4c0c5bf15 signup country bug fixed 2024-08-07 21:21:24 +01:00
ameye a4b85e9c85 Merge branch 'link-name-change' of WrenchBoard/Users-Wrench into master 2024-07-29 12:45:30 +00:00
ameye 6dab5412c7 Merge branch 'location-addition' of WrenchBoard/Users-Wrench into master 2024-07-29 12:45:22 +00:00
victorAnumudu 4949bd28aa added loc as a payload 2024-07-28 11:56:52 +01:00
2 changed files with 39 additions and 5 deletions
+31
View File
@@ -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 }}>
+8 -5
View File
@@ -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);