mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-07-09 15:08:06 +00:00
fix(BUG Carte): error first load map
This commit is contained in:
@@ -7,7 +7,7 @@ import "@christopherpickering/react-leaflet-markercluster/dist/styles.min.css";
|
|||||||
import MarkerBar from "./MarkerBar";
|
import MarkerBar from "./MarkerBar";
|
||||||
import "leaflet/dist/leaflet.css";
|
import "leaflet/dist/leaflet.css";
|
||||||
|
|
||||||
export default function MapComponent(props) {
|
export default function MapComponent(props: any) {
|
||||||
const { location, listBars } = props;
|
const { location, listBars } = props;
|
||||||
|
|
||||||
const toast = useToast({ position: "top" });
|
const toast = useToast({ position: "top" });
|
||||||
|
|||||||
+2
-9
@@ -18,13 +18,6 @@ export default function Map() {
|
|||||||
const idSaveToast = "saved_location";
|
const idSaveToast = "saved_location";
|
||||||
const { data: session, status } = useSession();
|
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 {
|
const {
|
||||||
isLoading,
|
isLoading,
|
||||||
isError,
|
isError,
|
||||||
@@ -79,7 +72,6 @@ export default function Map() {
|
|||||||
|
|
||||||
const userSetLocation = useMutation({
|
const userSetLocation = useMutation({
|
||||||
mutationKey: "userSetLocation",
|
mutationKey: "userSetLocation",
|
||||||
enabled: !isLoading && !loggedUser,
|
|
||||||
mutationFn: async (position: string) => {
|
mutationFn: async (position: string) => {
|
||||||
const pos = {
|
const pos = {
|
||||||
location: position,
|
location: position,
|
||||||
@@ -112,11 +104,12 @@ export default function Map() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
navigator.geolocation.getCurrentPosition((position) => {
|
navigator.geolocation.getCurrentPosition((position) => {
|
||||||
setLocation([position.coords.latitude, position.coords.longitude]);
|
setLocation([position.coords.latitude, position.coords.longitude]);
|
||||||
|
if (!loggedUser) return;
|
||||||
userSetLocation.mutate(
|
userSetLocation.mutate(
|
||||||
`${position.coords.latitude},${position.coords.longitude}`
|
`${position.coords.latitude},${position.coords.longitude}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}, []);
|
}, [loggedUser]);
|
||||||
|
|
||||||
const MapWithNoSSR = dynamic(
|
const MapWithNoSSR = dynamic(
|
||||||
() => import("../components/layout/map/MapComponent"),
|
() => import("../components/layout/map/MapComponent"),
|
||||||
|
|||||||
+17
-17
@@ -362,23 +362,6 @@ export default function UserProfile() {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
</Box>
|
</Box>
|
||||||
<Divider colorScheme={"purple"} />
|
<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 my={"1rem"}>
|
||||||
<Box>
|
<Box>
|
||||||
<FormLabel as={"legend"} htmlFor={"gender"}>
|
<FormLabel as={"legend"} htmlFor={"gender"}>
|
||||||
@@ -419,6 +402,23 @@ export default function UserProfile() {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Divider colorScheme={"purple"} />
|
<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 my={"1rem"}>
|
||||||
<Center>
|
<Center>
|
||||||
<Text as={"b"} fontSize={"1.5rem"} my={"1rem"}>
|
<Text as={"b"} fontSize={"1.5rem"} my={"1rem"}>
|
||||||
|
|||||||
Reference in New Issue
Block a user