1 | import React, { Component } from 'react'
|
---|
2 | import axios from 'axios'
|
---|
3 | import './PhoneOfferDetailsComponent.css'
|
---|
4 | import HeaderComponent from '../HeaderComponent/HeaderComponent'
|
---|
5 | import UserContext from '../../context/UserContext'
|
---|
6 | import { Link } from 'react-router-dom'
|
---|
7 |
|
---|
8 |
|
---|
9 | export class PhoneOfferDetailsComponent extends Component {
|
---|
10 |
|
---|
11 | constructor(props) {
|
---|
12 | super(props)
|
---|
13 |
|
---|
14 | this.state = {
|
---|
15 | offerId: window.location.href.split('/')[4],
|
---|
16 | offer: null
|
---|
17 | }
|
---|
18 | }
|
---|
19 |
|
---|
20 | componentDidMount(){
|
---|
21 | axios.get('/phoneoffer/'+this.state.offerId)
|
---|
22 | .then(response => {
|
---|
23 | this.setState({
|
---|
24 | offer: response.data
|
---|
25 | })
|
---|
26 | }).catch(error => console.log(error))
|
---|
27 | }
|
---|
28 |
|
---|
29 | render() {
|
---|
30 | return (
|
---|
31 | <div className='phone-offer-details-main'>
|
---|
32 | <HeaderComponent/>
|
---|
33 | <div className='phone-offer-details-last-updated-wrapper'>
|
---|
34 | <h3 className='phone-offer-details-last-updated-header'>Последно ажурирана: {this.state.offer == null ||
|
---|
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 | }
|
---|
42 | </div>
|
---|
43 | <div className='phone-offer-details-table-wrapper'>
|
---|
44 | <div className='phone-offer-details-table-section'>
|
---|
45 | <table className='phone-offer-details-table'>
|
---|
46 | <thead>
|
---|
47 | <tr><th colSpan={2}>Детали за понудата</th></tr>
|
---|
48 | </thead>
|
---|
49 | <tbody>
|
---|
50 | <tr className='phone-offer-details-table-row'>
|
---|
51 | <td>Понуда</td><td><a href={this.state.offer == null || this.state.offer.offer_url == null ?
|
---|
52 | '#' : this.state.offer.offer_url}>{this.state.offer == null || this.state.offer.offer_name == null ?
|
---|
53 | '/' : this.state.offer.offer_name}</a></td>
|
---|
54 | </tr>
|
---|
55 |
|
---|
56 | <tr className='phone-offer-details-table-row'>
|
---|
57 | <td>Продавница</td><td>{this.state.offer == null ||
|
---|
58 | this.state.offer.offer_shop == null ? '/' : this.state.offer.offer_shop}</td>
|
---|
59 | </tr>
|
---|
60 |
|
---|
61 | <tr className='phone-offer-details-table-row'>
|
---|
62 | <td>Цена</td><td>{this.state.offer == null ||
|
---|
63 | this.state.offer.price == null ? '/' : this.state.offer.price+' ден.'}</td>
|
---|
64 | </tr>
|
---|
65 | <tr className='phone-offer-details-table-row'>
|
---|
66 | <td>Предна камера</td><td>{this.state.offer == null ||
|
---|
67 | this.state.offer.front_camera == null ? '/' : this.state.offer.front_camera}</td>
|
---|
68 | </tr>
|
---|
69 |
|
---|
70 | <tr className='phone-offer-details-table-row'>
|
---|
71 | <td>Задна камера</td><td>{this.state.offer == null ||
|
---|
72 | this.state.offer.back_camera == null ? '/' : this.state.offer.back_camera}</td>
|
---|
73 | </tr>
|
---|
74 |
|
---|
75 | <tr className='phone-offer-details-table-row'>
|
---|
76 | <td>РОМ меморија</td><td>{this.state.offer == null ||
|
---|
77 | this.state.offer.rom_memory == null ? '/' : this.state.offer.rom_memory}</td>
|
---|
78 | </tr>
|
---|
79 |
|
---|
80 | <tr className='phone-offer-details-table-row'>
|
---|
81 | <td>РАМ меморија</td><td>{this.state.offer == null ||
|
---|
82 | this.state.offer.ram_memory == null ? '/' : this.state.offer.ram_memory}</td>
|
---|
83 | </tr>
|
---|
84 |
|
---|
85 | <tr className='phone-offer-details-table-row'>
|
---|
86 | <td>Оперативен систем</td><td>{this.state.offer == null ||
|
---|
87 | this.state.offer.operating_system == null ? '/' : this.state.offer.operating_system}</td>
|
---|
88 | </tr>
|
---|
89 |
|
---|
90 | <tr className='phone-offer-details-table-row'>
|
---|
91 | <td>Чипсет</td><td>{this.state.offer == null ||
|
---|
92 | this.state.offer.chipset == null ? '/' : this.state.offer.chipset}</td>
|
---|
93 | </tr>
|
---|
94 |
|
---|
95 | <tr className='phone-offer-details-table-row'>
|
---|
96 | <td>Процесор</td><td>{this.state.offer == null ||
|
---|
97 | this.state.offer.cpu == null ? '/' : this.state.offer.cpu}</td>
|
---|
98 | </tr>
|
---|
99 |
|
---|
100 | <tr className='phone-offer-details-table-row'>
|
---|
101 | <td>Батерија</td><td>{this.state.offer == null ||
|
---|
102 | this.state.offer.battery == null ? '/' : this.state.offer.battery}</td>
|
---|
103 | </tr>
|
---|
104 |
|
---|
105 | <tr className='phone-offer-details-table-row'>
|
---|
106 | <td>Боја</td><td>{this.state.offer == null ||
|
---|
107 | this.state.offer.color == null ? '/' : this.state.offer.color}</td>
|
---|
108 | </tr>
|
---|
109 |
|
---|
110 | <tr className='phone-offer-details-table-row'>
|
---|
111 | <td>Опис</td><td>{this.state.offer == null ||
|
---|
112 | this.state.offer.offer_description == null ? '/' : this.state.offer.offer_description}</td>
|
---|
113 | </tr>
|
---|
114 |
|
---|
115 | </tbody>
|
---|
116 | </table>
|
---|
117 | </div>
|
---|
118 | </div>
|
---|
119 |
|
---|
120 | </div>
|
---|
121 | )
|
---|
122 | }
|
---|
123 | }
|
---|
124 |
|
---|
125 | PhoneOfferDetailsComponent.contextType = UserContext
|
---|
126 |
|
---|
127 | export default PhoneOfferDetailsComponent
|
---|