fix(BUG Carte): error first load map

This commit is contained in:
Laurian-Dufrechou
2023-04-28 18:31:34 +02:00
parent 57f97b8e22
commit 6da8d263f6
3 changed files with 20 additions and 27 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ import "@christopherpickering/react-leaflet-markercluster/dist/styles.min.css";
import MarkerBar from "./MarkerBar";
import "leaflet/dist/leaflet.css";
export default function MapComponent(props) {
export default function MapComponent(props: any) {
const { location, listBars } = props;
const toast = useToast({ position: "top" });
+2 -9
View File
@@ -18,13 +18,6 @@ export default function Map() {
const idSaveToast = "saved_location";
const { data: session, status } = useSession();
//faire un useQuery pour récupérer les bars et restaurants et en meme temps regarder si l'user a une location
//Si oui, faire une mutation avec navigator.geolocation.getCurrentPosition pour mettre à jour la location de l'user dans la bdd
// cet url : https://data.opendatasoft.com/api/v2/catalog/datasets/osm-fr-bars%40babel/records?limit=100&offset=0&lang=fr&timezone=UTC
// ou : https://data.opendatasoft.com/api/v2/catalog/datasets/osm-fr-bars%40babel/exports/json?limit=-1&offset=0&lang=fr&timezone=UTC MAIS RENVOI UN file
const {
isLoading,
isError,
@@ -79,7 +72,6 @@ export default function Map() {
const userSetLocation = useMutation({
mutationKey: "userSetLocation",
enabled: !isLoading && !loggedUser,
mutationFn: async (position: string) => {
const pos = {
location: position,
@@ -112,11 +104,12 @@ export default function Map() {
useEffect(() => {
navigator.geolocation.getCurrentPosition((position) => {
setLocation([position.coords.latitude, position.coords.longitude]);
if (!loggedUser) return;
userSetLocation.mutate(
`${position.coords.latitude},${position.coords.longitude}`
);
});
}, []);
}, [loggedUser]);
const MapWithNoSSR = dynamic(
() => import("../components/layout/map/MapComponent"),
+17 -17
View File
@@ -362,23 +362,6 @@ export default function UserProfile() {
</FormControl>
</Box>
<Divider colorScheme={"purple"} />
<Box my={"1rem"}>
<Box>
<FormLabel as={"legend"} htmlFor={"passion"}>
Centre d'intéret :
</FormLabel>
<VStack gap={"1rem"} align="start">
<ProfileTagList
userPassions={
userData.PassionID !== undefined ? userData.PassionID : []
}
passions={passions}
/>
<ModalChoosePassion user={userData} passions={passions} />
</VStack>
</Box>
</Box>
<Divider colorScheme={"purple"} />
<Box my={"1rem"}>
<Box>
<FormLabel as={"legend"} htmlFor={"gender"}>
@@ -419,6 +402,23 @@ export default function UserProfile() {
</Box>
</Box>
<Divider colorScheme={"purple"} />
<Box my={"1rem"}>
<Box>
<FormLabel as={"legend"} htmlFor={"passion"}>
Centre d'intéret :
</FormLabel>
<VStack gap={"1rem"} align="start">
<ProfileTagList
userPassions={
userData.PassionID !== undefined ? userData.PassionID : []
}
passions={passions}
/>
<ModalChoosePassion user={userData} passions={passions} />
</VStack>
</Box>
</Box>
<Divider colorScheme={"purple"} />
<Box my={"1rem"}>
<Center>
<Text as={"b"} fontSize={"1.5rem"} my={"1rem"}>