Ignore:
Timestamp:
12/13/22 22:38:11 (19 months ago)
Author:
Nace Gjorgjievski <nace.gorgievski123@…>
Branches:
master
Parents:
113029b
Message:

Final Version

Location:
frontend/src/screens
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • frontend/src/screens/AdminAddProductScreen.js

    r113029b ra2e5735  
    2020  const [dimension, setDimension] = useState("");
    2121  const [scheme, setScheme] = useState("");
     22  const [H, setH] = useState("");
     23  const [W, setW] = useState("");
     24  const [L, setL] = useState("");
    2225  const [message, setMessage] = useState("");
    2326
     
    5659    formData.append("dimension", dimension);
    5760    formData.append("scheme", scheme);
    58 
     61    formData.append("H", H);
     62    formData.append("W", W);
     63    formData.append("L", L);
    5964    try {
    6065      const result = await axios.post("/api/products/add", formData);
     
    7681            Додади нов производ
    7782          </div>
     83        </Link>
     84        <Link
     85          to={"/admin/addCategory"}
     86          style={{ textDecoration: "none", width: "100%" }}
     87        >
     88          <div className="dashboard-btn">Додади категорија</div>
    7889        </Link>
    7990        <Link
     
    351362              </div>
    352363              <div>
     364                <Form.Group
     365                  style={{ display: "flex", justifyContent: "space-around" }}
     366                >
     367                  <div
     368                    style={{
     369                      display: "flex",
     370                      flexDirection: "row",
     371                      alignItems: "center",
     372                    }}
     373                  >
     374                    <Form.Label>H:</Form.Label>
     375                    <Form.Control
     376                      type="text"
     377                      name="dimension"
     378                      style={{ width: "60px" }}
     379                      value={H}
     380                      onChange={(e) => setH(e.target.value)}
     381                      required
     382                    ></Form.Control>
     383                  </div>
     384                  <div
     385                    style={{
     386                      display: "flex",
     387                      flexDirection: "row",
     388                      alignItems: "center",
     389                    }}
     390                  >
     391                    <Form.Label>W:</Form.Label>
     392                    <Form.Control
     393                      type="text"
     394                      name="dimension"
     395                      value={W}
     396                      onChange={(e) => setW(e.target.value)}
     397                      style={{ width: "60px" }}
     398                      required
     399                    ></Form.Control>
     400                  </div>
     401                  <div
     402                    style={{
     403                      display: "flex",
     404                      flexDirection: "row",
     405                      alignItems: "center",
     406                    }}
     407                  >
     408                    <Form.Label>L:</Form.Label>
     409                    <Form.Control
     410                      type="text"
     411                      name="dimension"
     412                      style={{ width: "60px" }}
     413                      value={L}
     414                      onChange={(e) => setL(e.target.value)}
     415                      required
     416                    ></Form.Control>
     417                  </div>
     418                </Form.Group>
    353419                <Form.Group>
    354420                  <Form.Label>Слика со димензии</Form.Label>
  • frontend/src/screens/AdminDashboardScreen.js

    r113029b ra2e5735  
    66import { useNavigate, Link } from "react-router-dom";
    77import ListProducts from "../components/ListProducts";
     8import { Helmet } from "react-helmet-async";
    89
    910function AdminDashboardScreen() {
     
    1920  return (
    2021    <div id="pgContainer">
     22      <Helmet>
     23        <title>Dashboard</title>
     24      </Helmet>
    2125      <div id="sidebarMenu">
    2226        <Link
     
    2731            Додади нов производ
    2832          </div>
     33        </Link>
     34        <Link
     35          to={"/admin/addCategory"}
     36          style={{ textDecoration: "none", width: "100%" }}
     37        >
     38          <div className="dashboard-btn">Додади категорија</div>
    2939        </Link>
    3040        <Link
  • frontend/src/screens/AdminEditProductScreen.js

    r113029b ra2e5735  
    8383            Додади нов производ
    8484          </div>
     85        </Link>
     86        <Link
     87          to={"/admin/addCategory"}
     88          style={{ textDecoration: "none", width: "100%" }}
     89        >
     90          <div className="dashboard-btn">Додади категорија</div>
    8591        </Link>
    8692        <Link
  • frontend/src/screens/AdminOrdersScreen.js

    r113029b ra2e5735  
    8282            Додади нов производ
    8383          </div>
     84        </Link>
     85        <Link
     86          to={"/admin/addCategory"}
     87          style={{ textDecoration: "none", width: "100%" }}
     88        >
     89          <div className="dashboard-btn">Додади категорија</div>
    8490        </Link>
    8591        <Link
  • frontend/src/screens/AdminProductsScreen.js

    r113029b ra2e5735  
    9696                Додади нов производ
    9797              </div>
     98            </Link>
     99            <Link
     100              to={"/admin/addCategory"}
     101              style={{ textDecoration: "none", width: "100%" }}
     102            >
     103              <div className="dashboard-btn">Додади категорија</div>
    98104            </Link>
    99105            <Link
  • frontend/src/screens/CategoryScreen.js

    r113029b ra2e5735  
    1 import React, { useEffect, useReducer } from "react";
     1import React, { useEffect, useReducer, useState } from "react";
    22import "../styles/Home.css";
    33// import data from "./data";
     
    3434  const params = useParams();
    3535  const { category, subCategory } = params;
     36  var HF = 0;
     37  var HT = 1000;
     38  var WF = 0;
     39  var WT = 1000;
     40  var LF = 0;
     41  var LT = 1000;
     42  //const [HT, setHT] = useState(1000);
     43  //const [WF, setWF] = useState(0);
     44  //const [WT, setWT] = useState(1000);
     45  //const [LF, setLF] = useState(0);
     46  //const [LT, setLT] = useState(1000);
    3647  const navigate = useNavigate();
    3748  const { search } = useLocation();
     
    4354  const order = sp.get("order") || "newest";
    4455  const page = sp.get("page") || 1;
    45 
    4656  const [{ loading, error, products, pages, countProducts }, dispatch] =
    4757    useReducer(reducer, { loading: true, error: "" });
     
    5666        );*/
    5767        const { data } = await axios.get(
    58           `/api/products?page=${page}&query=${query}&category=${category}&subCategory=${subCategory}&order=${order}`
     68          `/api/products?page=${page}&query=${query}&category=${category}&subCategory=${subCategory}&order=${order}&HF=${HF}&HT=${HT}&WF=${WF}&WT=${WT}&LF=${LF}&LT=${LT}`
    5969        );
    6070        dispatch({ type: "FETCH_SUCCESS", payload: data });
     
    6474    };
    6575    fetchData();
    66   }, [category, page, query, order, subCategory, error]);
     76  }, [
     77    category,
     78    page,
     79    query,
     80    order,
     81    subCategory,
     82    error,
     83    HF,
     84    HT,
     85    WF,
     86    WT,
     87    LF,
     88    LT,
     89  ]);
    6790
    6891  const getFilterUrl = (filter) => {
     
    7295    const filterSubCategory = filter.subCategory || subCategory;
    7396    const sortOrder = filter.order || order;
    74     return `?category=${filterCategorry}&query=${filterQuery}&subCategory=${filterSubCategory}&page=${filterPage}&order=${sortOrder}`;
     97    const filterHF = filter.HF || HF;
     98    const filterHT = filter.HT || HT;
     99    const filterWF = filter.WF || WF;
     100    const filterWT = filter.WT || WT;
     101    const filterLF = filter.LF || LF;
     102    const filterLT = filter.LT || LT;
     103    return `?category=${filterCategorry}&query=${filterQuery}&subCategory=${filterSubCategory}&page=${filterPage}&order=${sortOrder}&HF=${filterHF}&HT=${filterHT}&WF=${filterWF}&WT=${filterWT}&LF=${filterLF}&LT=${filterLT}`;
     104  };
     105
     106  const filterHandler = (e) => {
     107    e.preventDefault();
     108    HF = document.getElementById("HF").value;
     109    HT = document.getElementById("HT").value;
     110    WF = document.getElementById("WF").value;
     111    WT = document.getElementById("WT").value;
     112    LF = document.getElementById("LF").value;
     113    LT = document.getElementById("LT").value;
     114    console.log(HT);
     115    const fetchData = async () => {
     116      try {
     117        dispatch({ type: "FETCH_REQUEST" });
     118        /*
     119        const { data } = await axios.get(
     120          `/api/products/search?page=${page}&query=${query}&category=${category}&subCategory=${subCategory}&order=${order}`
     121        );*/
     122        const { data } = await axios.get(
     123          `/api/products?page=${page}&query=${query}&category=${category}&subCategory=${subCategory}&order=${order}&HF=${HF}&HT=${HT}&WF=${WF}&WT=${WT}&LF=${LF}&LT=${LT}`
     124        );
     125        dispatch({ type: "FETCH_SUCCESS", payload: data });
     126      } catch (err) {
     127        dispatch({ type: "FETCH_FAIL", payload: getError(err) });
     128      }
     129    };
     130    fetchData();
    75131  };
    76132
     
    124180            >
    125181              <Form
     182                onSubmit={filterHandler}
    126183                style={{
    127184                  width: "100%",
    128185                  display: "flex",
    129                   justifyContent: "end",
     186                  justifyContent: "space-around",
    130187                  marginRight: "40px",
    131188                  alignItems: "center",
    132189                }}
    133190              >
     191                <Form.Group style={{ display: "flex", alignItems: "center" }}>
     192                  <Form.Label style={{ margin: "0px" }}>H:</Form.Label>
     193                  <Form.Control
     194                    style={{ width: "60px" }}
     195                    id="HF"
     196                    //onChange={(e) => setHF(e.target.value)}
     197                  />
     198                  <Form.Label style={{ margin: "0px" }}>-</Form.Label>
     199                  <Form.Control
     200                    style={{ width: "60px" }}
     201                    id="HT"
     202                    //onChange={(e) => setHT(e.target.value)}
     203                  />
     204                </Form.Group>
     205                <Form.Group style={{ display: "flex", alignItems: "center" }}>
     206                  <Form.Label style={{ margin: "0px" }}>W:</Form.Label>
     207                  <Form.Control
     208                    style={{ width: "60px" }}
     209                    id="WF"
     210                    //onChange={(e) => setWF(e.target.value)}
     211                  />
     212                  <Form.Label style={{ margin: "0px" }}>-</Form.Label>
     213                  <Form.Control
     214                    style={{ width: "60px" }}
     215                    id="WT"
     216                    //onChange={(e) => setWT(e.target.value)}
     217                  />
     218                </Form.Group>
     219                <Form.Group style={{ display: "flex", alignItems: "center" }}>
     220                  <Form.Label style={{ margin: "0px" }}>L:</Form.Label>
     221                  <Form.Control
     222                    id="LF"
     223                    style={{ width: "60px" }}
     224                    //onChange={(e) => setLF(e.target.value)}
     225                  />
     226                  <Form.Label style={{ margin: "0px" }}>-</Form.Label>
     227                  <Form.Control
     228                    id="LT"
     229                    style={{ width: "60px" }}
     230                    //onChange={(e) => setLT(e.target.value)}
     231                  />
     232                </Form.Group>
    134233                {/*}
    135234                <Form.Group>
     
    292391                    <option value={"highFirst"}>Од висока кон ниска</option>
    293392                  </Form.Select>
     393                </Form.Group>
     394                <Form.Group>
     395                  <Button variant="danger" size="lg" type="submit">
     396                    Филтрирај
     397                  </Button>
    294398                </Form.Group>
    295399              </Form>
Note: See TracChangeset for help on using the changeset viewer.