Skip to content

Commit

Permalink
Merge pull request #31 from icssc/28-feat-date-range-filter-button
Browse files Browse the repository at this point in the history
28 feat date range filter button
  • Loading branch information
NwinNwin authored Feb 20, 2024
2 parents e63c5e0 + bcf8b11 commit 173c9f1
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 141 deletions.
5 changes: 4 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
property="twitter:description"
content="A platform for UCI students to effortlessly locate and recover lost or found items."
/>
<meta property="twitter:image" content="https://zotnfound.com/description.png" />
<meta
property="twitter:image"
content="https://zotnfound.com/description.png"
/>

<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
Expand Down
74 changes: 74 additions & 0 deletions src/components/Home/DateRangeFilter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Button, Menu, MenuButton, MenuList, MenuItem } from "@chakra-ui/react";
import { useState, useContext } from "react";
import { ChevronDownIcon } from "@chakra-ui/icons";
import DataContext from "../../context/DataContext";

import {
retrieveItemsAllTime,
retrieveItemsWithinMonth,
retrieveItemsWithinTwoWeeks,
retrieveItemsWithinWeek,
retrieveItemsWithinYear,
} from "../../utils/HomeUtils";

export default function DateRangeFilter() {
const [DateRangeFilter, setDateRangeFilter] = useState("Date Range Filter");
const { setLoading, setData } = useContext(DataContext);

return (
<Menu>
<MenuButton
as={Button}
rightIcon={<ChevronDownIcon />}
backgroundColor="white"
variant="outline"
boxShadow="7px 7px 14px #666666,
-7px -7px 14px #ffffff;"
color="#74a2fa"
fontSize={{ base: "xl", md: "2xl" }}
size="lg"
// gap={2}
borderRadius={"lg"}
>
{DateRangeFilter}
</MenuButton>
<MenuList>
<MenuItem
onClick={() =>
retrieveItemsAllTime(setData, setDateRangeFilter, setLoading)
}
>
All
</MenuItem>
<MenuItem
onClick={() =>
retrieveItemsWithinWeek(setData, setDateRangeFilter, setLoading)
}
>
Last 7 Days
</MenuItem>
<MenuItem
onClick={() =>
retrieveItemsWithinTwoWeeks(setData, setDateRangeFilter, setLoading)
}
>
Last 14 Days
</MenuItem>
<MenuItem
onClick={() =>
retrieveItemsWithinMonth(setData, setDateRangeFilter, setLoading)
}
>
Last 30 Days
</MenuItem>
<MenuItem
onClick={() =>
retrieveItemsWithinYear(setData, setDateRangeFilter, setLoading)
}
>
This Year
</MenuItem>
</MenuList>
</Menu>
);
}
108 changes: 22 additions & 86 deletions src/components/Home/Home.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import React, { useState, useEffect, useRef } from "react";
import Map from "../Map/Map";
import "./Home.css";
import Filter from "../Filter/Filter";
import ResultsBar from "../ResultsBar/ResultsBar";
import CreateModal from "../CreateModal/CreateModal";
import LoginModal from "../LoginModal/LoginModal";
import Leaderboard from "./Leaderboard";
import axios from "axios";

import instagram from "../../assets/logos/instagram.svg";
import { UserAuth } from "../../context/AuthContext";
import DataContext from "../../context/DataContext";

