From 4f5620f632b112c5f4918a7b1c3e2178cffaa152 Mon Sep 17 00:00:00 2001 From: Zhi Date: Sun, 10 Dec 2023 14:06:03 +0800 Subject: [PATCH] Feature - Line color update, UI fixes - Scrollable cards --- client/components/map/FacilityCard.tsx | 7 ++-- client/components/map/RouteCard.tsx | 22 ++++++++----- client/public/locationButton.png | Bin 0 -> 1093 bytes client/spa-pages/components/MapPage.tsx | 42 +++++++++++++++++++++--- client/utils.ts | 2 ++ 5 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 client/public/locationButton.png diff --git a/client/components/map/FacilityCard.tsx b/client/components/map/FacilityCard.tsx index 11dd60d..e71d3ce 100644 --- a/client/components/map/FacilityCard.tsx +++ b/client/components/map/FacilityCard.tsx @@ -48,6 +48,7 @@ export const FacilityCard = ({ return ( )} - { - console.log(items); - console.log(route); const { getFacility, getItemCategory } = useSheetyData(); const [isExpanded, setIsExpanded] = useState(false); const [translateY, setTranslateY] = useState(50); @@ -36,6 +34,7 @@ export const RouteCard = ({ return ( )} - - + blue circle blue line - + ); })} + ); diff --git a/client/public/locationButton.png b/client/public/locationButton.png new file mode 100644 index 0000000000000000000000000000000000000000..32d99ea570c623b5170d1d1e1186f608d8e7c58f GIT binary patch literal 1093 zcmV-L1iJf)P)zSIuA%XhO0<5AaP*oKQtd|ap#1-8g9>(G7 zssL}cwqk#74$db}pkKZWE2PA`kzv4<`uZ@W5~`{k`EMGT&!6M`*RRlXa}kf?f@R39 zjt&8`UAcmDFJ2&ps>tX2v$OCoEMTv{Uq0vSIi;nr-M$U8G7Zb1+nt@zoK9qa|Begq z-u?AHuJ~3%1H2Oxa&K-$1yXL^f*F~D-RbSca%H7_`L)_w*zeqt>+Z=(xQ2!hbh}}@ zdNo{W)^=kf+&w*Fh1|M2DCy~lRico}Mg7am_+4HuO~y%}X&O`-8l7MK z_6=EIzQ}W{g@rgGYdAlBg7f1?#HyI1OLCMz*_X!D|0*hicY0bNbzO(XgJJ3DYHPzD zRg{(WF ztsz#ODrYyTi3>*mMvY(pLGT56< zO|mgz$er$Pc*e%Wx2#n1t|t;Obgo99U%xK*D_*YvW>7UX0_4gXpPi&rd6whH@$ezi z9z1}9hBV2{jC__!-i>T5HNv;Xus?eyQ57Jcaz$0P(bK0$xpxmbjnl?h%njzGrIRb{ z9Un)4EWo*WF)uG1Rng$QFGzj;TAuX{4j!*|j~|=L*_dJ3b6nvdP3Klk&GA3*>J=_f zhH{)mR@6q_?uX#to`Lnn31VPf&IEtP=KJvgL9uhBa=ej5Kl8-XCEpK zhg@S&S6LZ?6j=%O2Q^eXA1TYQY>%YR0~sB00000 LNkvXXu0mjfI { recyclingLocationResults?.route.complete ? "green" : "blue", ); const [showRoute, setShowRoute] = useState(false); + + // Trigger changes in lazy loaded CustomPolyline component + const [key, setKey] = useState(0); + // Filters const { isOpen: isFilterOpen, onOpen: onFilterOpen, onClose: onFilterClose } = useDisclosure(); const [range, setRange] = useState(MAX_DISTANCE_KM * 10); @@ -176,6 +189,7 @@ const MapInner = ({ setPage }: Props) => { // Handle the changing of location in this page itself const handleChangedLocation = (itemEntry: (TItemSelection | TEmptyItem)[]) => { + console.log(itemEntry); const locations = getNearbyFacilities( itemEntry as TItemSelection[], address, @@ -184,6 +198,8 @@ const MapInner = ({ setPage }: Props) => { MAX_DISTANCE_KM, ); locations.route.complete ? setLineColor("green") : setLineColor("blue"); + // Trigger changes in lazy loaded CustomPolyline component + setKey((prevKey) => prevKey + 1); setLineCoords(locations.route.coords); // Set map position @@ -293,6 +309,9 @@ const MapInner = ({ setPage }: Props) => { dist, ); locations.route.complete ? setLineColor("green") : setLineColor("blue"); + // Trigger changes in lazy loaded CustomPolyline component + setKey((prevKey) => prevKey + 1); + setLineCoords(locations.route.coords); setRange(val); setRecyclingLocationResults(locations); @@ -363,7 +382,11 @@ const MapInner = ({ setPage }: Props) => { /> {/* Show Route */} - {showRoute && } + {showRoute ? ( + + ) : ( + <> + )} @@ -386,7 +409,7 @@ const MapInner = ({ setPage }: Props) => { facCardDistance={facCardDistance} /> )} - {showRoute && !facCardIsOpen && ( + {showRoute && !facCardIsOpen && recyclingLocationResults?.route && ( Show Route (beta) - + ); diff --git a/client/utils.ts b/client/utils.ts index 1fb72cd..46020d5 100644 --- a/client/utils.ts +++ b/client/utils.ts @@ -32,6 +32,7 @@ export const getNearbyFacilities = ( const res: Record = {}; const allFacilityIds: number[] = []; const userCats = usersCategories(items, getItemCategory); + console.log(userCats); const allFacilities: TStateFacilities[] = []; const distances = new Map(); const blueBinFacilities: TStateFacilities[] = []; @@ -109,6 +110,7 @@ export const getNearbyFacilities = ( }); const route = dijkstra(allFacilities, address, userCats); + console.log(route.complete); return { results: res, facilitiesList: allFacilityIds,