Changeset 7e88e46 for phonelux-frontend/src/components/PhoneOfferComponent
- Timestamp:
- 09/17/22 01:24:24 (2 years ago)
- Branches:
- master
- Children:
- 5201690
- Parents:
- 775e15e
- Location:
- phonelux-frontend/src/components/PhoneOfferComponent
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.