|
@@ -21,6 +21,9 @@ class ArticleDetails extends React.Component {
|
21
|
21
|
|
22
|
22
|
}
|
23
|
23
|
|
|
24
|
+ componentDidMount = () => {
|
|
25
|
+
|
|
26
|
+ }
|
24
|
27
|
|
25
|
28
|
handleDesc = () => {
|
26
|
29
|
this.setState({currentArticle:this.props.id})
|
|
@@ -68,31 +71,75 @@ class ArticleDetails extends React.Component {
|
68
|
71
|
})
|
69
|
72
|
}
|
70
|
73
|
|
71
|
|
- plusQuantity = () => {
|
|
74
|
+ plusQuantity = (element) => {
|
72
|
75
|
this.setState({quantity:this.state.quantity+1},()=>{
|
73
|
76
|
this.updateArticle();
|
|
77
|
+ if (this.state.quantity > 0 ){
|
|
78
|
+ if (this.state.selected){
|
|
79
|
+ this.props.colorArticle("white",element)
|
|
80
|
+ } else {
|
|
81
|
+ this.props.colorArticle("grey",element)
|
|
82
|
+ }
|
|
83
|
+ }
|
74
|
84
|
})
|
75
|
85
|
}
|
76
|
86
|
|
77
|
|
- minusQuantity = () => {
|
|
87
|
+ minusQuantity = (element) => {
|
78
|
88
|
if(this.state.quantity > 0){
|
79
|
89
|
this.setState({quantity:this.state.quantity-1},()=>{
|
80
|
90
|
this.updateArticle();
|
|
91
|
+ if (this.state.quantity === 0){
|
|
92
|
+ if (this.state.selected){
|
|
93
|
+ this.props.colorArticle("red&white",element)
|
|
94
|
+ } else {
|
|
95
|
+ this.props.colorArticle("red",element)
|
|
96
|
+ }
|
|
97
|
+ }
|
81
|
98
|
})
|
82
|
|
- }
|
|
99
|
+ }
|
83
|
100
|
}
|
84
|
101
|
|
|
102
|
+ // OnClick : selon si on clique sur tel ou tel element : on va colorer en blanc et selectionner
|
|
103
|
+ // on va minus ou plus quantity et colorer en rouge
|
|
104
|
+
|
85
|
105
|
selectArticles = (e) => {
|
86
|
|
- console.log(e.target.id)
|
87
|
|
- if ((e.target.id !== "categoryIcon") && (e.target.id !== "penblue") && (e.target.id !== "crossred") && (e.target.id !== "") && (e.target.id !== "bluepen") && (e.target.id !== "redcross") && (e.target.id !== "no")){
|
|
106
|
+ let currentElement = e.target;
|
|
107
|
+ let iconElement;
|
|
108
|
+ if (e.target.tagName === "path"){
|
|
109
|
+ currentElement = e.target.parentElement
|
|
110
|
+ iconElement = currentElement
|
|
111
|
+ }
|
|
112
|
+ if ((e.target.id === "minusIcon") || (e.target.id === "plusIcon")){
|
|
113
|
+ iconElement = currentElement
|
|
114
|
+ }
|
|
115
|
+ while (currentElement.id !== "bulle"){
|
|
116
|
+ currentElement = currentElement.parentElement
|
|
117
|
+ }
|
|
118
|
+
|
|
119
|
+ console.log(currentElement);
|
|
120
|
+ if ((e.target.id !== "categoryIcon") && (e.target.id !== "penblue") && (e.target.id !== "crossred") && (e.target.id !== "") && (e.target.id !== "bluepen") && (e.target.id !== "redcross") && (e.target.id !== "no") && (e.target.id !== "minusIcon") && (e.target.id !== "plusIcon")){
|
88
|
121
|
this.setState({selected:!this.state.selected},()=>{
|
89
|
122
|
console.log(this.state.selected)
|
90
|
123
|
if (this.state.selected){
|
91
|
124
|
this.props.select(this.props.id)
|
|
125
|
+ if (this.state.quantity === 0){
|
|
126
|
+ this.props.colorArticle("red&white",currentElement)
|
|
127
|
+ } else {
|
|
128
|
+ this.props.colorArticle("white",currentElement)
|
|
129
|
+ }
|
92
|
130
|
} else {
|
93
|
131
|
this.props.deselect(this.props.id)
|
|
132
|
+ if (this.state.quantity === 0){
|
|
133
|
+ this.props.colorArticle("red",currentElement)
|
|
134
|
+ } else {
|
|
135
|
+ this.props.colorArticle("grey",currentElement)
|
|
136
|
+ }
|
94
|
137
|
}
|
95
|
138
|
})
|
|
139
|
+ } else if (iconElement.id === "minusIcon"){
|
|
140
|
+ this.minusQuantity(currentElement)
|
|
141
|
+ } else if (iconElement.id === "plusIcon"){
|
|
142
|
+ this.plusQuantity(currentElement)
|
96
|
143
|
}
|
97
|
144
|
}
|
98
|
145
|
|
|
@@ -105,11 +152,7 @@ class ArticleDetails extends React.Component {
|
105
|
152
|
|
106
|
153
|
// SQUARE
|
107
|
154
|
|
108
|
|
- this.state.selected ?
|
109
|
|
-
|
110
|
|
- // SELECTED
|
111
|
|
-
|
112
|
|
- <div onClick={this.selectArticles} id="bulleSelect" onMouseEnter={this.handleDesc} onMouseLeave={this.handlePhoto}>
|
|
155
|
+ <div onClick={this.selectArticles} id="bulle" onMouseEnter={this.handleDesc} onMouseLeave={this.handlePhoto}>
|
113
|
156
|
{this.state.redcrossPressed ?
|
114
|
157
|
<div id="confirmation">
|
115
|
158
|
<div id="confirmationTxt">Tu veux vraiment supprimer cet article ?</div>
|
|
@@ -119,102 +162,45 @@ class ArticleDetails extends React.Component {
|
119
|
162
|
</div>
|
120
|
163
|
</div>
|
121
|
164
|
:
|
122
|
|
- <>
|
123
|
|
- <div id="imageordescblock">
|
124
|
|
- {this.state.currentArticle === this.props.id ?
|
125
|
|
- <>
|
126
|
|
- <div id="icons">
|
127
|
|
- <div id="bluepen" onClick={() => this.props.editArticle(this.props)}>
|
128
|
|
- <Icon id="penblue" icon={editSolid} style={{color: '#ffffff', fontSize: '25px'}} rotate="270deg" />
|
129
|
|
- </div>
|
130
|
|
- <div id="redcross" onClick={this.handleRedCross}>
|
131
|
|
- <Icon id="crossred" icon={plusIcon} style={{transform : 'rotate(-45deg)', color: '#ffffff', fontSize: '25px'}} />
|
132
|
|
- </div>
|
133
|
|
- </div>
|
134
|
|
- <div id="categoryDiv">
|
135
|
|
- <img onClick={() => this.props.handleCategories(this.props.category)} id="categoryIcon" alt="bonjour" src={`https://etud.insa-toulouse.fr/~proximo/api_proximo/storage/app/public/icon/${this.props.category.icon}`}/>
|
136
|
|
- </div>
|
137
|
|
- <div id="descandprice">
|
138
|
|
- <h1 id="desc">{this.props.desc}</h1>
|
139
|
|
- <p id ="price">{this.props.price} €</p>
|
140
|
|
- </div>
|
141
|
|
- </>
|
142
|
|
- : <img id="image" src={`https://etud.insa-toulouse.fr/~proximo/api_proximo/storage/app/public/img/${this.props.img}`} alt='bonjour'/>
|
143
|
|
- }
|
144
|
|
- </div>
|
145
|
|
- <h1 id="name">{this.props.name}</h1>
|
146
|
|
- <div id="count">
|
147
|
|
- <Icon onClick={this.minusQuantity} icon={minusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
148
|
|
- <div id="countNumber">
|
149
|
|
- <p id="countNumberTxt">{this.state.quantity}</p>
|
|
165
|
+ <div id="bulleContainer">
|
|
166
|
+ <div id="imageordescblock">
|
|
167
|
+ {this.state.currentArticle === this.props.id ?
|
|
168
|
+ <>
|
|
169
|
+ <div id="icons">
|
|
170
|
+ <div id="bluepen" onClick={() => this.props.editArticle(this.props)}>
|
|
171
|
+ <Icon icon={editSolid} style={{color: '#ffffff', fontSize: '25px'}} rotate="270deg" />
|
|
172
|
+ </div>
|
|
173
|
+ <div id="redcross" onClick={this.handleRedCross}>
|
|
174
|
+ <Icon icon={plusIcon} style={{transform : 'rotate(-45deg)', color: '#ffffff', fontSize: '25px'}} />
|
|
175
|
+ </div>
|
150
|
176
|
</div>
|
151
|
|
- <Icon onClick={this.plusQuantity} icon={plusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
152
|
|
- </div>
|
153
|
|
- </>
|
154
|
|
- }
|
155
|
|
- </div>
|
156
|
|
-
|
157
|
|
- :
|
158
|
|
-
|
159
|
|
- // NOT SELECTED
|
160
|
|
-
|
161
|
|
- <div onClick={this.selectArticles} id="bulle" onMouseEnter={this.handleDesc} onMouseLeave={this.handlePhoto}>
|
162
|
|
- {this.state.redcrossPressed ?
|
163
|
|
- <div id="confirmation">
|
164
|
|
- <div id="confirmationTxt">Tu veux vraiment supprimer cet article ?</div>
|
165
|
|
- <div id="choice">
|
166
|
|
- <div id="yes" onClick={this.deleteArticle}>Oui</div>
|
167
|
|
- <div id="no" onClick={this.handleNoDelete}>Non</div>
|
168
|
|
- </div>
|
169
|
|
- </div>
|
170
|
|
- :
|
171
|
|
- <>
|
172
|
|
- <div id="imageordescblock">
|
173
|
|
- {this.state.currentArticle === this.props.id ?
|
174
|
|
- <>
|
175
|
|
- <div id="icons">
|
176
|
|
- <div id="bluepen" onClick={() => this.props.editArticle(this.props)}>
|
177
|
|
- <Icon icon={editSolid} style={{color: '#ffffff', fontSize: '25px'}} rotate="270deg" />
|
178
|
|
- </div>
|
179
|
|
- <div id="redcross" onClick={this.handleRedCross}>
|
180
|
|
- <Icon icon={plusIcon} style={{transform : 'rotate(-45deg)', color: '#ffffff', fontSize: '25px'}} />
|
|
177
|
+ <div id="categoryDiv">
|
|
178
|
+ <img onClick={() => this.props.handleCategories(this.props.category)} id="categoryIcon" alt="bonjour" src={`https://etud.insa-toulouse.fr/~proximo/api_proximo/storage/app/public/icon/${this.props.category.icon}`}/>
|
|
179
|
+ </div>
|
|
180
|
+ <div id="descandprice">
|
|
181
|
+ <h1 id="desc">{this.props.desc}</h1>
|
|
182
|
+ <p id ="price">{this.props.price} €</p>
|
|
183
|
+ </div>
|
|
184
|
+ </>
|
|
185
|
+ : <img id="image" src={`https://etud.insa-toulouse.fr/~proximo/api_proximo/storage/app/public/img/${this.props.img}`} alt='bonjour'/>
|
|
186
|
+ }
|
181
|
187
|
</div>
|
182
|
|
- </div>
|
183
|
|
- <div id="categoryDiv">
|
184
|
|
- <img onClick={() => this.props.handleCategories(this.props.category)} id="categoryIcon" alt="bonjour" src={`https://etud.insa-toulouse.fr/~proximo/api_proximo/storage/app/public/icon/${this.props.category.icon}`}/>
|
185
|
|
- </div>
|
186
|
|
- <div id="descandprice">
|
187
|
|
- <h1 id="desc">{this.props.desc}</h1>
|
188
|
|
- <p id ="price">{this.props.price} €</p>
|
189
|
|
- </div>
|
190
|
|
- </>
|
191
|
|
- : <img id="image" src={`https://etud.insa-toulouse.fr/~proximo/api_proximo/storage/app/public/img/${this.props.img}`} alt='bonjour'/>
|
192
|
|
- }
|
193
|
|
- </div>
|
194
|
|
- <h1 id="name">{this.props.name}</h1>
|
195
|
|
- <div id="count">
|
196
|
|
- <Icon onClick={this.minusQuantity} icon={minusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
|
188
|
+ <h1 id="name">{this.props.name}</h1>
|
|
189
|
+ <div id="count">
|
|
190
|
+ <Icon id="minusIcon" icon={minusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
197
|
191
|
<div id="countNumber">
|
198
|
192
|
<p id="countNumberTxt">{this.state.quantity}</p>
|
199
|
193
|
</div>
|
200
|
|
- <Icon onClick={this.plusQuantity} icon={plusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
|
194
|
+ <Icon id="plusIcon" icon={plusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
201
|
195
|
</div>
|
202
|
|
- </>
|
|
196
|
+ </div>
|
203
|
197
|
}
|
204
|
|
- </div>
|
|
198
|
+ </div>
|
205
|
199
|
|
206
|
200
|
:
|
207
|
201
|
|
208
|
202
|
// INLINE
|
209
|
203
|
|
210
|
|
- this.state.selected ?
|
211
|
|
-
|
212
|
|
- // SELECTED
|
213
|
|
-
|
214
|
|
- <div>Ok</div>
|
215
|
|
-
|
216
|
|
- :
|
217
|
|
-
|
218
|
204
|
// NOT SELECTED
|
219
|
205
|
|
220
|
206
|
<div id="line">
|