Changeset a2e5735 for frontend/src/screens
- Timestamp:
- 12/13/22 22:38:11 (2 years ago)
- Branches:
- master
- Parents:
- 113029b
- Location:
- frontend/src/screens
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/screens/AdminAddProductScreen.js
r113029b ra2e5735 20 20 const [dimension, setDimension] = useState(""); 21 21 const [scheme, setScheme] = useState(""); 22 const [H, setH] = useState(""); 23 const [W, setW] = useState(""); 24 const [L, setL] = useState(""); 22 25 const [message, setMessage] = useState(""); 23 26 … … 56 59 formData.append("dimension", dimension); 57 60 formData.append("scheme", scheme); 58 61 formData.append("H", H); 62 formData.append("W", W); 63 formData.append("L", L); 59 64 try { 60 65 const result = await axios.post("/api/products/add", formData); … … 76 81 Додади нов производ 77 82 </div> 83 </Link> 84 <Link 85 to={"/admin/addCategory"} 86 style={{ textDecoration: "none", width: "100%" }} 87 > 88 <div className="dashboard-btn">Додади категорија</div> 78 89 </Link> 79 90 <Link … … 351 362 </div> 352 363 <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> 353 419 <Form.Group> 354 420 <Form.Label>Слика со димензии</Form.Label> -
frontend/src/screens/AdminDashboardScreen.js
r113029b ra2e5735 6 6 import { useNavigate, Link } from "react-router-dom"; 7 7 import ListProducts from "../components/ListProducts"; 8 import { Helmet } from "react-helmet-async"; 8 9 9 10 function AdminDashboardScreen() { … … 19 20 return ( 20 21 <div id="pgContainer"> 22 <Helmet> 23 <title>Dashboard</title> 24 </Helmet> 21 25 <div id="sidebarMenu"> 22 26 <Link … … 27 31 Додади нов производ 28 32 </div> 33 </Link> 34 <Link 35 to={"/admin/addCategory"} 36 style={{ textDecoration: "none", width: "100%" }} 37 > 38 <div className="dashboard-btn">Додади категорија</div> 29 39 </Link> 30 40 <Link -
frontend/src/screens/AdminEditProductScreen.js
r113029b ra2e5735 83 83 Додади нов производ 84 84 </div> 85 </Link> 86 <Link 87 to={"/admin/addCategory"} 88 style={{ textDecoration: "none", width: "100%" }} 89 > 90 <div className="dashboard-btn">Додади категорија</div> 85 91 </Link> 86 92 <Link -
frontend/src/screens/AdminOrdersScreen.js
r113029b ra2e5735 82 82 Додади нов производ 83 83 </div> 84 </Link> 85 <Link 86 to={"/admin/addCategory"} 87 style={{ textDecoration: "none", width: "100%" }} 88 > 89 <div className="dashboard-btn">Додади категорија</div> 84 90 </Link> 85 91 <Link -
frontend/src/screens/AdminProductsScreen.js
r113029b ra2e5735 96 96 Додади нов производ 97 97 </div> 98 </Link> 99 <Link 100 to={"/admin/addCategory"} 101 style={{ textDecoration: "none", width: "100%" }} 102 > 103 <div className="dashboard-btn">Додади категорија</div> 98 104 </Link> 99 105 <Link -
frontend/src/screens/CategoryScreen.js
r113029b ra2e5735 1 import React, { useEffect, useReducer } from "react";1 import React, { useEffect, useReducer, useState } from "react"; 2 2 import "../styles/Home.css"; 3 3 // import data from "./data"; … … 34 34 const params = useParams(); 35 35 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); 36 47 const navigate = useNavigate(); 37 48 const { search } = useLocation(); … … 43 54 const order = sp.get("order") || "newest"; 44 55 const page = sp.get("page") || 1; 45 46 56 const [{ loading, error, products, pages, countProducts }, dispatch] = 47 57 useReducer(reducer, { loading: true, error: "" }); … … 56 66 );*/ 57 67 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}` 59 69 ); 60 70 dispatch({ type: "FETCH_SUCCESS", payload: data }); … … 64 74 }; 65 75 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 ]); 67 90 68 91 const getFilterUrl = (filter) => { … … 72 95 const filterSubCategory = filter.subCategory || subCategory; 73 96 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}<=${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}` 124 ); 125 dispatch({ type: "FETCH_SUCCESS", payload: data }); 126 } catch (err) { 127 dispatch({ type: "FETCH_FAIL", payload: getError(err) }); 128 } 129 }; 130 fetchData(); 75 131 }; 76 132 … … 124 180 > 125 181 <Form 182 onSubmit={filterHandler} 126 183 style={{ 127 184 width: "100%", 128 185 display: "flex", 129 justifyContent: " end",186 justifyContent: "space-around", 130 187 marginRight: "40px", 131 188 alignItems: "center", 132 189 }} 133 190 > 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> 134 233 {/*} 135 234 <Form.Group> … … 292 391 <option value={"highFirst"}>Од висока кон ниска</option> 293 392 </Form.Select> 393 </Form.Group> 394 <Form.Group> 395 <Button variant="danger" size="lg" type="submit"> 396 Филтрирај 397 </Button> 294 398 </Form.Group> 295 399 </Form>
Note:
See TracChangeset
for help on using the changeset viewer.