Ignore:
Timestamp:
09/21/22 18:47:39 (22 months ago)
Author:
Marko <Marko@…>
Branches:
master
Children:
34950c6
Parents:
5201690
Message:

Component for editing offers added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • phonelux-frontend/src/components/PhoneOfferComponent/PhoneOfferComponent.js

    r5201690 rd66b8eb  
    99import VisibilityIcon from '@mui/icons-material/Visibility';
    1010import CheckIcon from '@mui/icons-material/Check';
     11import CompareIcon from '@mui/icons-material/Compare';
     12import BookmarkRemoveIcon from '@mui/icons-material/BookmarkRemove';
    1113
    1214export class PhoneOfferComponent extends Component {
     
    1618   
    1719      this.state = {
    18        
    1920      }
    2021    }
     
    7273      });
    7374    }
     75
     76    handleOfferCompare = () => {
     77      let offersToCompare = []
     78     if(localStorage.getItem('offersToCompare'))
     79     {
     80      offersToCompare = JSON.parse(localStorage.getItem('offersToCompare'))
     81     }
     82
     83     if(!offersToCompare.includes(this.props.id) && offersToCompare.length<5)
     84     {
     85      offersToCompare.push(this.props.id)
     86     }
     87     else{
     88      offersToCompare = offersToCompare.filter(offer => offer != this.props.id)
     89     }
     90     localStorage.setItem('offersToCompare', JSON.stringify(offersToCompare))
     91     this.forceUpdate()
     92    }
    7493   
    7594   
     
    81100      <td>{this.props.price} ден.</td>
    82101      <td>
     102
     103        {/* if else jsx syntax here to add icon */}
     104
     105        {(() => {
     106          if(!localStorage.getItem('token'))
     107          {
     108            return <></>
     109          }
     110
     111          if(localStorage.getItem('offersToCompare') && localStorage.getItem('offersToCompare').includes(this.props.id))
     112          {
     113            return  <Tippy placement='bottom' content='Избриши понуда за споредба'>
     114                      <CompareIcon onClick={this.handleOfferCompare} className='phone-offer-compare-selected-icon' style={{fontSize: '40px', marginRight: '10px' }}/>
     115                    </Tippy>
     116          }
     117          else{
     118            return  <Tippy placement='bottom' content='Додади понуда за споредба'>
     119            <CompareIcon onClick={this.handleOfferCompare} className='phone-offer-compare-icon' style={{fontSize: '40px', marginRight: '10px' }}/>
     120          </Tippy>
     121          }
     122      })()}
     123        {/* {
     124          localStorage.getItem('token') && !localStorage.getItem('offersToCompare').includes(this.props.id)?
     125          <Tippy placement='bottom' content='Додади понуда за споредба'>
     126          <CompareIcon onClick={this.handleOfferCompare} className='phone-offer-compare-icon' style={{fontSize: '40px', marginRight: '10px' }}/>
     127        </Tippy> : <></>
     128        } */}
    83129        {
    84130          window.location.href.split('/')[5] == 'favouriteoffers' ?   
     
    98144          localStorage.getItem('token') && this.props.loggedUserFavouriteOffers.filter(offer => offer.id == this.props.id).length != 0?
    99145          <Tippy placement='bottom' content='Избриши од омилени понуди'>
    100           <StarIcon onClick={this.removeFromFavourite} className='phone-offer-favouriteoffer-icon' style={{fontSize: '40px', marginRight: '10px' }}/>
     146          <StarIcon onClick={this.removeFromFavourite} className='phone-offer-remove-favouriteoffer-icon' style={{fontSize: '40px', marginRight: '10px' }}/>
    101147          </Tippy>
    102148          : <></>
     
    105151
    106152        <Link style={{ textDecoration: 'none' }} to={"/phoneoffer/"+this.props.id}>
    107           <button className='phone-offer-specifications-button'>Спецификации</button>
     153          <button className='phone-offer-specifications-button'><b>Спецификации</b></button>
    108154        </Link>
    109155        </td>
Note: See TracChangeset for help on using the changeset viewer.