import { Spinner, useToast } from "@chakra-ui/react";
import {
Input,
Expand Down Expand Up @@ -37,8 +31,7 @@ import {
AlertIcon,
AlertTitle,
} from "@chakra-ui/react";
import { SettingsIcon, ChevronDownIcon, StarIcon } from "@chakra-ui/icons";
import logo from "../../assets/images/small_logo.png";
import { SettingsIcon, StarIcon } from "@chakra-ui/icons";
import upload from "../../assets/images/download.png";

import logout from "../../assets/logos/logout.svg";
Expand All @@ -47,7 +40,15 @@ import userlogo from "../../assets/logos/userlogo.svg";
import yourposts from "../../assets/logos/yourposts.svg";
import cookie from "../../assets/images/cookie.svg";

import axios from "axios";
import Map from "../Map/Map";
import "./Home.css";
import Filter from "../Filter/Filter";
import ResultsBar from "../ResultsBar/ResultsBar";
import CreateModal from "../CreateModal/CreateModal";
import LoginModal from "../LoginModal/LoginModal";
import Leaderboard from "./Leaderboard";
import ZotNFoundLogoText from "./ZotNFoundLogoText";
import DateRangeFilter from "./DateRangeFilter";

export default function Home() {
const [search, setSearch] = useState("");
Expand Down Expand Up @@ -111,9 +112,7 @@ export default function Home() {
const centerPosition = [33.6461, -117.8427];
const [position, setPosition] = useState(centerPosition);
const [focusLocation, setFocusLocation] = useState();
const [screenWidth, setScreenWidth] = useState(window.screen.width);
const [uploadImg, setUploadImg] = useState("");

// LOGIN MODAL
const {
isOpen: isLoginModalOpen,
Expand All @@ -139,7 +138,7 @@ export default function Home() {
console.log(result);
toast({
title: "Succesfully Unsubscribed!",
description: "You have been unsubscribed from the ZotnFound Newsletter",
description: "You have been unsubscribed from the ZotNFound Newsletter",
status: "success",
duration: 5000,
isClosable: true,
Expand Down Expand Up @@ -253,14 +252,11 @@ export default function Home() {
}
}, [user]);

window.onresize = () => {
setScreenWidth(window.screen.width);
};

return (
<DataContext.Provider
value={{
data: data,
setData: setData,
token: token,
setLoading: setLoading,
isLoginModalOpen: isLoginModalOpen,
Expand All @@ -274,70 +270,10 @@ export default function Home() {
alignItems="center"
className="big"
>
<Flex
alignItems="center"
w={{ base: "20%", md: "20%" }}
className="med"
minWidth={{ base: "125px", md: "315px" }}
>
<Image
width={{ base: "50px", md: "100px" }}
src={logo}
mb="5%"
mt="3%"
ml="10%"
display={screenWidth < 350 ? "None" : "inline"}
/>
<Menu autoSelect={false}>
<MenuButton
as={Button}
rightIcon={<ChevronDownIcon />}
size={{ base: "4xl", md: "4xl" }}
ml="3%"
fontSize={{ base: "xl", md: "4xl" }}
background="white"
justifyContent="center"
alignItems="center"
padding={2}
>
ZotnFound
</MenuButton>
{/* LOGO + TEXT */}
<ZotNFoundLogoText />

{/* ZotnFound Logo/Text Dropdown */}
<MenuList zIndex={10000}>
<MenuItem
alignItems={"center"}
justifyContent={"center"}
as={"a"}
href="https://www.instagram.com/zotnfound/"
>
@ZotnFound
<Image
src={instagram}
maxWidth="10%"
maxHeight="10%"
ml="5%"
></Image>
</MenuItem>
<MenuItem
alignItems={"center"}
justifyContent={"center"}
as={"a"}
href="/update"
>
News
</MenuItem>
<MenuItem
alignItems={"center"}
justifyContent={"center"}
as={"a"}
href="/about"
>
About
</MenuItem>
</MenuList>
</Menu>
</Flex>
{/* SEARCH BAR */}
<HStack
w={{ base: "100%", md: "40%" }}
display={{ base: "none", md: "block" }}
Expand Down Expand Up @@ -538,7 +474,7 @@ export default function Home() {
</Alert>
</Flex>
) : (
<>
<Flex gap="4">
<Button
backgroundColor="white"
variant="outline"
Expand All @@ -561,6 +497,9 @@ export default function Home() {
isOpen={isOpen}
onClose={onClose}
/>

<DateRangeFilter />

<Button
display={{ md: "none" }}
background={"#74a2fa"}
Expand Down Expand Up @@ -630,7 +569,6 @@ export default function Home() {
<ResultsBar
search={search}
findFilter={findFilter}
setData={setData}
setFocusLocation={setFocusLocation}
onResultsBarClose={onResultsBarClose}
setLeaderboard={setLeaderboard}
Expand All @@ -640,7 +578,7 @@ export default function Home() {
<DrawerFooter></DrawerFooter>
</DrawerContent>
</Drawer>
</>
</Flex>
)}
</Flex>
<Flex position="absolute">
Expand All @@ -652,7 +590,6 @@ export default function Home() {
setIsEdit={setIsEdit}
search={search}
findFilter={findFilter}
setData={setData}
setIsCreate={setIsCreate}
isCreate={isCreate}
centerPosition={centerPosition}
Expand All @@ -675,7 +612,6 @@ export default function Home() {
<ResultsBar
search={search}
findFilter={findFilter}
setData={setData}
setFocusLocation={setFocusLocation}
setLeaderboard={setLeaderboard}
/>
Expand Down
88 changes: 88 additions & 0 deletions src/components/Home/ZotNFoundLogoText.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import {
Button,
Flex,
Image,
Menu,
MenuButton,
MenuList,
MenuItem,
} from "@chakra-ui/react";

import { useState } from "react";
import logo from "../../assets/images/small_logo.png";
import instagram from "../../assets/logos/instagram.svg";
import { ChevronDownIcon } from "@chakra-ui/icons";

export default function ZotNFoundLogoText() {
const [screenWidth, setScreenWidth] = useState(window.screen.width);

window.onresize = () => {
setScreenWidth(window.screen.width);
};
return (
<Flex
alignItems="center"
w={{ base: "20%", md: "20%" }}
className="med"
minWidth={{ base: "125px", md: "315px" }}
>
<Image
width={{ base: "50px", md: "100px" }}
src={logo}
mb="5%"
mt="3%"
ml="10%"
display={screenWidth < 350 ? "None" : "inline"}
/>
<Menu autoSelect={false}>
<MenuButton
as={Button}
rightIcon={<ChevronDownIcon />}
size={{ base: "4xl", md: "4xl" }}
ml="3%"
fontSize={{ base: "xl", md: "4xl" }}
background="white"
justifyContent="center"
alignItems="center"
padding={2}
>
ZotNFound
</MenuButton>

{/* ZotnFound Logo/Text Dropdown */}
<MenuList zIndex={10000}>
<MenuItem
alignItems={"center"}
justifyContent={"center"}
as={"a"}
href="https://www.instagram.com/zotnfound/"
>
@ZotNFound
<Image
src={instagram}
maxWidth="10%"
maxHeight="10%"
ml="5%"
></Image>
</MenuItem>
<MenuItem
alignItems={"center"}
justifyContent={"center"}
as={"a"}
href="/update"
>
News
</MenuItem>
<MenuItem
alignItems={"center"}
justifyContent={"center"}
as={"a"}
href="/about"
>
About
</MenuItem>
</MenuList>
</Menu>
</Flex>
);
}
Loading

0 comments on commit 173c9f1

Please sign in to comment.