- Timestamp:
- 09/21/22 18:47:39 (2 years ago)
- Branches:
- master
- Children:
- 34950c6
- Parents:
- 5201690
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
phonelux-frontend/src/components/UserFavouriteOffersComponent/UserFavouriteOffersComponent.js
r5201690 rd66b8eb 7 7 import PhoneOfferComponent from '../PhoneOfferComponent/PhoneOfferComponent' 8 8 import CheaperOffersComponent from '../CheaperOffersComponent/CheaperOffersComponent' 9 import { wait } from '@testing-library/user-event/dist/utils' 9 10 10 11 export class UserFavouriteOffersComponent extends Component { … … 21 22 22 23 componentDidMount(){ 24 if(!localStorage.getItem('token')){ 25 window.location.href = "/" 26 } 27 23 28 this.getFavouriteOffersForLoggedUser() 24 29 } … … 27 32 var config = { 28 33 method: 'get', 29 url: '/user/'+ this.context.userId+'/favouriteoffers',34 url: '/user/'+window.location.href.split('/')[4]+'/favouriteoffers', 30 35 headers: { 31 36 'Authorization': 'Bearer '+localStorage.getItem('token') … … 59 64 60 65 render() { 61 66 // console.log(this.context) 62 67 63 68 return ( … … 71 76 <StarIcon style={{fontSize: '50px', marginTop: '20px', marginLeft: '10px'}}/> 72 77 </div> 73 <table cellPadding={20} className='phone-with-offers-table'> 74 <thead className='phone-with-offers-table-head'> 75 <tr> 76 <th>Продавница</th> 77 <th>Име на понуда</th> 78 <th>Цена</th> 79 <th></th> 80 </tr> 81 </thead> 82 <tbody> 83 { 84 this.state.userFavouriteOffers.map((offer,idx) => <PhoneOfferComponent key={idx} id={offer.id} 85 is_validated={offer.is_validated} offer_shop={offer.offer_shop} offer_name={offer.offer_name} 86 price={offer.price} offer_url={offer.offer_url} handleOpen={this.handleOpen} 87 loggedUserFavouriteOffers={this.state.userFavouriteOffers} 88 getFavouriteOffersForLoggedUser={this.getFavouriteOffersForLoggedUser} 89 />) 90 } 91 </tbody> 92 </table> 78 79 {(() => { 80 if(this.state.userFavouriteOffers.length != 0){ 81 return <table cellPadding={20} className='phone-with-offers-table'> 82 <thead className='phone-with-offers-table-head'> 83 <tr> 84 <th>Продавница</th> 85 <th>Име на понуда</th> 86 <th>Цена</th> 87 <th></th> 88 </tr> 89 </thead> 90 <tbody> 91 { 92 this.state.userFavouriteOffers.map((offer,idx) => <PhoneOfferComponent key={idx} id={offer.id} 93 is_validated={offer.is_validated} offer_shop={offer.offer_shop} offer_name={offer.offer_name} 94 price={offer.price} offer_url={offer.offer_url} handleOpen={this.handleOpen} 95 loggedUserFavouriteOffers={this.state.userFavouriteOffers} 96 getFavouriteOffersForLoggedUser={this.getFavouriteOffersForLoggedUser} 97 />) 98 } 99 </tbody> 100 </table> 101 } 102 else{ 103 return <h1 className='no-offers-saved-message'>Нема зачувано понуди</h1> 104 } 105 106 })()} 107 93 108 <CheaperOffersComponent 94 109 cheaperOffers={this.state.cheaperOffers}
Note:
See TracChangeset
for help on using the changeset viewer.