Changeset e5b84dc for phonelux-frontend/src
- Timestamp:
- 09/11/22 18:03:58 (2 years ago)
- Branches:
- master
- Children:
- 775e15e
- Parents:
- 527b93f
- Location:
- phonelux-frontend/src
- Files:
-
- 5 added
- 2 deleted
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
phonelux-frontend/src/App.js
r527b93f re5b84dc 1 1 import { BrowserRouter, Routes, Route } from "react-router-dom"; 2 2 import './App.css'; 3 import GroupedFiltersComponent from "./components/GroupedFiltersComponent/GroupedFiltersComponent";4 import HeaderComponent from "./components/HeaderComponent/HeaderComponent";5 import InputFormComponent from "./components/LoginRegisterComponents/InputFormComponent";6 import LoginFormComponent from "./components/LoginRegisterComponents/LoginFormComponent";7 import RegisterFormComponent from "./components/LoginRegisterComponents/RegisterFormComponent";8 import PaginationComponent from "./components/PaginationComponent/PaginationComponent"9 import PhoneCardComponent from "./components/PhoneCardComponent/PhoneCardComponent";10 import PhoneCardGridComponent from "./components/PhoneCardGridComponent/PhoneCardGridComponent";11 3 import HomepageComponent from "./components/HomepageComponent" 12 4 import PhonePageComponent from "./components/PhonePageComponent"; 13 import SortByComponent from "./components/FiltersComponents/SortByComponent";14 5 import LoginPageComponent from "./components/LoginPageComponent" 15 6 import RegisterPageComponent from "./components/RegisterPageComponent"; 7 import PhoneOfferDetailsComponent from "./components/PhoneOfferDetailsComponent/PhoneOfferDetailsComponent"; 8 16 9 17 10 … … 21 14 <BrowserRouter> 22 15 <Routes> 23 {/* { <Route path="/" element={<PhoneCardComponent24 image_url='https://admin.ledikom.mk/uploads/items/411/1641668143apple-iphone-13-pro-max-1-250x300-pad.jpg?v=1'25 model='Apple iPhone 13 Pro Max' price='75000'/>}/> } */}26 16 <Route path="/" element={<HomepageComponent/>}/> 27 17 <Route path="/login" element={<LoginPageComponent/>}/> 28 18 <Route path="/register" element={<RegisterPageComponent/>}/> 29 19 <Route path="/phones/:phoneId" element={<PhonePageComponent/>} /> 20 <Route path="/phoneoffer/:offerId" element={<PhoneOfferDetailsComponent/>} /> 30 21 31 22 </Routes> -
phonelux-frontend/src/components/FiltersComponents/FilterPriceComponent.js
r527b93f re5b84dc 18 18 19 19 componentDidMount(){ 20 21 20 22 21 axios.get('/lowestPrice') -
phonelux-frontend/src/components/FiltersComponents/SortByComponent.css
r527b93f re5b84dc 10 10 width: 15%; 11 11 background-color: #e6f8ef; 12 margin-right: 15px; 12 13 } -
phonelux-frontend/src/components/GroupedFiltersComponent/GroupedFiltersComponent.js
r527b93f re5b84dc 21 21 } 22 22 23 24 componentDidMount(){25 26 }27 23 28 24 render() { -
phonelux-frontend/src/components/HeaderComponent/HeaderComponent.css
r527b93f re5b84dc 8 8 width: 310px; 9 9 height: 200px; 10 margin-top: -65px; 10 11 } 12 13 .homepage-navbar-component{ 14 width: 100%; 15 display: flex; 16 justify-content: end; 17 background-color: #B6E2C8; 18 } -
phonelux-frontend/src/components/HeaderComponent/HeaderComponent.js
r527b93f re5b84dc 2 2 import { Link } from 'react-router-dom' 3 3 import logo from '../../images/logo_phonelux.png' 4 import NavbarComponent from '../NavbarComponent/NavbarComponent' 4 5 import './HeaderComponent.css' 5 6 … … 7 8 render() { 8 9 return ( 10 <> 11 <div className='homepage-navbar-component'> 12 <NavbarComponent/> 13 </div> 9 14 <div className='header-component'> 10 15 <Link style={{ textDecoration: 'none' }} to={"/"}> … … 12 17 </Link> 13 18 </div> 19 </> 14 20 ) 15 21 } -
phonelux-frontend/src/components/HomepageComponent.js
r527b93f re5b84dc 3 3 import HeaderComponent from './HeaderComponent/HeaderComponent' 4 4 import PhoneCardGridComponent from './PhoneCardGridComponent/PhoneCardGridComponent' 5 5 6 6 7 export class HomepageComponent extends Component { … … 10 11 11 12 this.state = { 12 shops: null,13 brands: null,14 priceRange: null,15 searchValue: null,16 sortBy: null13 shops: '', 14 brands: '', 15 priceRange: '', 16 searchValue: '', 17 sortBy: 'mostPopular' 17 18 } 18 19 } … … 46 47 searchValue: e.searchValue 47 48 }) 49 48 50 } 49 51 … … 56 58 } 57 59 60 58 61 render() { 59 62 return ( … … 61 64 <HeaderComponent/> 62 65 <GroupedFiltersComponent passFilters={this.changeFilters}/> 63 <PhoneCardGridComponent />66 <PhoneCardGridComponent {...this.state}/> 64 67 </> 65 68 ) -
phonelux-frontend/src/components/LoginRegisterComponents/LoginFormComponent.css
r527b93f re5b84dc 16 16 width: fit-content; 17 17 box-shadow: 11px 12px 13px 12px rgb(207, 207, 207); 18 padding-top: 30px;18 padding-top: 20px; 19 19 border-radius: 60px; 20 20 background-color: white; … … 23 23 } 24 24 .loginform-imgs-div { 25 padding-top: 20px;25 padding-top: 10px; 26 26 justify-content: center; 27 27 display: flex; … … 43 43 44 44 .loginform-sub-main-div > div{ 45 margin-bottom: 50px;45 margin-bottom: 30px; 46 46 margin-left: 80px; 47 47 margin-right: 80px; … … 137 137 color: blue; 138 138 } 139 .register-link > a{ 140 color: rgb(53, 99, 70); 141 text-decoration: none; 139 140 141 142 .registerform-link{ 143 color: rgb(53, 99, 70); 144 text-decoration: none; 142 145 } 143 146 144 .register -link > a:hover{145 color: blue;147 .registerform-link:hover{ 148 color: blue; 146 149 } 150 151 .loginform-message-wrapper{ 152 display: flex; 153 justify-content: center; 154 } 155 156 .loginform-error-message{ 157 color: red; 158 border: 1px solid red; 159 width: fit-content; 160 padding: 10px; 161 border-radius: 50px; 162 background-color: rgb(251, 224, 224); 163 } -
phonelux-frontend/src/components/LoginRegisterComponents/LoginFormComponent.js
r527b93f re5b84dc 17 17 email: '', 18 18 password: '', 19 serverResponse: '' 19 20 } 20 21 } … … 42 43 43 44 axios(config) 44 .then(function (response) { 45 console.log(response.data); 45 .then((response) => { 46 // store access token in local storage, redirect to homepage 47 console.log(response.data) 46 48 }) 47 .catch(function (error) { 48 console.log(error); 49 .catch((error) => { 50 this.setState({ 51 serverResponse: 'error' 52 }) 49 53 }); 50 54 … … 67 71 <div className="loginform-sub-main-div"> 68 72 <div> 69 73 {this.state.serverResponse == 'error' ? <div className='loginform-message-wrapper'> 74 <h5 className='loginform-error-message'>Невалидна е-маил адреса или лозинка!</h5></div> : <></>} 70 75 <div className="loginform-imgs-div"> 71 76 <div className="loginform-image-container"> … … 93 98 </div> 94 99 </form> 95 <p className='register-link'><Link to={"/register"}><a>Регистрирај се</a></Link></p>100 <p className='register-link'><Link className='registerform-link' to={"/register"}>Регистрирај се</Link></p> 96 101 97 102 </div> -
phonelux-frontend/src/components/LoginRegisterComponents/RegisterFormComponent.css
r527b93f re5b84dc 23 23 } 24 24 .registerform-imgs-div { 25 padding-top: 20px;25 padding-top: 5px; 26 26 justify-content: center; 27 27 display: flex; … … 158 158 } 159 159 160 .registerform-message-wrapper{ 161 display: flex; 162 justify-content: center; 163 } 164 165 .registerform-error-message{ 166 color: red; 167 border: 1px solid red; 168 width: fit-content; 169 padding: 10px; 170 border-radius: 50px; 171 background-color: rgb(251, 224, 224); 172 } 173 174 .registerform-success-message{ 175 color: green; 176 border: 1px solid green; 177 width: fit-content; 178 padding: 10px; 179 border-radius: 50px; 180 background-color: #B6E2C8; 181 } 160 182 161 183 -
phonelux-frontend/src/components/LoginRegisterComponents/RegisterFormComponent.js
r527b93f re5b84dc 20 20 password: '', 21 21 confirmPassword:'', 22 serverResponse: '' 22 23 } 23 24 } … … 43 44 44 45 axios(config) 45 .then(function (response) { 46 console.log(response); 46 .then((response) => { 47 this.setState({ 48 serverResponse: response.data 49 }) 47 50 }) 48 .catch(function (error) { 49 console.log(error); 51 .catch((error) => { 52 this.setState({ 53 serverResponse: error.response.data 54 }) 50 55 }); 51 56 … … 59 64 60 65 61 62 63 66 render() { 64 67 … … 69 72 <div className="registerform-sub-main-div"> 70 73 <div> 74 75 {(() => { 76 if(this.state.serverResponse == '') 77 { 78 return <></> 79 } 80 81 if(this.state.serverResponse != '' && this.state.serverResponse.includes('Error')) 82 { 83 return <div className='registerform-message-wrapper'> 84 <h5 className='registerform-error-message'>{this.state.serverResponse.split(':')[1]}</h5> </div> 85 } 86 87 if(this.state.serverResponse != '' && this.state.serverResponse.includes('token')) 88 { 89 return <div className='registerform-message-wrapper'> 90 <h5 className='registerform-success-message'>Вашата регистрација е во тек. Потврдете на вашата е-маил адреса!</h5> </div> 91 } 92 93 })()} 71 94 72 95 <div className="registerform-imgs-div"> -
phonelux-frontend/src/components/PhoneCardComponent/PhoneCardComponent.css
r527b93f re5b84dc 1 1 .phonecard{ 2 background-color: #B6E2C8;2 /* background-color: #B6E2C8; */ 3 3 padding:15px; 4 4 justify-items: center; 5 padding-top: 35px; 5 6 width: 250px; 6 7 height: 400px; 7 8 border-radius: 25px; 9 border: 3px solid #B6E2C8; 10 border-radius: 50px; 8 11 } 9 12 10 13 .phonecard:hover{ 11 background-color: #84c69f;14 /* background-color: #B6E2C8; */ 12 15 cursor: pointer; 16 box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19); 17 transition: box-shadow 0.5s, background-color 0.5s ; 18 border-radius: 50px; 13 19 } 14 20 … … 26 32 27 33 .phonecard-lowestprice-header, .phonecard-totaloffers-header{ 28 margin-top: -10px; 29 color: rgb(34, 106, 106); 30 text-align: center; 34 margin-top: 20px; 35 text-align: right; 36 } 37 38 .phonecard-totaloffers-header{ 39 margin-top: -15px; 31 40 } 32 41 33 42 .phonecard-model-header{ 34 43 text-align: center; 44 border: 1px solid rgb(161, 165, 163); 45 border-radius: 20px 100px; 46 background-color: rgb(222, 228, 225); 47 padding: 5px; 48 padding-right: 10px; 49 35 50 } 36 51 … … 44 59 } 45 60 61 .phonecard-lowestprice-header{ 62 /* color: rgb(24, 117, 24); */ 63 } 64 65 .phonecard-totaloffers-header{ 66 /* color: rgb(24, 117, 24); */ 67 } 68 46 69 .phonecard > h5 > p{ 47 70 display: inline; -
phonelux-frontend/src/components/PhoneCardComponent/PhoneCardComponent.js
r527b93f re5b84dc 24 24 <h3 className='phonecard-model-header'>{this.props.model}</h3> 25 25 <h5 className='phonecard-lowestprice-header'>Најниска цена: <p className='phonecard-lowestprice'>{this.props.lowestPrice}</p> ден.</h5> 26 <h 6 className='phonecard-totaloffers-header'>Вкупно понуди: <p className='phonecard-totaloffers'>{this.props.total_offers}</p></h6>26 <h5 className='phonecard-totaloffers-header'>Вкупно понуди: <p className='phonecard-totaloffers'>{this.props.total_offers}</p></h5> 27 27 </div> 28 28 </Paper> -
phonelux-frontend/src/components/PhoneCardGridComponent/PhoneCardGridComponent.css
r527b93f re5b84dc 15 15 } 16 16 17 .pagination-wrapper{ 18 margin-top: 40px; 19 padding-bottom: 40px; 20 display: flex; 21 justify-content: center; 22 } 17 23 24 25 -
phonelux-frontend/src/components/PhoneCardGridComponent/PhoneCardGridComponent.js
r527b93f re5b84dc 1 import { Grid } from '@mui/material'1 import { Grid, Pagination } from '@mui/material' 2 2 import axios from 'axios' 3 3 import React, { Component } from 'react' 4 import PaginationComponent from '../PaginationComponent/PaginationComponent'5 4 import '../PhoneCardComponent/PhoneCardComponent' 6 5 import PhoneCardComponent from '../PhoneCardComponent/PhoneCardComponent' … … 15 14 this.state = { 16 15 phones: [], 17 loading: true,18 16 currentPage: 1, 19 17 phonesPerPage: 12, … … 24 22 } 25 23 24 componentDidUpdate(prevProps) { 25 if(JSON.stringify(prevProps) != JSON.stringify(this.props)){ 26 let filters = '?' 27 28 if(this.props.shops) 29 { 30 filters += 'shops='+this.props.shops+'&' 31 } 32 if(this.props.brands) 33 { 34 filters += 'brands='+this.props.brands+'&' 35 } 36 if(this.props.priceRange) 37 { 38 filters += 'priceRange='+this.props.priceRange+'&' 39 } 40 if(this.props.searchValue) 41 { 42 filters += 'searchValue='+this.props.searchValue+'&' 43 } 44 45 if(this.props.sortBy) 46 { 47 filters += 'sortBy='+this.props.sortBy+'&' 48 } 49 50 axios.get('/phones'+filters) 51 .then(response => { 52 this.setState({ 53 phones: response.data, 54 numberOfPages: Math.ceil(response.data.length / this.state.phonesPerPage) 55 },(e) => this.setNewPage(e,this.state.currentPage)) 56 } 57 ) 58 .catch(error => console.log(error)) 59 console.log(filters) 60 } 61 } 62 26 63 componentDidMount() { 27 28 64 axios.get('/phones') 29 65 .then(response => { 30 66 this.setState({ 31 67 phones: response.data, 32 loading: false,33 68 numberOfPages: Math.ceil(response.data.length / this.state.phonesPerPage) 34 },( ) => this.setNewPage(this.state.currentPage))69 },(e) => this.setNewPage(e,this.state.currentPage)) 35 70 } 36 71 ) … … 38 73 } 39 74 40 setNewPage = (newPage) => {41 if(newPage == '')42 {43 newPage = this.state.currentPage-144 }45 75 46 if(newPage == '') 47 { 48 newPage = this.state.currentPage+1 49 } 76 setNewPage = (event,page) => { 50 77 51 52 const indexOfLastPhone = parseInt(newPage) * this.state.phonesPerPage; 78 const indexOfLastPhone = parseInt(page) * this.state.phonesPerPage; 53 79 const indexOfFirstPhone = indexOfLastPhone - this.state.phonesPerPage; 54 80 … … 56 82 57 83 this.setState({ 58 currentPage: parseInt( newPage),84 currentPage: parseInt(page), 59 85 currentPhones: currPhones 60 86 }) … … 63 89 64 90 render() { 91 65 92 return ( 66 93 <div className='phonecardgrid-wrapper'> … … 71 98 spacing={2}> 72 99 73 {this.state.currentPhones.map((phone ) => <GridclassName='phonecardgrid-item' item md={3}>74 <PhoneCardComponent key={phone.id}id={phone.id} brand={phone.brand}100 {this.state.currentPhones.map((phone,idx) => <Grid key={idx} className='phonecardgrid-item' item md={3}> 101 <PhoneCardComponent id={phone.id} brand={phone.brand} 75 102 model={phone.model} image_url={phone.image_url == null ? phoneImage : phone.image_url} total_offers={phone.total_offers} lowestPrice={phone.lowestPrice}/></Grid>)} 76 103 77 {/* <Grid item xs={12} md={12}>78 <PaginationComponent79 currentPage={this.state.currentPage}80 changePageHandler={this.setNewPage}81 numberOfPages={this.state.numberOfPages} />82 </Grid> */}83 104 </Grid> 84 <PaginationComponent 85 currentPage={this.state.currentPage} 86 changePageHandler={this.setNewPage} 87 numberOfPages={this.state.numberOfPages} /> 105 106 <div className='pagination-wrapper'> 107 <Pagination className='paginationcomponent-pagination' onChange={this.setNewPage} page={this.state.currentPage} 108 count={this.state.numberOfPages} color="primary" /> 109 </div> 110 88 111 </div> 89 112 ) -
phonelux-frontend/src/components/PhoneOfferComponent/PhoneOfferComponent.css
r527b93f re5b84dc 1 .phone-with-offers-table-row{ 2 font-size: 18px; 3 } 4 5 .phone-with-offers-table-row > td:first-of-type { 6 font-weight: bold; 7 } 8 9 .phone-offer-specifications-button{ 10 font-size: 17px; 11 padding: 10px; 12 background-color: #B6E2C8; 13 border-radius: 20px; 14 border: 1px solid black; 15 } 16 17 .phone-with-offers-table-row td:last-of-type{ 18 display: flex; 19 justify-content: center; 20 flex-wrap: wrap; 21 } 22 23 .phone-offer-specifications-button:hover{ 24 cursor: pointer; 25 background-color: rgb(166, 201, 171); 26 box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19); 27 transition: box-shadow 0.5s, background-color 0.5s ; 28 } -
phonelux-frontend/src/components/PhoneOfferComponent/PhoneOfferComponent.js
r527b93f re5b84dc 1 1 import React, { Component } from 'react' 2 import { Link } from 'react-router-dom' 3 import './PhoneOfferComponent.css' 2 4 3 5 export class PhoneOfferComponent extends Component { … … 13 15 14 16 render() { 15 console.log(this.props)17 // console.log(this.props) 16 18 return ( 17 19 <tr className='phone-with-offers-table-row'> 18 20 <td>{this.props.offer_shop}</td> 19 <td><a href={this.props.offer_url}>{this.props.offer_name}</a></td>21 <td><a style={{ textDecoration: 'none' }} href={this.props.offer_url}>{this.props.offer_name}</a></td> 20 22 <td>{this.props.price} ден.</td> 21 <td></td> 23 <td> 24 <Link style={{ textDecoration: 'none' }} to={"/phoneoffer/"+this.props.id}> 25 <button className='phone-offer-specifications-button'>Спецификации</button> 26 </Link> 27 </td> 22 28 </tr> 23 29 ) … … 27 33 export default PhoneOfferComponent 28 34 29 30 31 32 // back_camera: null33 // battery: null34 // chipset: null35 // color: null36 // cpu: null37 // front_camera: null38 // id: 48639 // image_url: "https://setec.mk/image/cache/catalog/Product/51841_0-228x228.jpg"40 // is_validated: false41 // last_updated: "2022-07-26T22:00:00.000+00:00"42 // offer_description: "Apple iPhone 13 128GB Midnight, GSM/CDMA/HSPA/EVDO/LTE/ 5G, Display: Super Retina XDR OLED; HDR10; Dolby Vision; 800 nits (HBM); 1200 nit…"43 // offer_name: "Apple iPhone 13 128GB Midnight"44 // offer_shop: "Setec"45 // offer_shop_code: "51841"46 // offer_url: "https://setec.mk/index.php?route=product/product&path=10066_10067&product_id=51841"47 // operating_system: null48 // price: 6399049 // ram_memory: null50 // rom_memory: null -
phonelux-frontend/src/components/PhoneWithOffersComponent/PhoneWithOffersComponent.css
r527b93f re5b84dc 23 23 24 24 .phone-with-offers-table-row:nth-of-type(even){ 25 background-color: # DEE4E1;25 background-color: #eef2f0; 26 26 } 27 27 … … 51 51 font-size: 22px; 52 52 } 53 54 .phone-with-offers-model-header{ 55 border: 1px solid gray; 56 padding: 10px; 57 padding-left: 50px; 58 padding-right: 50px; 59 border-radius: 10px 60px; 60 box-shadow: inset 0px 0px 25px 0px rgb(120, 190, 139); 61 outline: none; 62 background-color: #c4f3d8; 63 } 64 65 .phone-with-offers-totaloffers-header{ 66 padding: 10px; 67 border: 1px solid rgb(199, 193, 193); 68 background-color: #B6E2C8; 69 border-radius: 50px; 70 } -
phonelux-frontend/src/components/PhoneWithOffersComponent/PhoneWithOffersComponent.js
r527b93f re5b84dc 31 31 <div className='phone-with-offers-sub-main'> 32 32 <div className='phone-with-offers-totaloffers-div'> 33 <h3 >Понуди: {this.props.total_offers}</h3>33 <h3 className='phone-with-offers-totaloffers-header'>Понуди: {this.props.total_offers}</h3> 34 34 </div> 35 35 … … 41 41 42 42 <div className='phone-with-offers-model-wrapper'> 43 <h1 >{this.props.model}</h1>43 <h1 className='phone-with-offers-model-header'>{this.props.model}</h1> 44 44 </div> 45 45 </div> … … 58 58 <tbody> 59 59 { 60 this.state.phone_offers.map((offer ) => <PhoneOfferComponent key={offer.offer_id} id={offer.id}60 this.state.phone_offers.map((offer,idx) => <PhoneOfferComponent key={idx} id={offer.id} 61 61 is_validated={offer.is_validated} offer_shop={offer.offer_shop} offer_name={offer.offer_name} 62 62 price={offer.price} offer_url={offer.offer_url} -
phonelux-frontend/src/index.js
r527b93f re5b84dc 4 4 import App from './App'; 5 5 import reportWebVitals from './reportWebVitals'; 6 import Data from './components/DataManager'; 6 7 8 window.Data = Data; 7 9 const root = ReactDOM.createRoot(document.getElementById('root')); 8 10 root.render(
Note:
See TracChangeset
for help on using the changeset viewer.