Changeset 7e88e46 for phonelux-frontend/src/components
- Timestamp:
- 09/17/22 01:24:24 (2 years ago)
- Branches:
- master
- Children:
- 5201690
- Parents:
- 775e15e
- Location:
- phonelux-frontend/src/components
- Files:
-
- 10 added
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
phonelux-frontend/src/components/FiltersComponents/SearchFieldComponent.js
r775e15e r7e88e46 7 7 import IconButton from '@mui/material/IconButton'; 8 8 import Typography from '@mui/material/Typography'; 9 import InputBase from '@mui/material/InputBase';10 9 import Badge from '@mui/material/Badge'; 11 10 import MenuItem from '@mui/material/MenuItem'; 12 11 import Menu from '@mui/material/Menu'; 13 12 import MenuIcon from '@mui/icons-material/Menu'; 13 import InputBase from '@mui/material/InputBase'; 14 14 import SearchIcon from '@mui/icons-material/Search'; 15 15 import AccountCircle from '@mui/icons-material/AccountCircle'; -
phonelux-frontend/src/components/HeaderComponent/HeaderComponent.css
r775e15e r7e88e46 9 9 height: 200px; 10 10 margin-top: -65px; 11 cursor: pointer; 11 12 } 12 13 -
phonelux-frontend/src/components/HeaderComponent/HeaderComponent.js
r775e15e r7e88e46 6 6 7 7 export default class HeaderComponent extends Component { 8 9 10 redirectToHomepage = () =>{ 11 window.location.href = "/" 12 } 8 13 render() { 9 14 return ( … … 13 18 </div> 14 19 <div className='header-component'> 15 <Link style={{ textDecoration: 'none' }} to={"/"}>16 <img src={logo}></img>17 </Link>20 {/* <Link style={{ textDecoration: 'none' }} to={"/"}> */} 21 <img className='phonelux-logo' onClick={this.redirectToHomepage} src={logo}></img> 22 {/* </Link> */} 18 23 </div> 19 24 </> -
phonelux-frontend/src/components/HomepageComponent.js
r775e15e r7e88e46 1 1 import React, { Component } from 'react' 2 import UserContext from '../context/UserContext' 2 3 import GroupedFiltersComponent from './GroupedFiltersComponent/GroupedFiltersComponent' 3 4 import HeaderComponent from './HeaderComponent/HeaderComponent' … … 49 50 50 51 } 51 52 52 53 if(e.hasOwnProperty('sortBy')) 53 54 { … … 60 61 61 62 render() { 63 console.log(this.context) 64 console.log(localStorage.getItem('token')) 62 65 return ( 63 66 <> … … 70 73 } 71 74 75 HomepageComponent.contextType = UserContext 76 77 72 78 export default HomepageComponent -
phonelux-frontend/src/components/LoginRegisterComponents/LoginFormComponent.js
r775e15e r7e88e46 6 6 import { Link } from 'react-router-dom'; 7 7 import axios from 'axios'; 8 9 10 8 11 9 export class LoginFormComponent extends Component { … … 44 42 axios(config) 45 43 .then((response) => { 44 const {access_token} = response.data 46 45 // store access token in local storage, redirect to homepage 47 console.log(response.data) 46 localStorage.setItem('token', access_token) 47 window.location.href="/" 48 48 }) 49 49 .catch((error) => { … … 64 64 65 65 render() { 66 67 const {email,password} = this.state68 66 69 67 return ( … … 108 106 } 109 107 108 110 109 export default LoginFormComponent -
phonelux-frontend/src/components/NavbarComponent/NavbarComponent.css
r775e15e r7e88e46 9 9 } 10 10 11 .navbar-logout-box-icon{ 12 font-size: 40px; 13 margin-top: 10px; 14 } 15 11 16 .navbar-account-box-icon:hover{ 12 17 cursor: pointer; 13 18 } 14 19 20 .navbar-logout-box-icon:hover{ 21 cursor: pointer; 22 } 15 23 16 /* style={{ fontSize: '50px', marginTop: '10px' }} */ 24 .navbar-favouriteoffers-icon:hover{ 25 cursor: pointer; 26 } 27 28 .navbar-superadmin-icon:hover{ 29 cursor: pointer; 30 } 31 -
phonelux-frontend/src/components/NavbarComponent/NavbarComponent.js
r775e15e r7e88e46 8 8 import PersonIcon from '@mui/icons-material/Person'; 9 9 import LogoutIcon from '@mui/icons-material/Logout'; 10 import StarsIcon from '@mui/icons-material/Stars'; 11 import UserContext from '../../context/UserContext'; 12 import SupervisorAccountIcon from '@mui/icons-material/SupervisorAccount'; 10 13 11 14 export class NavbarComponent extends Component { … … 15 18 16 19 this.state = { 17 profileSectionOpen: false20 18 21 } 22 } 23 24 logOut = () => { 25 localStorage.clear() 26 window.location.href = "/" 19 27 } 20 28 … … 22 30 return ( 23 31 <div className='phonelux-navbar'> 32 { 33 localStorage.getItem('token') && this.context.role == 'SUPERADMIN' ? 34 <Tippy placement='bottom' content='Менаџмент со корисници'> 35 <Link style={{color: 'black'}} to={"/management/users"}> 36 <SupervisorAccountIcon style={{fontSize: '40px', marginTop: '10px', marginRight: '10px' }} className='navbar-superadmin-icon'/> 37 </Link> 38 </Tippy> : <></> 39 } 40 { 41 localStorage.getItem('token') ? 42 <Tippy placement='bottom' content='Омилени понуди'> 43 <Link style={{color: 'black'}} to={"/user/"+this.context.userId+"/favouriteoffers"}> 44 <StarsIcon style={{fontSize: '40px', marginTop: '10px', marginRight: '10px' }} className='navbar-favouriteoffers-icon'/> 45 </Link> 46 </Tippy> : <></> 47 } 48 49 { localStorage.getItem('token') ? 50 <Tippy placement='bottom' content='Одјави се'> 51 <LogoutIcon onClick={this.logOut} style={{fontSize: '40px', marginTop: '10px' }} className='navbar-logout-box-icon'/> 52 </Tippy> 53 : 24 54 <Tippy placement='bottom' content='Најави се'> 25 55 <Link style={{color: 'black'}} to={"/login"}> <PersonIcon style={{fontSize: '50px', marginTop: '10px' }} className='navbar-account-box-icon'/></Link> 26 56 </Tippy> 57 } 27 58 28 {/* favourite offers icon goes here */}29 59 30 60 </div> … … 33 63 } 34 64 65 NavbarComponent.contextType = UserContext 66 35 67 export default NavbarComponent -
phonelux-frontend/src/components/PhoneOfferComponent/PhoneOfferComponent.css
r775e15e r7e88e46 27 27 transition: box-shadow 0.5s, background-color 0.5s ; 28 28 } 29 30 .phone-offer-favouriteoffer-icon:hover{ 31 cursor: pointer; 32 } 33 34 .phone-offer-cheaperoffers-icon{ 35 cursor: pointer; 36 } -
phonelux-frontend/src/components/PhoneOfferComponent/PhoneOfferComponent.js
r775e15e r7e88e46 2 2 import { Link } from 'react-router-dom' 3 3 import './PhoneOfferComponent.css' 4 import StarBorderIcon from '@mui/icons-material/StarBorder'; 5 import StarIcon from '@mui/icons-material/Star'; 6 import Tippy from '@tippyjs/react'; 7 import axios from 'axios'; 8 import UserContext from '../../context/UserContext'; 9 import VisibilityIcon from '@mui/icons-material/Visibility'; 10 import CheckIcon from '@mui/icons-material/Check'; 4 11 5 12 export class PhoneOfferComponent extends Component { … … 12 19 } 13 20 } 21 22 addToFavourite = () => { 23 var config = { 24 method: 'put', 25 url: '/user/'+this.context.userId+'/addoffer/'+this.props.id, 26 headers: { 27 'Authorization': 'Bearer '+localStorage.getItem('token') 28 } 29 }; 30 31 axios(config) 32 .then(response => { 33 this.props.getFavouriteOffersForLoggedUser() 34 }) 35 .catch(error => { 36 console.log(error) 37 }) 38 } 39 40 removeFromFavourite = () => { 41 var config = { 42 method: 'put', 43 url: '/user/'+this.context.userId+'/removeoffer/'+this.props.id, 44 headers: { 45 'Authorization': 'Bearer '+localStorage.getItem('token') 46 } 47 }; 48 49 axios(config) 50 .then(response => { 51 this.props.getFavouriteOffersForLoggedUser() 52 }) 53 .catch(error => { 54 console.log(error); 55 }); 56 } 57 58 59 getCheaperOffers = () =>{ 60 var config = { 61 method: 'get', 62 url: '/phoneoffer/'+this.props.id+'/cheaperoffers', 63 headers: { } 64 }; 65 66 axios(config) 67 .then(response => { 68 this.props.handleOpen(response.data,this.props.price) 69 }) 70 .catch(error => { 71 console.log(error); 72 }); 73 } 14 74 15 75 16 76 render() { 17 // console.log(this.props)18 77 return ( 19 78 <tr className='phone-with-offers-table-row'> … … 22 81 <td>{this.props.price} ден.</td> 23 82 <td> 83 { 84 window.location.href.split('/')[5] == 'favouriteoffers' ? 85 <Tippy placement='bottom' content='Прикажи поевтини понуди'> 86 <VisibilityIcon onClick={this.getCheaperOffers} className='phone-offer-cheaperoffers-icon' style={{fontSize: '40px', marginRight: '10px' }}/> 87 </Tippy> : <></> 88 } 89 { 90 localStorage.getItem('token') && this.props.loggedUserFavouriteOffers.filter(offer => offer.id == this.props.id).length == 0? 91 <Tippy placement='bottom' content='Додади во омилени понуди'> 92 <StarBorderIcon onClick={this.addToFavourite} className='phone-offer-favouriteoffer-icon' style={{fontSize: '40px', marginRight: '10px' }}/> 93 </Tippy> 94 : <></> 95 } 96 97 { 98 localStorage.getItem('token') && this.props.loggedUserFavouriteOffers.filter(offer => offer.id == this.props.id).length != 0? 99 <Tippy placement='bottom' content='Избриши од омилени понуди'> 100 <StarIcon onClick={this.removeFromFavourite} className='phone-offer-favouriteoffer-icon' style={{fontSize: '40px', marginRight: '10px' }}/> 101 </Tippy> 102 : <></> 103 } 104 105 24 106 <Link style={{ textDecoration: 'none' }} to={"/phoneoffer/"+this.props.id}> 25 107 <button className='phone-offer-specifications-button'>Спецификации</button> … … 31 113 } 32 114 115 PhoneOfferComponent.contextType = UserContext 33 116 export default PhoneOfferComponent 34 117 -
phonelux-frontend/src/components/PhoneOfferDetailsComponent/PhoneOfferDetailsComponent.css
r775e15e r7e88e46 19 19 .phone-offer-details-table-row{ 20 20 border: 1px solid gainsboro; 21 22 21 } 23 22 … … 67 66 .phone-offer-details-last-updated-wrapper{ 68 67 display: flex; 68 width: 100%; 69 69 justify-content: start; 70 align-items: center; 71 } 72 73 .phone-offer-details-edit-header{ 74 width: 100%; 75 margin-left: 20px; 76 padding-top: 10px; 77 border: 1px solid black; 78 background-color: rgb(232, 243, 121); 79 border-radius: 30px; 80 text-align: center; 81 padding: 10px; 82 } 83 84 .phone-offer-details-edit-header:hover{ 85 cursor: pointer; 86 background-color: rgb(212, 219, 140); 87 box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19); 88 transition: box-shadow 0.5s, background-color 0.5s ; 89 } 90 91 .link-offer-edit{ 92 width: 15%; 93 height: fit-content; 94 text-decoration: none; 95 display: flex; 70 96 } 71 97 -
phonelux-frontend/src/components/PhoneOfferDetailsComponent/PhoneOfferDetailsComponent.js
r775e15e r7e88e46 3 3 import './PhoneOfferDetailsComponent.css' 4 4 import HeaderComponent from '../HeaderComponent/HeaderComponent' 5 import UserContext from '../../context/UserContext' 6 import { Link } from 'react-router-dom' 5 7 6 8 … … 26 28 27 29 render() { 28 console.log(this.state)29 30 return ( 30 31 <div className='phone-offer-details-main'> … … 33 34 <h3 className='phone-offer-details-last-updated-header'>Последно ажурирана: {this.state.offer == null || 34 35 this.state.offer.last_updated == null ? '#' : this.state.offer.last_updated.split('T')[0]}</h3> 36 { 37 localStorage.getItem('token') && (this.context.role == 'ADMIN' || this.context.role == 'SUPERADMIN') ? 38 <Link className='link-offer-edit' style={{color:'black'}} to={'/admin/editoffer/'+this.state.offerId}> 39 <h3 className='phone-offer-details-edit-header'>Измени понуда</h3> 40 </Link> : <></> 41 } 35 42 </div> 36 43 <div className='phone-offer-details-table-wrapper'> … … 116 123 } 117 124 125 PhoneOfferDetailsComponent.contextType = UserContext 126 118 127 export default PhoneOfferDetailsComponent -
phonelux-frontend/src/components/PhoneWithOffersComponent/PhoneWithOffersComponent.css
r775e15e r7e88e46 69 69 border-radius: 50px; 70 70 } 71 72 -
phonelux-frontend/src/components/PhoneWithOffersComponent/PhoneWithOffersComponent.js
r775e15e r7e88e46 5 5 import './PhoneWithOffersComponent.css' 6 6 import phoneImg from '../../images/phone.png' 7 import UserContext from '../../context/UserContext' 8 7 9 8 10 export class PhoneWithOffersComponent extends Component { … … 12 14 13 15 this.state = { 14 phone_offers: [] 16 phone_offers: [], 17 loggedUserFavouriteOffers: [] 15 18 } 16 19 } … … 21 24 this.setState({ 22 25 phone_offers: response.data 26 }, this.getFavouriteOffersForLoggedUser) 27 }).catch(error => console.log(error)) 28 } 29 30 getFavouriteOffersForLoggedUser = () => { 31 if(localStorage.getItem('token')) 32 { 33 var config = { 34 method: 'get', 35 url: '/user/'+this.context.userId+'/favouriteoffers', 36 headers: { 37 'Authorization': 'Bearer '+localStorage.getItem('token') 38 } 39 }; 40 41 axios(config) 42 .then(response => { 43 this.setState({ 44 loggedUserFavouriteOffers: response.data 23 45 }) 24 }).catch(error => console.log(error)) 46 }) 47 .catch(error => { 48 console.log(error); 49 }); 50 } 25 51 } 26 52 … … 60 86 this.state.phone_offers.map((offer,idx) => <PhoneOfferComponent key={idx} id={offer.id} 61 87 is_validated={offer.is_validated} offer_shop={offer.offer_shop} offer_name={offer.offer_name} 62 price={offer.price} offer_url={offer.offer_url} 88 price={offer.price} offer_url={offer.offer_url} loggedUserFavouriteOffers={this.state.loggedUserFavouriteOffers} 89 getFavouriteOffersForLoggedUser={this.getFavouriteOffersForLoggedUser} 63 90 />) 64 91 } … … 73 100 } 74 101 102 PhoneWithOffersComponent.contextType = UserContext 103 75 104 export default PhoneWithOffersComponent
Note:
See TracChangeset
for help on using the changeset viewer.