|  | @@ -48,7 +48,7 @@ const ProductList = ({ size = 99999 }) => {
 | 
		
	
		
			
			| 48 | 48 |  
 | 
		
	
		
			
			| 49 | 49 |    //filter
 | 
		
	
		
			
			| 50 | 50 |    const [category, setCategory] = useState('all');
 | 
		
	
		
			
			| 51 |  | -  const [sort, setSort] = useState('all')
 | 
		
	
		
			
			|  | 51 | +  const [sort, setSort] = useState('title')
 | 
		
	
		
			
			| 52 | 52 |  
 | 
		
	
		
			
			| 53 | 53 |    useEffect(() => {
 | 
		
	
		
			
			| 54 | 54 |  
 | 
		
	
	
		
			
			|  | @@ -97,13 +97,19 @@ const ProductList = ({ size = 99999 }) => {
 | 
		
	
		
			
			| 97 | 97 |          }
 | 
		
	
		
			
			| 98 | 98 |        );
 | 
		
	
		
			
			| 99 | 99 |  
 | 
		
	
		
			
			|  | 100 | +      if (sort === "title") {
 | 
		
	
		
			
			|  | 101 | +        newFilteredProducts = newFilteredProducts.sort((a, b) => a.title.localeCompare(b.title));
 | 
		
	
		
			
			|  | 102 | +      } else if (sort === "new") {
 | 
		
	
		
			
			|  | 103 | +        newFilteredProducts = newFilteredProducts.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
 | 
		
	
		
			
			|  | 104 | +      } else if (sort === "old") {
 | 
		
	
		
			
			|  | 105 | +        newFilteredProducts = newFilteredProducts.sort((a, b) => new Date(a.createdAt) - new Date(b.createdAt));
 | 
		
	
		
			
			|  | 106 | +      }
 | 
		
	
		
			
			|  | 107 | +
 | 
		
	
		
			
			| 100 | 108 |        setFilteredProducts(newFilteredProducts)
 | 
		
	
		
			
			| 101 | 109 |  
 | 
		
	
		
			
			| 102 | 110 |      }
 | 
		
	
		
			
			| 103 | 111 |  
 | 
		
	
		
			
			| 104 |  | -  }, [category])
 | 
		
	
		
			
			| 105 |  | -
 | 
		
	
		
			
			| 106 |  | -
 | 
		
	
		
			
			|  | 112 | +  }, [category, sort])
 | 
		
	
		
			
			| 107 | 113 |  
 | 
		
	
		
			
			| 108 | 114 |    useEffect(() => {
 | 
		
	
		
			
			| 109 | 115 |      if (products) console.log(products)
 | 
		
	
	
		
			
			|  | @@ -171,6 +177,13 @@ const ProductList = ({ size = 99999 }) => {
 | 
		
	
		
			
			| 171 | 177 |          sx={{
 | 
		
	
		
			
			| 172 | 178 |            display: "flex",
 | 
		
	
		
			
			| 173 | 179 |            justifyContent: "space-between",
 | 
		
	
		
			
			|  | 180 | +          py:1,
 | 
		
	
		
			
			|  | 181 | +          flexDirection:{
 | 
		
	
		
			
			|  | 182 | +            xs:"column",
 | 
		
	
		
			
			|  | 183 | +            sm:"row",
 | 
		
	
		
			
			|  | 184 | +            md:"row",
 | 
		
	
		
			
			|  | 185 | +            lg:"row"
 | 
		
	
		
			
			|  | 186 | +          },
 | 
		
	
		
			
			| 174 | 187 |            alignItems: "center",
 | 
		
	
		
			
			| 175 | 188 |            backgroundColor: "background.black",
 | 
		
	
		
			
			| 176 | 189 |            color: "white",
 | 
		
	
	
		
			
			|  | @@ -179,15 +192,20 @@ const ProductList = ({ size = 99999 }) => {
 | 
		
	
		
			
			| 179 | 192 |          }}
 | 
		
	
		
			
			| 180 | 193 |        >
 | 
		
	
		
			
			| 181 | 194 |          {/* Left Side: Page Title */}
 | 
		
	
		
			
			| 182 |  | -        <Typography variant="body2">
 | 
		
	
		
			
			|  | 195 | +        <Typography variant="body2" sx={{fontSize:10}}>
 | 
		
	
		
			
			| 183 | 196 |            {`${filteredProducts.length} Item`}
 | 
		
	
		
			
			| 184 | 197 |          </Typography>
 | 
		
	
		
			
			| 185 | 198 |  
 | 
		
	
		
			
			| 186 | 199 |          {/* Right Side: Option Inputs */}
 | 
		
	
		
			
			| 187 |  | -        <Box sx={{ display: "flex", gap: 2 }}>
 | 
		
	
		
			
			|  | 200 | +        <Box sx={{ display: "flex", gap: 2, flexDirection:{
 | 
		
	
		
			
			|  | 201 | +            xs:"column",
 | 
		
	
		
			
			|  | 202 | +            sm:"row",
 | 
		
	
		
			
			|  | 203 | +            md:"row",
 | 
		
	
		
			
			|  | 204 | +            lg:"row"
 | 
		
	
		
			
			|  | 205 | +          }, }}>
 | 
		
	
		
			
			| 188 | 206 |  
 | 
		
	
		
			
			| 189 | 207 |            <FormControl sx={{ m: 1, display: "flex", flexDirection: "row" }} variant="standard">
 | 
		
	
		
			
			| 190 |  | -            <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>Filter By Category</Typography>
 | 
		
	
		
			
			|  | 208 | +            <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>Category</Typography>
 | 
		
	
		
			
			| 191 | 209 |              <Select
 | 
		
	
		
			
			| 192 | 210 |                value={category}
 | 
		
	
		
			
			| 193 | 211 |                onChange={(event) => {
 | 
		
	
	
		
			
			|  | @@ -201,17 +219,19 @@ const ProductList = ({ size = 99999 }) => {
 | 
		
	
		
			
			| 201 | 219 |              </Select>
 | 
		
	
		
			
			| 202 | 220 |            </FormControl>
 | 
		
	
		
			
			| 203 | 221 |  
 | 
		
	
		
			
			| 204 |  | -          <FormControl sx={{ m: 1, display: { xs: "none", sm: "none", md: "flex" }, flexDirection: "row" }} variant="standard">
 | 
		
	
		
			
			| 205 |  | -            <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>Sort By</Typography>
 | 
		
	
		
			
			|  | 222 | +          <FormControl sx={{ m: 1, display: "flex", flexDirection: "row" }} variant="standard">
 | 
		
	
		
			
			|  | 223 | +            <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>Sort</Typography>
 | 
		
	
		
			
			| 206 | 224 |              <Select
 | 
		
	
		
			
			| 207 | 225 |                value={sort}
 | 
		
	
		
			
			| 208 |  | -              onChange={handleChange}
 | 
		
	
		
			
			|  | 226 | +              onChange={(event) => {
 | 
		
	
		
			
			|  | 227 | +                setSort(event.target.value);
 | 
		
	
		
			
			|  | 228 | +              }}
 | 
		
	
		
			
			| 209 | 229 |                input={<BootstrapInput />}
 | 
		
	
		
			
			| 210 | 230 |                name="sort"
 | 
		
	
		
			
			| 211 | 231 |              >
 | 
		
	
		
			
			| 212 |  | -              <MenuItem defaultValue value={''}>All</MenuItem>
 | 
		
	
		
			
			| 213 |  | -              <MenuItem defaultValue value={'all'}>Newest</MenuItem>
 | 
		
	
		
			
			| 214 |  | -
 | 
		
	
		
			
			|  | 232 | +              <MenuItem defaultValue value={'title'}>Title</MenuItem>
 | 
		
	
		
			
			|  | 233 | +              <MenuItem defaultValue value={'new'}>Newest</MenuItem>
 | 
		
	
		
			
			|  | 234 | +              <MenuItem defaultValue value={'old'}>Oldest</MenuItem>
 | 
		
	
		
			
			| 215 | 235 |              </Select>
 | 
		
	
		
			
			| 216 | 236 |            </FormControl>
 | 
		
	
		
			
			| 217 | 237 |  
 |