From 6950bb7176b0fdc020dc78713a53f43084aa2c91 Mon Sep 17 00:00:00 2001 From: Laurian-Dufrechou Date: Sat, 20 May 2023 15:11:45 +0200 Subject: [PATCH 1/3] fix(bg color profile): bg color profile --- src/pages/profile.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx index 4f4be58..f017351 100644 --- a/src/pages/profile.tsx +++ b/src/pages/profile.tsx @@ -162,7 +162,7 @@ export default function UserProfile() { }; return ( - + From 36182eb47be2393b7813b9cdda77fe2e36d60250 Mon Sep 17 00:00:00 2001 From: Laurian-Dufrechou Date: Sat, 20 May 2023 15:29:17 +0200 Subject: [PATCH 2/3] feat(Distance bar search): Distance in preference is used in api bar --- src/components/layout/map/MapComponent.tsx | 1 + .../layout/profile/CustomSlider.tsx | 75 +++++++++++-------- src/pages/map.tsx | 12 ++- src/pages/profile.tsx | 14 ++-- 4 files changed, 62 insertions(+), 40 deletions(-) diff --git a/src/components/layout/map/MapComponent.tsx b/src/components/layout/map/MapComponent.tsx index 2e2334b..7e14f7a 100644 --- a/src/components/layout/map/MapComponent.tsx +++ b/src/components/layout/map/MapComponent.tsx @@ -41,6 +41,7 @@ export default function MapComponent(props: any) { ) : ( >; name: string; -} & Omit; +} & Omit; export default function CustomSlider(props: CustomSliderProps) { const { @@ -34,31 +34,46 @@ export default function CustomSlider(props: CustomSliderProps) { } = props; return ( - <> - {label} - ( - { - setSliderDistanceValue(v); - onChange(v); - }} - onMouseEnter={() => setShowTooltipDistance(true)} - onMouseLeave={() => setShowTooltipDistance(false)}> - - - - - - - - - - )}/> - + <> + + {label} + + ( + { + setSliderDistanceValue(v); + onChange(v); + }} + onMouseEnter={() => setShowTooltipDistance(true)} + onMouseLeave={() => setShowTooltipDistance(false)} + > + + + + + + + + + + )} + /> + ); } diff --git a/src/pages/map.tsx b/src/pages/map.tsx index 5a5e4e0..b26156b 100644 --- a/src/pages/map.tsx +++ b/src/pages/map.tsx @@ -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"); diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx index f017351..fa097bc 100644 --- a/src/pages/profile.tsx +++ b/src/pages/profile.tsx @@ -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(0); + const [showTooltipDistance, setShowTooltipDistance] = useState(false); + const [sliderDistanceValue, setSliderDistanceValue] = useState(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} /> - {/* */} + />
From 9f9595f94fe2c189e11bcff5e90a897fb69774a0 Mon Sep 17 00:00:00 2001 From: Laurian-Dufrechou Date: Sat, 20 May 2023 15:49:22 +0200 Subject: [PATCH 3/3] fix(position api bar): position api bar --- src/components/layout/map/MapComponent.tsx | 3 +-- src/pages/map.tsx | 13 ++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/components/layout/map/MapComponent.tsx b/src/components/layout/map/MapComponent.tsx index 7e14f7a..85ffe47 100644 --- a/src/components/layout/map/MapComponent.tsx +++ b/src/components/layout/map/MapComponent.tsx @@ -41,9 +41,8 @@ export default function MapComponent(props: any) { ) : ( diff --git a/src/pages/map.tsx b/src/pages/map.tsx index b26156b..7e82cb2 100644 --- a/src/pages/map.tsx +++ b/src/pages/map.tsx @@ -56,7 +56,7 @@ export default function Map() { } = useQuery({ queryKey: ["listBars"], refetchOnWindowFocus: false, - enabled: Boolean(loggedUser), + enabled: Boolean(loggedUser) && loggedUser.location.length > 0, queryFn: async () => { ///Utiliser api de noratim @@ -65,12 +65,11 @@ export default function Map() { ); 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(); + if (location[0] === null || location[1] === null) { + const co = loggedUser.location.split(","); + coordinates = co[1].toString() + " " + co[0].toString(); + } else + coordinates = location[1].toString() + " " + location[0].toString(); urlBars.searchParams.append( "where",