summaryrefslogtreecommitdiff
path: root/src/components/Filter.js
blob: cb8fd6263a260bcee50d2fcadea6f0447817e2f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import CloseIcon from "../icons/close.svg";

const Filter = ({ 
  selectedBrand,
  onChangeBrand,
  selectedCategory,
  onChangeCategory,
  brands,
  categories,
  isActiveFilter, 
  closeFilter,
  onSubmit
}) => {
  return (
    <div className={`fixed w-full z-[60] py-8 px-4 ring ring-gray-300 bg-white rounded-t-3xl idt-transition ${isActiveFilter ? 'bottom-0' : 'bottom-[-100%]'}`}>
      <div className="flex justify-between items-center mb-5">
        <h2 className="text-xl font-semibold">Filter Produk</h2>
        <button onClick={closeFilter}>
          <CloseIcon className="w-7" />
        </button>
      </div>
      <form className="flex flex-col gap-y-4" onSubmit={onSubmit}>
        <div>
          <label>Kategori</label>
          <select className="form-input mt-2" value={selectedCategory} onChange={onChangeCategory}>
            <option value="">Pilih kategori...</option>
            {categories?.map((category, index) => (
              <option key={index} value={category}>{category}</option>
            ))}
          </select>
        </div>
        <div>
          <label>Brand</label>
          <select className="form-input mt-2" value={selectedBrand} onChange={onChangeBrand}>
            <option value="">Pilih brand...</option>
            {brands?.map((brand, index) => (
              <option key={index} value={brand}>{brand}</option>
            ))}
          </select>
        </div>
        <div>
          <label>Harga</label>
          <div className="flex gap-x-4 mt-2 items-center">
            <input className="form-input"/>
            <span>-</span>
            <input className="form-input"/>
          </div>
        </div>
        <button type="submit" className="btn-yellow font-semibold mt-4 w-full">
          Terapkan Filter
        </button>
      </form>
    </div>
  )
};

export default Filter;