diff --git a/client/components/footer/StickyFooter.tsx b/client/components/footer/StickyFooter.tsx index 9387f83..24b86ab 100644 --- a/client/components/footer/StickyFooter.tsx +++ b/client/components/footer/StickyFooter.tsx @@ -30,7 +30,6 @@ export const StickyFooter = forwardRef(({ disabled, setPa MAX_DISTANCE_KM, ), ); - setPage(pageNumber); }; diff --git a/client/components/home/UserInput/Items.tsx b/client/components/home/UserInput/Items.tsx index c21a734..693dcd1 100644 --- a/client/components/home/UserInput/Items.tsx +++ b/client/components/home/UserInput/Items.tsx @@ -51,6 +51,7 @@ export const Items = () => { _item[type] = value as Methods; } else { _item[type] = value; + _item["method"] = undefined; } _items[index] = _item; setUserSelection(_items); @@ -107,7 +108,7 @@ export const Items = () => { placeholder="Method" color={item.method ? COLORS.Select.body : COLORS.Select.placeholder} iconColor={COLORS.Select.icon} - value={item.method} + value={item.method ? item.method : "Method"} onChange={(e: ChangeEvent) => { e.target.value && handleUpdateItem("method", index, e.target.value); }} diff --git a/client/components/home/UserInput/Location/index.tsx b/client/components/home/UserInput/Location/index.tsx index c608074..adbc7f0 100644 --- a/client/components/home/UserInput/Location/index.tsx +++ b/client/components/home/UserInput/Location/index.tsx @@ -1,4 +1,4 @@ -import { Box, Flex, Text } from "@chakra-ui/react"; +import { Box, Text } from "@chakra-ui/react"; import { fetchAddresses } from "api/onemap"; import { useUserInputs } from "hooks/useUserSelection"; import debounce from "lodash/debounce"; @@ -32,7 +32,7 @@ export const Location = ({ handleBlur, showText, containerStyle = {} }: Location lat: result.LATITUDE, long: result.LONGITUDE, }, - } as AddressOption), + }) as AddressOption, ), ), ); diff --git a/client/components/home/UserInput/index.tsx b/client/components/home/UserInput/index.tsx index 9f51f80..5ed7501 100644 --- a/client/components/home/UserInput/index.tsx +++ b/client/components/home/UserInput/index.tsx @@ -11,9 +11,8 @@ type Props = { export const UserInput = ({ scrollableContainerRef, setReadyToSubmit }: Props) => { const { items, address } = useUserInputs(); - useEffect(() => { - setReadyToSubmit(!!address && validateSelections(items)); + setReadyToSubmit(!!address.value && validateSelections(items)); }, [address, items, setReadyToSubmit]); useEffect(() => { diff --git a/client/components/instructions/InstructionsAccordion/DisplayAccordion.tsx b/client/components/instructions/InstructionsAccordion/DisplayAccordion.tsx index 5c2e7fe..9c6a638 100644 --- a/client/components/instructions/InstructionsAccordion/DisplayAccordion.tsx +++ b/client/components/instructions/InstructionsAccordion/DisplayAccordion.tsx @@ -55,7 +55,7 @@ const DisplayAccordion = ({ items, recyclable }: AccordionDisplayProps) => { onMouseLeave={() => handleAccordionHover(index, false, isExpanded)} style={{ boxShadow: - index === 0 && index !== lastIndex + index !== lastIndex ? "0px -5px 6px -6px rgba(0, 0, 0, 0.25), -5px 0px 6px -6px rgba(0, 0, 0, 0.25), 5px 0px 6px -6px rgba(0, 0, 0, 0.25)" : "1px 2px 6px 0px rgb(0,0,0, 0.25)", }} @@ -65,8 +65,8 @@ const DisplayAccordion = ({ items, recyclable }: AccordionDisplayProps) => { {`Icon { - const [currentIndex, setCurrentIndex] = useState(0); - - const handlePrevClick = () => { - setCurrentIndex((prevIndex) => (prevIndex === 0 ? items.length - 1 : prevIndex - 1)); - }; - - const handleNextClick = () => { - setCurrentIndex((prevIndex) => (prevIndex === items.length - 1 ? 0 : prevIndex + 1)); - }; - return ( >; }; diff --git a/client/components/map/FacilityCard.tsx b/client/components/map/FacilityCard.tsx index 2892ad2..6b1f954 100644 --- a/client/components/map/FacilityCard.tsx +++ b/client/components/map/FacilityCard.tsx @@ -10,6 +10,7 @@ import { useSheetyData } from "hooks/useSheetyData"; import { CheckIcon } from "@chakra-ui/icons"; import { categoriesProcessor } from "./utils"; import { Methods } from "api/sheety/enums"; +import { useUserInputs } from "hooks/useUserSelection"; export const FacilityCard = ({ items, facCardDetails, @@ -20,7 +21,7 @@ export const FacilityCard = ({ facCardDistance: number; }) => { const { getItemCategory } = useSheetyData(); - + const { address } = useUserInputs(); const [isExpanded, setIsExpanded] = useState(false); const [translateY, setTranslateY] = useState(50); const handleMovement = () => { @@ -102,19 +103,23 @@ export const FacilityCard = ({ {/* Address:{" "} */} {facCardDetails.address} - + + diff --git a/client/components/map/FilterPanel.tsx b/client/components/map/FilterPanel.tsx index ec84416..0872a12 100644 --- a/client/components/map/FilterPanel.tsx +++ b/client/components/map/FilterPanel.tsx @@ -17,14 +17,11 @@ import { CheckboxProps, useCheckboxGroup, Spacer, - useRadio, - UseRadioProps, - useRadioGroup, } from "@chakra-ui/react"; import { COLORS } from "theme"; import { TItemSelection, TEmptyItem } from "app-context/SheetyContext/types"; import { OptionType } from "spa-pages"; -import React, { ChangeEvent, PropsWithChildren } from "react"; +import React, { ChangeEvent } from "react"; import { Methods } from "api/sheety/enums"; import { useSheetyData } from "hooks/useSheetyData"; @@ -185,43 +182,6 @@ const ChipCheckbox = (props: CheckboxProps) => { ); }; -const ChipRadioGroup = ({ items }: { items: Array }) => { - const { getRootProps, getRadioProps } = useRadioGroup({ - name: "sortBy", - defaultValue: "Nearest", - }); - - const group = getRootProps(); - - return ( - - {items.map((value) => { - const radio = getRadioProps({ value }); - return ( - - {value} - - ); - })} - - ); -}; - -const ChipRadio = (props: PropsWithChildren) => { - const { getInputProps, getRadioProps, state } = useRadio(props); - - const input = getInputProps(); - - return ( - - - - {props.children} - - - ); -}; - export const Chip = ({ value, children, @@ -231,7 +191,8 @@ export const Chip = ({ const selectedColor = darkBackground ? "teal.500" : "teal.50"; const selectedTextColor = darkBackground ? "white" : "black"; const { getItemCategory } = useSheetyData(); - const category = getItemCategory(value as string); + const category = getItemCategory(value as string) as string; + // To prevent an error that is triggered when I use the Show Route function return ( {category && ( {`${category} diff --git a/client/components/map/Marker/ClusterGroup.tsx b/client/components/map/Marker/ClusterGroup.tsx index 9a6af0b..366f55d 100644 --- a/client/components/map/Marker/ClusterGroup.tsx +++ b/client/components/map/Marker/ClusterGroup.tsx @@ -53,7 +53,7 @@ const CreateMarkerClusterGroup = ( ), }), diff --git a/client/components/map/Marker/MarkerIconWrapper.tsx b/client/components/map/Marker/MarkerIconWrapper.tsx index 043d851..940e7af 100644 --- a/client/components/map/Marker/MarkerIconWrapper.tsx +++ b/client/components/map/Marker/MarkerIconWrapper.tsx @@ -9,7 +9,7 @@ export interface CustomMarkerProps { position: LatLngExpression; icon?: React.ComponentType; // Update the type here color: string; - label?: string; + label?: number; category: string; isSelected?: boolean; } @@ -30,18 +30,32 @@ const MarkerIconWrapper = ({ ))} - {label && {label}} + {label && ( + + {label} + + )} {category && ( <> Circle behind category icon {`${category} diff --git a/client/components/map/Marker/icons/ClusterIcon.tsx b/client/components/map/Marker/icons/ClusterIcon.tsx index fd6548d..0b26005 100644 --- a/client/components/map/Marker/icons/ClusterIcon.tsx +++ b/client/components/map/Marker/icons/ClusterIcon.tsx @@ -1,7 +1,7 @@ import { Icon } from "@chakra-ui/react"; const ClusterIcon = (props: any) => ( - + ( - + diff --git a/client/components/map/RouteCard.tsx b/client/components/map/RouteCard.tsx index a744d1f..82e60ca 100644 --- a/client/components/map/RouteCard.tsx +++ b/client/components/map/RouteCard.tsx @@ -12,11 +12,9 @@ import Link from "next/link"; export const RouteCard = ({ items, route, - results, }: { items: (TItemSelection | TEmptyItem)[]; route: RecyclingLocationResults["route"]; - results: RecyclingLocationResults["results"]; }) => { const { getFacility, getItemCategory } = useSheetyData(); const [isExpanded, setIsExpanded] = useState(false); @@ -70,8 +68,14 @@ export const RouteCard = ({ {/* Header */} - {route.path.length - 1} stop - {route.path.length > 2 && "s"} + {route.path.length > 0 ? ( + <> + {route.path.length - 1} stop + {route.path.length > 2 && "s"} + + ) : ( + <>No facilities found. + )} Total {(calculateSum(route.distanceBtwFacilities) * 1000).toFixed(0)}m diff --git a/client/components/pickup/OrgCard.tsx b/client/components/pickup/OrgCard.tsx index 69fd9b7..56c789b 100644 --- a/client/components/pickup/OrgCard.tsx +++ b/client/components/pickup/OrgCard.tsx @@ -9,7 +9,6 @@ import { theme, Divider, } from "@chakra-ui/react"; -import Link from "next/link"; import { Card, CardBody } from "@chakra-ui/card"; import { TSheetyPickupDetails } from "api/sheety/types"; diff --git a/client/components/pickup/OrgLabel.tsx b/client/components/pickup/OrgLabel.tsx index d83ef37..bb03122 100644 --- a/client/components/pickup/OrgLabel.tsx +++ b/client/components/pickup/OrgLabel.tsx @@ -10,7 +10,7 @@ type Props = { const OrgLabel = (props: Props) => { return ( - + {props.title} diff --git a/client/components/pickup/PickupCarousel.tsx b/client/components/pickup/PickupCarousel.tsx index ea4c3d9..aaaf819 100644 --- a/client/components/pickup/PickupCarousel.tsx +++ b/client/components/pickup/PickupCarousel.tsx @@ -97,7 +97,7 @@ const PickupCarousel = ({ ) : ( - {(minDist * 1000).toFixed(0)}m + {minDist > 10000 ? (minDist * 1000).toFixed(0) + "m" : "-"} )}{" "} diff --git a/client/components/pickup/filterPopover.tsx b/client/components/pickup/filterPopover.tsx index f5a7e04..fc0dc78 100644 --- a/client/components/pickup/filterPopover.tsx +++ b/client/components/pickup/filterPopover.tsx @@ -63,7 +63,7 @@ const FilterButton = ({ maxWidth="calc(768px - 32px)" top={`${modalTop}px`} marginBottom={0} - marginRight={3} + width={"90%"} > { const [windowDimensions, setWindowDimensions] = useState<{ @@ -9,13 +8,26 @@ export const useWindowDimensions = () => { width: 0, height: 0, }); - const updateSize = () => - setWindowDimensions({ - width: window.innerWidth, - height: window.innerHeight, - }); - useEffect(() => (window.onresize = updateSize), []); + useLayoutEffect(() => { + const updateSize = () => { + setWindowDimensions({ + width: window.innerWidth, + height: window.innerHeight, + }); + }; + + // Initial update after the first render + updateSize(); + + // Add the resize event listener + window.addEventListener("resize", updateSize); + + // Clean up the event listener on component unmount + return () => { + window.removeEventListener("resize", updateSize); + }; + }, []); // Empty dependency array to run the effect only once after the first render return windowDimensions; }; diff --git a/client/public/Marker.css b/client/public/Marker.css index 233938b..9db66c1 100644 --- a/client/public/Marker.css +++ b/client/public/Marker.css @@ -29,11 +29,10 @@ } .marker-text { - font-size: 17px; + font-size: 15px; font-weight: 700; position: absolute; - right: 14px; - top: 6px; + top: 11px; background-clip: text; color: transparent; background-image: linear-gradient(90deg, #2b6cb0 0%, #2c5282 100%); diff --git a/client/public/icons/baby_children_items.png b/client/public/icons/baby_children_items.png deleted file mode 100644 index c1e71fd..0000000 Binary files a/client/public/icons/baby_children_items.png and /dev/null differ diff --git a/client/public/icons/bags_and_accessories.png b/client/public/icons/bags_and_accessories.png deleted file mode 100644 index eb91975..0000000 Binary files a/client/public/icons/bags_and_accessories.png and /dev/null differ diff --git a/client/public/icons/BABY_CHILDREN_ITEMS.png b/client/public/icons/blackicons/BABY_CHILDREN_ITEMS.png similarity index 100% rename from client/public/icons/BABY_CHILDREN_ITEMS.png rename to client/public/icons/blackicons/BABY_CHILDREN_ITEMS.png diff --git a/client/public/icons/BAGS_AND_ACCESSORIES.png b/client/public/icons/blackicons/BAGS_AND_ACCESSORIES.png similarity index 100% rename from client/public/icons/BAGS_AND_ACCESSORIES.png rename to client/public/icons/blackicons/BAGS_AND_ACCESSORIES.png diff --git a/client/public/icons/BOOKS.png b/client/public/icons/blackicons/BOOKS.png similarity index 100% rename from client/public/icons/BOOKS.png rename to client/public/icons/blackicons/BOOKS.png diff --git a/client/public/icons/CLOTHING.png b/client/public/icons/blackicons/CLOTHING.png similarity index 100% rename from client/public/icons/CLOTHING.png rename to client/public/icons/blackicons/CLOTHING.png diff --git a/client/public/icons/contact_lens.png b/client/public/icons/blackicons/CONTACT_LENS.png similarity index 100% rename from client/public/icons/contact_lens.png rename to client/public/icons/blackicons/CONTACT_LENS.png diff --git a/client/public/icons/CONTENT_CONTAINER.png b/client/public/icons/blackicons/CONTENT_CONTAINER.png similarity index 100% rename from client/public/icons/CONTENT_CONTAINER.png rename to client/public/icons/blackicons/CONTENT_CONTAINER.png diff --git a/client/public/icons/FOOD.png b/client/public/icons/blackicons/FOOD.png similarity index 100% rename from client/public/icons/FOOD.png rename to client/public/icons/blackicons/FOOD.png diff --git a/client/public/icons/FOOD_DRINK_CONTAINER.png b/client/public/icons/blackicons/FOOD_DRINK_CONTAINER.png similarity index 100% rename from client/public/icons/FOOD_DRINK_CONTAINER.png rename to client/public/icons/blackicons/FOOD_DRINK_CONTAINER.png diff --git a/client/public/icons/FURNITURE.png b/client/public/icons/blackicons/FURNITURE.png similarity index 100% rename from client/public/icons/FURNITURE.png rename to client/public/icons/blackicons/FURNITURE.png diff --git a/client/public/icons/GENERAL_WASTE.png b/client/public/icons/blackicons/GENERAL_WASTE.png similarity index 100% rename from client/public/icons/GENERAL_WASTE.png rename to client/public/icons/blackicons/GENERAL_WASTE.png diff --git a/client/public/icons/HOUSEHOLD_GOODS.png b/client/public/icons/blackicons/HOUSEHOLD_GOODS.png similarity index 100% rename from client/public/icons/HOUSEHOLD_GOODS.png rename to client/public/icons/blackicons/HOUSEHOLD_GOODS.png diff --git a/client/public/icons/ICT_EQUIPMENT.png b/client/public/icons/blackicons/ICT_EQUIPMENT.png similarity index 100% rename from client/public/icons/ICT_EQUIPMENT.png rename to client/public/icons/blackicons/ICT_EQUIPMENT.png diff --git a/client/public/icons/INKS_AND_TONER_CARTRIDGES.png b/client/public/icons/blackicons/INKS_AND_TONER_CARTRIDGES.png similarity index 100% rename from client/public/icons/INKS_AND_TONER_CARTRIDGES.png rename to client/public/icons/blackicons/INKS_AND_TONER_CARTRIDGES.png diff --git a/client/public/icons/LAMPS.png b/client/public/icons/blackicons/LAMPS.png similarity index 100% rename from client/public/icons/LAMPS.png rename to client/public/icons/blackicons/LAMPS.png diff --git a/client/public/icons/LARGE_HOUSEHOLD_APPLIANCES.png b/client/public/icons/blackicons/LARGE_HOUSEHOLD_APPLIANCES.png similarity index 100% rename from client/public/icons/LARGE_HOUSEHOLD_APPLIANCES.png rename to client/public/icons/blackicons/LARGE_HOUSEHOLD_APPLIANCES.png diff --git a/client/public/icons/nespresso.png b/client/public/icons/blackicons/NESPRESSO.png similarity index 100% rename from client/public/icons/nespresso.png rename to client/public/icons/blackicons/NESPRESSO.png diff --git a/client/public/icons/OTHER_ELECTRICAL_APPLIANCES.png b/client/public/icons/blackicons/OTHER_ELECTRICAL_APPLIANCES.png similarity index 100% rename from client/public/icons/OTHER_ELECTRICAL_APPLIANCES.png rename to client/public/icons/blackicons/OTHER_ELECTRICAL_APPLIANCES.png diff --git a/client/public/icons/PAPER_AND_CARDBOARD.png b/client/public/icons/blackicons/PAPER_AND_CARDBOARD.png similarity index 100% rename from client/public/icons/PAPER_AND_CARDBOARD.png rename to client/public/icons/blackicons/PAPER_AND_CARDBOARD.png diff --git a/client/public/icons/portable_batteries.png b/client/public/icons/blackicons/PORTABLE_BATTERIES.png similarity index 100% rename from client/public/icons/portable_batteries.png rename to client/public/icons/blackicons/PORTABLE_BATTERIES.png diff --git a/client/public/icons/RECYCLABLE.png b/client/public/icons/blackicons/RECYCLABLE.png similarity index 100% rename from client/public/icons/RECYCLABLE.png rename to client/public/icons/blackicons/RECYCLABLE.png diff --git a/client/public/icons/SHOES.png b/client/public/icons/blackicons/SHOES.png similarity index 100% rename from client/public/icons/SHOES.png rename to client/public/icons/blackicons/SHOES.png diff --git a/client/public/icons/STATIONERY.png b/client/public/icons/blackicons/STATIONERY.png similarity index 100% rename from client/public/icons/STATIONERY.png rename to client/public/icons/blackicons/STATIONERY.png diff --git a/client/public/icons/TOYS.png b/client/public/icons/blackicons/TOYS.png similarity index 100% rename from client/public/icons/TOYS.png rename to client/public/icons/blackicons/TOYS.png diff --git a/client/public/blueicons/baby_children_items.png b/client/public/icons/blueicons/BABY_CHILDREN_ITEMS.png similarity index 100% rename from client/public/blueicons/baby_children_items.png rename to client/public/icons/blueicons/BABY_CHILDREN_ITEMS.png diff --git a/client/public/blueicons/bags_and_accessories.png b/client/public/icons/blueicons/BAGS_AND_ACCESSORIES.png similarity index 100% rename from client/public/blueicons/bags_and_accessories.png rename to client/public/icons/blueicons/BAGS_AND_ACCESSORIES.png diff --git a/client/public/blueicons/BOOKS.png b/client/public/icons/blueicons/BOOKS.png similarity index 100% rename from client/public/blueicons/BOOKS.png rename to client/public/icons/blueicons/BOOKS.png diff --git a/client/public/blueicons/CLOTHING.png b/client/public/icons/blueicons/CLOTHING.png similarity index 100% rename from client/public/blueicons/CLOTHING.png rename to client/public/icons/blueicons/CLOTHING.png diff --git a/client/public/blueicons/contact_lens.png b/client/public/icons/blueicons/CONTACT_LENS.png similarity index 100% rename from client/public/blueicons/contact_lens.png rename to client/public/icons/blueicons/CONTACT_LENS.png diff --git a/client/public/blueicons/content_container.png b/client/public/icons/blueicons/CONTENT_CONTAINER.png similarity index 100% rename from client/public/blueicons/content_container.png rename to client/public/icons/blueicons/CONTENT_CONTAINER.png diff --git a/client/public/blueicons/FOOD.png b/client/public/icons/blueicons/FOOD.png similarity index 100% rename from client/public/blueicons/FOOD.png rename to client/public/icons/blueicons/FOOD.png diff --git a/client/public/blueicons/food_drink_container.png b/client/public/icons/blueicons/FOOD_DRINK_CONTAINER.png similarity index 100% rename from client/public/blueicons/food_drink_container.png rename to client/public/icons/blueicons/FOOD_DRINK_CONTAINER.png diff --git a/client/public/blueicons/FURNITURE.png b/client/public/icons/blueicons/FURNITURE.png similarity index 100% rename from client/public/blueicons/FURNITURE.png rename to client/public/icons/blueicons/FURNITURE.png diff --git a/client/public/blueicons/household_goods.png b/client/public/icons/blueicons/HOUSEHOLD_GOODS.png similarity index 100% rename from client/public/blueicons/household_goods.png rename to client/public/icons/blueicons/HOUSEHOLD_GOODS.png diff --git a/client/public/blueicons/ict_equipment.png b/client/public/icons/blueicons/ICT_EQUIPMENT.png similarity index 100% rename from client/public/blueicons/ict_equipment.png rename to client/public/icons/blueicons/ICT_EQUIPMENT.png diff --git a/client/public/blueicons/INKS_AND_TONER_CARTRIDGES.png b/client/public/icons/blueicons/INKS_AND_TONER_CARTRIDGES.png similarity index 100% rename from client/public/blueicons/INKS_AND_TONER_CARTRIDGES.png rename to client/public/icons/blueicons/INKS_AND_TONER_CARTRIDGES.png diff --git a/client/public/blueicons/LAMPS.png b/client/public/icons/blueicons/LAMPS.png similarity index 100% rename from client/public/blueicons/LAMPS.png rename to client/public/icons/blueicons/LAMPS.png diff --git a/client/public/blueicons/large_household_appliances.png b/client/public/icons/blueicons/LARGE_HOUSEHOLD_APPLIANCES.png similarity index 100% rename from client/public/blueicons/large_household_appliances.png rename to client/public/icons/blueicons/LARGE_HOUSEHOLD_APPLIANCES.png diff --git a/client/public/blueicons/nespresso.png b/client/public/icons/blueicons/NESPRESSO.png similarity index 100% rename from client/public/blueicons/nespresso.png rename to client/public/icons/blueicons/NESPRESSO.png diff --git a/client/public/blueicons/other_electrical_appliances.png b/client/public/icons/blueicons/OTHER_ELECTRICAL_APPLIANCES.png similarity index 100% rename from client/public/blueicons/other_electrical_appliances.png rename to client/public/icons/blueicons/OTHER_ELECTRICAL_APPLIANCES.png diff --git a/client/public/blueicons/paper_and_cardboard.png b/client/public/icons/blueicons/PAPER_AND_CARDBOARD.png similarity index 100% rename from client/public/blueicons/paper_and_cardboard.png rename to client/public/icons/blueicons/PAPER_AND_CARDBOARD.png diff --git a/client/public/blueicons/portable_batteries.png b/client/public/icons/blueicons/PORTABLE_BATTERIES.png similarity index 100% rename from client/public/blueicons/portable_batteries.png rename to client/public/icons/blueicons/PORTABLE_BATTERIES.png diff --git a/client/public/blueicons/RECYCLABLE.png b/client/public/icons/blueicons/RECYCLABLE.png similarity index 100% rename from client/public/blueicons/RECYCLABLE.png rename to client/public/icons/blueicons/RECYCLABLE.png diff --git a/client/public/blueicons/SHOES.png b/client/public/icons/blueicons/SHOES.png similarity index 100% rename from client/public/blueicons/SHOES.png rename to client/public/icons/blueicons/SHOES.png diff --git a/client/public/blueicons/STATIONERY.png b/client/public/icons/blueicons/STATIONERY.png similarity index 100% rename from client/public/blueicons/STATIONERY.png rename to client/public/icons/blueicons/STATIONERY.png diff --git a/client/public/blueicons/Toys.png b/client/public/icons/blueicons/TOYS.png similarity index 100% rename from client/public/blueicons/Toys.png rename to client/public/icons/blueicons/TOYS.png diff --git a/client/public/blueicons/icon_circle.png b/client/public/icons/blueicons/icon_circle.png similarity index 100% rename from client/public/blueicons/icon_circle.png rename to client/public/icons/blueicons/icon_circle.png diff --git a/client/public/icons/books.png b/client/public/icons/books.png deleted file mode 100644 index f227a3f..0000000 Binary files a/client/public/icons/books.png and /dev/null differ diff --git a/client/public/icons/clothing.png b/client/public/icons/clothing.png deleted file mode 100644 index 49df18c..0000000 Binary files a/client/public/icons/clothing.png and /dev/null differ diff --git a/client/public/icons/content_container.png b/client/public/icons/content_container.png deleted file mode 100644 index 7bb8261..0000000 Binary files a/client/public/icons/content_container.png and /dev/null differ diff --git a/client/public/icons/food.png b/client/public/icons/food.png deleted file mode 100644 index a9b9f74..0000000 Binary files a/client/public/icons/food.png and /dev/null differ diff --git a/client/public/icons/food_drink_container.png b/client/public/icons/food_drink_container.png deleted file mode 100644 index d18ccbc..0000000 Binary files a/client/public/icons/food_drink_container.png and /dev/null differ diff --git a/client/public/icons/furniture.png b/client/public/icons/furniture.png deleted file mode 100644 index 82e48ad..0000000 Binary files a/client/public/icons/furniture.png and /dev/null differ diff --git a/client/public/icons/household_goods.png b/client/public/icons/household_goods.png deleted file mode 100644 index 04157e8..0000000 Binary files a/client/public/icons/household_goods.png and /dev/null differ diff --git a/client/public/icons/ict_equipment.png b/client/public/icons/ict_equipment.png deleted file mode 100644 index 3baa156..0000000 Binary files a/client/public/icons/ict_equipment.png and /dev/null differ diff --git a/client/public/icons/lamps.png b/client/public/icons/lamps.png deleted file mode 100644 index d56e936..0000000 Binary files a/client/public/icons/lamps.png and /dev/null differ diff --git a/client/public/icons/large_household_appliances.png b/client/public/icons/large_household_appliances.png deleted file mode 100644 index 715ee34..0000000 Binary files a/client/public/icons/large_household_appliances.png and /dev/null differ diff --git a/client/public/icons/other_electrical_appliances.png b/client/public/icons/other_electrical_appliances.png deleted file mode 100644 index 12abe98..0000000 Binary files a/client/public/icons/other_electrical_appliances.png and /dev/null differ diff --git a/client/public/icons/paper_and_cardboard.png b/client/public/icons/paper_and_cardboard.png deleted file mode 100644 index 6eb0db4..0000000 Binary files a/client/public/icons/paper_and_cardboard.png and /dev/null differ diff --git a/client/public/icons/recyclable.png b/client/public/icons/recyclable.png deleted file mode 100644 index ea1cacc..0000000 Binary files a/client/public/icons/recyclable.png and /dev/null differ diff --git a/client/public/icons/shoes.png b/client/public/icons/shoes.png deleted file mode 100644 index 98770fc..0000000 Binary files a/client/public/icons/shoes.png and /dev/null differ diff --git a/client/public/icons/stationery.png b/client/public/icons/stationery.png deleted file mode 100644 index 45c7d37..0000000 Binary files a/client/public/icons/stationery.png and /dev/null differ diff --git a/client/public/icons/toys.png b/client/public/icons/toys.png deleted file mode 100644 index 467b622..0000000 Binary files a/client/public/icons/toys.png and /dev/null differ diff --git a/client/public/whiteicons/baby_children_items.png b/client/public/icons/whiteicons/BABY_CHILDREN_ITEMS.png similarity index 100% rename from client/public/whiteicons/baby_children_items.png rename to client/public/icons/whiteicons/BABY_CHILDREN_ITEMS.png diff --git a/client/public/whiteicons/bags_and_accessories.png b/client/public/icons/whiteicons/BAGS_AND_ACCESSORIES.png similarity index 100% rename from client/public/whiteicons/bags_and_accessories.png rename to client/public/icons/whiteicons/BAGS_AND_ACCESSORIES.png diff --git a/client/public/whiteicons/BOOKS.png b/client/public/icons/whiteicons/BOOKS.png similarity index 100% rename from client/public/whiteicons/BOOKS.png rename to client/public/icons/whiteicons/BOOKS.png diff --git a/client/public/whiteicons/CLOTHING.png b/client/public/icons/whiteicons/CLOTHING.png similarity index 100% rename from client/public/whiteicons/CLOTHING.png rename to client/public/icons/whiteicons/CLOTHING.png diff --git a/client/public/whiteicons/contact_lens.png b/client/public/icons/whiteicons/CONTACT_LENS.png similarity index 100% rename from client/public/whiteicons/contact_lens.png rename to client/public/icons/whiteicons/CONTACT_LENS.png diff --git a/client/public/whiteicons/content_container.png b/client/public/icons/whiteicons/CONTENT_CONTAINER.png similarity index 100% rename from client/public/whiteicons/content_container.png rename to client/public/icons/whiteicons/CONTENT_CONTAINER.png diff --git a/client/public/whiteicons/FOOD.png b/client/public/icons/whiteicons/FOOD.png similarity index 100% rename from client/public/whiteicons/FOOD.png rename to client/public/icons/whiteicons/FOOD.png diff --git a/client/public/whiteicons/food_drink_container.png b/client/public/icons/whiteicons/FOOD_DRINK_CONTAINER.png similarity index 100% rename from client/public/whiteicons/food_drink_container.png rename to client/public/icons/whiteicons/FOOD_DRINK_CONTAINER.png diff --git a/client/public/whiteicons/FURNITURE.png b/client/public/icons/whiteicons/FURNITURE.png similarity index 100% rename from client/public/whiteicons/FURNITURE.png rename to client/public/icons/whiteicons/FURNITURE.png diff --git a/client/public/whiteicons/GENERAL_WASTE.png b/client/public/icons/whiteicons/GENERAL_WASTE.png similarity index 100% rename from client/public/whiteicons/GENERAL_WASTE.png rename to client/public/icons/whiteicons/GENERAL_WASTE.png diff --git a/client/public/whiteicons/household_goods.png b/client/public/icons/whiteicons/HOUSEHOLD_GOODS.png similarity index 100% rename from client/public/whiteicons/household_goods.png rename to client/public/icons/whiteicons/HOUSEHOLD_GOODS.png diff --git a/client/public/whiteicons/ict_equipment.png b/client/public/icons/whiteicons/ICT_EQUIPMENT.png similarity index 100% rename from client/public/whiteicons/ict_equipment.png rename to client/public/icons/whiteicons/ICT_EQUIPMENT.png diff --git a/client/public/whiteicons/INKS_AND_TONER_CARTRIDGES.png b/client/public/icons/whiteicons/INKS_AND_TONER_CARTRIDGES.png similarity index 100% rename from client/public/whiteicons/INKS_AND_TONER_CARTRIDGES.png rename to client/public/icons/whiteicons/INKS_AND_TONER_CARTRIDGES.png diff --git a/client/public/whiteicons/LAMPS.png b/client/public/icons/whiteicons/LAMPS.png similarity index 100% rename from client/public/whiteicons/LAMPS.png rename to client/public/icons/whiteicons/LAMPS.png diff --git a/client/public/whiteicons/large_household_appliances.png b/client/public/icons/whiteicons/LARGE_HOUSEHOLD_APPLIANCES.png similarity index 100% rename from client/public/whiteicons/large_household_appliances.png rename to client/public/icons/whiteicons/LARGE_HOUSEHOLD_APPLIANCES.png diff --git a/client/public/whiteicons/nespresso.png b/client/public/icons/whiteicons/NESPRESSO.png similarity index 100% rename from client/public/whiteicons/nespresso.png rename to client/public/icons/whiteicons/NESPRESSO.png diff --git a/client/public/whiteicons/other_electrical_appliances.png b/client/public/icons/whiteicons/OTHER_ELECTRICAL_APPLIANCES.png similarity index 100% rename from client/public/whiteicons/other_electrical_appliances.png rename to client/public/icons/whiteicons/OTHER_ELECTRICAL_APPLIANCES.png diff --git a/client/public/whiteicons/paper_and_cardboard.png b/client/public/icons/whiteicons/PAPER_AND_CARDBOARD.png similarity index 100% rename from client/public/whiteicons/paper_and_cardboard.png rename to client/public/icons/whiteicons/PAPER_AND_CARDBOARD.png diff --git a/client/public/whiteicons/portable_batteries.png b/client/public/icons/whiteicons/PORTABLE_BATTERIES.png similarity index 100% rename from client/public/whiteicons/portable_batteries.png rename to client/public/icons/whiteicons/PORTABLE_BATTERIES.png diff --git a/client/public/whiteicons/RECYCLABLE.png b/client/public/icons/whiteicons/RECYCLABLE.png similarity index 100% rename from client/public/whiteicons/RECYCLABLE.png rename to client/public/icons/whiteicons/RECYCLABLE.png diff --git a/client/public/whiteicons/SHOES.png b/client/public/icons/whiteicons/SHOES.png similarity index 100% rename from client/public/whiteicons/SHOES.png rename to client/public/icons/whiteicons/SHOES.png diff --git a/client/public/whiteicons/STATIONERY.png b/client/public/icons/whiteicons/STATIONERY.png similarity index 100% rename from client/public/whiteicons/STATIONERY.png rename to client/public/icons/whiteicons/STATIONERY.png diff --git a/client/public/whiteicons/Toys.png b/client/public/icons/whiteicons/TOYS.png similarity index 100% rename from client/public/whiteicons/Toys.png rename to client/public/icons/whiteicons/TOYS.png diff --git a/client/spa-pages/components/HomePage.tsx b/client/spa-pages/components/HomePage.tsx index b3735f1..cd29c39 100644 --- a/client/spa-pages/components/HomePage.tsx +++ b/client/spa-pages/components/HomePage.tsx @@ -13,19 +13,20 @@ type Props = { setPage: Dispatch>; }; export const HomePage = ({ setPage }: Props) => { - const [stickyHeight, setStickyHeight] = useState(0); + const stickyRef = useRef(null); + const scrollableContainerRef = useRef(null); + + const [stickyHeight, setStickyHeight] = useState( + stickyRef.current?.clientHeight as number, + ); const [readyToSubmit, setReadyToSubmit] = useState(false); const { height } = useWindowDimensions(); const { isLoaded } = useSheetyData(); - const stickyRef = useRef(null); - const scrollableContainerRef = useRef(null); - useEffect(() => { setStickyHeight(stickyRef.current?.clientHeight || 0); }, [stickyRef.current?.clientHeight, height]); - return ( @@ -37,7 +38,7 @@ export const HomePage = ({ setPage }: Props) => { }} p={0} pb={5} - overflow="auto" + overflow={"scroll"} height={height - stickyHeight - NAVBAR_HEIGHT} ref={scrollableContainerRef} > diff --git a/client/spa-pages/components/InstructionsPage.tsx b/client/spa-pages/components/InstructionsPage.tsx index 973ecae..e4b8c10 100644 --- a/client/spa-pages/components/InstructionsPage.tsx +++ b/client/spa-pages/components/InstructionsPage.tsx @@ -89,7 +89,7 @@ export const InstructionsPage = ({ setPage }: Props) => { height={height - stickyHeight - NAVBAR_HEIGHT} ref={scrollableContainerRef} > - + diff --git a/client/spa-pages/components/MapPage.tsx b/client/spa-pages/components/MapPage.tsx index b6a15ae..193f120 100644 --- a/client/spa-pages/components/MapPage.tsx +++ b/client/spa-pages/components/MapPage.tsx @@ -10,7 +10,7 @@ import { Button, Image, } from "@chakra-ui/react"; -import { ComponentProps, Dispatch, SetStateAction, useState } from "react"; +import { ComponentProps, Dispatch, SetStateAction, useEffect, useState } from "react"; import { Pages } from "spa-pages/pageEnums"; import { useUserInputs } from "hooks/useUserSelection"; import { TStateFacilities } from "app-context/SheetyContext/types"; @@ -20,7 +20,7 @@ import { TItemSelection, TEmptyItem } from "app-context/SheetyContext/types"; import { FacilityType, RecyclingLocationResults } from "app-context/UserSelectionContext/types"; import Select, { components } from "react-select"; import { ActionMeta, MultiValue } from "react-select"; -import { Methods } from "api/sheety/enums"; +import { Categories, Methods } from "api/sheety/enums"; import { ChangeEvent } from "react"; // Component Imports @@ -90,6 +90,12 @@ const MapInner = ({ setPage }: Props) => { const leafletWindow = useLeafletWindow(); const { recyclingLocationResults, address, items, setRecyclingLocationResults } = useUserInputs(); + + // Remove general waste items + const recyclableItems = items.filter( + (item) => getItemCategory(item.name) !== Categories.GENERAL_WASTE, + ); + ////// States ////// const [lineCoords, setLineCoords] = useState<[number, number][]>( recyclingLocationResults?.route.coords ?? [[0, 0]], @@ -107,7 +113,7 @@ const MapInner = ({ setPage }: Props) => { const [range, setRange] = useState(MAX_DISTANCE_KM * 10); // Multiselect Box - const selectOptions: OptionType[] = items.map((item, index) => ({ + const selectOptions: OptionType[] = recyclableItems.map((item, index) => ({ value: item.name, label: item.name, method: item.method, @@ -115,7 +121,7 @@ const MapInner = ({ setPage }: Props) => { })); const [selectedOptions, setSelectedOptions] = useState([...selectOptions]); // Internal tracking of user-selected items - const [itemState, setItemState] = useState<(TItemSelection | TEmptyItem)[]>(items); + const [itemState, setItemState] = useState<(TItemSelection | TEmptyItem)[]>(recyclableItems); // Facility Card const [facCardIsOpen, setFacCardIsOpen] = useState(false); @@ -200,25 +206,25 @@ const MapInner = ({ setPage }: Props) => { setSelectedOptions(updatedOptions); setItemState(updatedItemState); setFacCardIsOpen(false); - handleChangedLocation(updatedItemState); + handleChangedLocation(updatedItemState, range); }; // Handle changes in items selected in the Filter panel const handleCheckboxChange = (e: ChangeEvent) => { const { updatedItemState, updatedOptions } = checkboxChange(e, itemState, selectedOptions); - handleChangedLocation(updatedItemState); + handleChangedLocation(updatedItemState, range); setSelectedOptions(updatedOptions); setItemState(updatedItemState); }; // Handle the changing of location in this page itself - const handleChangedLocation = (itemEntry: (TItemSelection | TEmptyItem)[]) => { + const handleChangedLocation = (itemEntry: (TItemSelection | TEmptyItem)[], range: number) => { const locations = getNearbyFacilities( itemEntry as TItemSelection[], address, facilities, getItemCategory, - MAX_DISTANCE_KM, + range / 10, ); locations.route.complete ? setLineColor("green") : setLineColor("blue"); // Trigger changes in lazy loaded CustomPolyline component @@ -241,40 +247,24 @@ const MapInner = ({ setPage }: Props) => { ] as LatLngExpression); }; + useEffect(() => { + handleChangedLocation(itemState, range); + }, [address, itemState]); + const selectAllItems = () => { - const itemState = items.map((item) => ({ + const itemState = recyclableItems.map((item) => ({ name: item.name, method: item.method, })); - handleChangedLocation(itemState); setItemState(itemState); setSelectedOptions(selectOptions); }; // Handle the changes in distance selected in Filter panel const handleSliderChange = (val: number) => { - const dist = val / 10; - const locations = getNearbyFacilities( - itemState as TItemSelection[], - address, - facilities, - getItemCategory, - 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); - locations ? setLocations(locations.results) : setLocations(undefined); - - map?.panTo([ - parseFloat(address.coordinates.lat), - parseFloat(address.coordinates.long), - ] as LatLngExpression); + handleChangedLocation(itemState, val); }; const handleFlyTo = (location: LatLngExpression) => { @@ -350,26 +340,21 @@ const MapInner = ({ setPage }: Props) => { selectedOptions={selectedOptions} selectOptions={selectOptions} handleMultiselectOnChange={handleMultiselectOnChange} - itemState={itemState} - handleChangedLocation={handleChangedLocation} handleRouteShow={handleRouteShow} handleFlyTo={handleFlyTo} /> {facCardIsOpen && ( )} {showRoute && !facCardIsOpen && recyclingLocationResults?.route && ( )} @@ -399,8 +384,6 @@ export const MapHeaderButtons = ({ selectedOptions, selectOptions, handleMultiselectOnChange, - itemState, - handleChangedLocation, onFilterOpen, handleRouteShow, handleFlyTo, @@ -412,8 +395,6 @@ export const MapHeaderButtons = ({ newValue: MultiValue, actionMeta: ActionMeta, ) => void; - itemState: (TItemSelection | TEmptyItem)[]; - handleChangedLocation: (itemEntry: (TItemSelection | TEmptyItem)[]) => void; onFilterOpen: () => void; handleRouteShow: () => void; handleFlyTo: (location: LatLngExpression) => void; @@ -448,7 +429,6 @@ export const MapHeaderButtons = ({ borderRadius: "6px", }} showText={false} - handleBlur={() => handleChangedLocation(itemState)} /> { {`${category} diff --git a/client/spa-pages/components/PickupPage.tsx b/client/spa-pages/components/PickupPage.tsx index 8c5eb8f..c99685e 100644 --- a/client/spa-pages/components/PickupPage.tsx +++ b/client/spa-pages/components/PickupPage.tsx @@ -12,6 +12,7 @@ import { TSheetyPickupDetails } from "api/sheety/types"; import { TEmptyItem, TItemSelection } from "app-context/SheetyContext/types"; import NonRecyclableModal from "components/common/NonRecyclableModal"; import { useState } from "react"; +import { Categories } from "api/sheety/enums"; type Props = { setPage: Dispatch>; @@ -26,6 +27,12 @@ export type OrgProps = { export const PickupPage = ({ setPage }: Props) => { const { items, recyclingLocationResults } = useUserInputs(); const results = recyclingLocationResults ? recyclingLocationResults.results : {}; + const { pickUpServices, getItemCategory } = useSheetyData(); + + // Remove general waste items + const recyclableItems = items.filter( + (item) => getItemCategory(item.name) !== Categories.GENERAL_WASTE, + ); // Find shortest distance to facility let minDistance = 100; @@ -42,7 +49,6 @@ export const PickupPage = ({ setPage }: Props) => { } // Pick up services - const { pickUpServices, getItemCategory } = useSheetyData(); const sortPickups = (itemEntry: (TItemSelection | TEmptyItem)[]): OrgProps[] => { const possiblePickups = pickUpServices.filter((pickUpService) => { let picksUpAtLeastOneItem = false; @@ -71,7 +77,7 @@ export const PickupPage = ({ setPage }: Props) => { return sortedPossiblePickups; }; - const [orgs, setOrgs] = useState(sortPickups(items)); + const [orgs, setOrgs] = useState(sortPickups(recyclableItems)); return ( @@ -90,7 +96,11 @@ export const PickupPage = ({ setPage }: Props) => { {/* Title + Back Button */} {/* Multiselect Box */} - + {/* Title + List of all Services */}