mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-07-09 23:18:07 +00:00
feat(Distance bar search): Distance in preference is used in api bar
This commit is contained in:
+9
-3
@@ -56,7 +56,7 @@ export default function Map() {
|
||||
} = useQuery({
|
||||
queryKey: ["listBars"],
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !isLoading && location[0] !== null,
|
||||
enabled: Boolean(loggedUser),
|
||||
queryFn: async () => {
|
||||
///Utiliser api de noratim
|
||||
|
||||
@@ -64,11 +64,17 @@ export default function Map() {
|
||||
"https://data.opendatasoft.com/api/v2/catalog/datasets/osm-fr-bars%40babel/exports/json?"
|
||||
);
|
||||
|
||||
const coordinates = location[1].toString() + " " + location[0].toString();
|
||||
let coordinates;
|
||||
if (location[0] === null || location[1] === null)
|
||||
coordinates =
|
||||
loggedUser.location[1].toString() +
|
||||
" " +
|
||||
loggedUser.location[0].toString();
|
||||
else coordinates = location[1].toString() + " " + location[0].toString();
|
||||
|
||||
urlBars.searchParams.append(
|
||||
"where",
|
||||
`distance(geo_point_2d,geom'POINT(${coordinates})',75km)`
|
||||
`distance(geo_point_2d,geom'POINT(${coordinates})',${loggedUser.distance}km)`
|
||||
);
|
||||
urlBars.searchParams.append("limit", "-1");
|
||||
urlBars.searchParams.append("offset", "0");
|
||||
|
||||
@@ -26,7 +26,7 @@ import CustomFalseEditable from "@/components/layout/profile/CustomFalseEditable
|
||||
import CustomEditableArea from "@/components/layout/profile/CustomEditableArea";
|
||||
import CustomRadioGender from "@/components/layout/profile/CustomRadioGender";
|
||||
import CustomRangeSlider from "@/components/layout/profile/CustomRangeSlider";
|
||||
// import CustomSlider from "@/components/layout/user_profile/CustomSlider";
|
||||
import CustomSlider from "@/components/layout/profile/CustomSlider";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
@@ -42,8 +42,8 @@ export default function UserProfile() {
|
||||
|
||||
const [showTooltipAge, setShowTooltipAge] = useState(false);
|
||||
const [sliderAgeValue, setSliderAgeValue] = useState([[] as number[]]);
|
||||
// const [showTooltipDistance, setShowTooltipDistance] = useState(false);
|
||||
// const [sliderDistanceValue, setSliderDistanceValue] = useState<number>(0);
|
||||
const [showTooltipDistance, setShowTooltipDistance] = useState(false);
|
||||
const [sliderDistanceValue, setSliderDistanceValue] = useState<number>(0);
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
@@ -76,7 +76,7 @@ export default function UserProfile() {
|
||||
const { user } = session as unknown as Session;
|
||||
|
||||
setSliderAgeValue([user.ageMin, user.ageMax]);
|
||||
// setSliderDistanceValue(user.distance);
|
||||
setSliderDistanceValue(user.distance);
|
||||
|
||||
return fetch(`/api/users/${user.id}`)
|
||||
.then((res) => res.json())
|
||||
@@ -332,16 +332,16 @@ export default function UserProfile() {
|
||||
sliderAgeValue={sliderAgeValue}
|
||||
/>
|
||||
</Box>
|
||||
{/* <CustomSlider
|
||||
<CustomSlider
|
||||
control={control}
|
||||
label={"Distance :"}
|
||||
label={"Distance des bars :"}
|
||||
name={"distance"}
|
||||
defaultValue={userData.distance}
|
||||
setSliderDistanceValue={setSliderDistanceValue}
|
||||
setShowTooltipDistance={setShowTooltipDistance}
|
||||
showTooltipDistance={showTooltipDistance}
|
||||
sliderDistanceValue={sliderDistanceValue}
|
||||
/> */}
|
||||
/>
|
||||
</Box>
|
||||
<Divider colorScheme={"purple"} />
|
||||
<Center position={"sticky"} bottom={0} gap={"1rem"} my={"1rem"}>
|
||||
|
||||
Reference in New Issue
Block a user