- Timestamp:
- 09/17/22 01:24:24 (2 years ago)
- Branches:
- master
- Children:
- 5201690
- Parents:
- 775e15e
- Location:
- phonelux-frontend/src/components/PhoneWithOffersComponent
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.