mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-05-13 17:21:53 +00:00
fix(error merge): fixed error induced with wrong merge
This commit is contained in:
+14
-26
@@ -17,7 +17,11 @@ const MapWithNoSSR = dynamic(
|
||||
);
|
||||
|
||||
export default function Map() {
|
||||
const [location, setLocation] = useState<number[]>([]);
|
||||
const [location, setLocation] = useState([
|
||||
null as unknown as number,
|
||||
null as unknown as number,
|
||||
]);
|
||||
|
||||
const [geolocationError, setGeolocationError] = useState(false);
|
||||
const { data: session, status } = useSession();
|
||||
const [listBars, setListBars] = useState({} as unknown as any);
|
||||
@@ -112,19 +116,10 @@ export default function Map() {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!session?.user) return;
|
||||
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(position: GeolocationPosition) => {
|
||||
setLocation([position.coords.latitude, position.coords.longitude]);
|
||||
setGeolocationError(false);
|
||||
},
|
||||
() => setGeolocationError(true),
|
||||
{
|
||||
enableHighAccuracy: true,
|
||||
timeout: 5000,
|
||||
maximumAge: 0,
|
||||
},
|
||||
successPosition,
|
||||
errorPosition,
|
||||
geolocationOptions
|
||||
);
|
||||
}, [loggedUser]);
|
||||
|
||||
@@ -139,22 +134,15 @@ export default function Map() {
|
||||
setLocation([position.coords.latitude, position.coords.longitude]);
|
||||
setGeolocationError(false);
|
||||
|
||||
for (const [key, val] of Object.entries(params)) {
|
||||
urlBars.searchParams.append(key, val);
|
||||
if (!loggedUser) return;
|
||||
userSetLocation.mutate(
|
||||
`${position.coords.latitude},${position.coords.longitude}`
|
||||
);
|
||||
}
|
||||
|
||||
fetch(urlBars)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const filteredBars = data.filter((bar: any) => bar.name !== null);
|
||||
setListBars(filteredBars);
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
function errorPosition(error: GeolocationPositionError) {
|
||||
setGeolocationError(true);
|
||||
}
|
||||
}, [session?.user]);
|
||||
|
||||
if (status === 'loading') return <LoadingPage/>;
|
||||
const {user} = session as unknown as Session;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user