ticket Fonctionnel
This commit is contained in:
parent
c82e2cf251
commit
35daee4af9
2 changed files with 57 additions and 4 deletions
|
@ -73,4 +73,25 @@
|
||||||
padding-bottom:1%;
|
padding-bottom:1%;
|
||||||
font-size:35px;
|
font-size:35px;
|
||||||
color:black;
|
color:black;
|
||||||
|
}
|
||||||
|
|
||||||
|
#validateArticlesBlock{
|
||||||
|
height:4vh;
|
||||||
|
margin-top:5vh;
|
||||||
|
display:flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#validateArticlesBox{
|
||||||
|
font-family: 'Wellfleet', cursive;
|
||||||
|
display:block;
|
||||||
|
color:white;
|
||||||
|
font-family: 'Wellfleet', cursive;
|
||||||
|
font-size:2vw;
|
||||||
|
background-image:linear-gradient(#057B26,#044616);
|
||||||
|
border: 0.3vw solid black;
|
||||||
|
border-radius: 2.2vw;
|
||||||
|
padding:0.7vw 1vw 0.7vw 1vw;
|
||||||
|
cursor:pointer;
|
||||||
}
|
}
|
|
@ -4,11 +4,11 @@ import Header from '../Components/Header';
|
||||||
import Navbar from '../Components/Navbar';
|
import Navbar from '../Components/Navbar';
|
||||||
import 'react-perfect-scrollbar/dist/css/styles.css';
|
import 'react-perfect-scrollbar/dist/css/styles.css';
|
||||||
import Footer from '../Components/Footer';
|
import Footer from '../Components/Footer';
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import SearchBar from '../Components/SearchBar';
|
import SearchBar from '../Components/SearchBar';
|
||||||
import BarcodeReader from 'react-barcode-reader';
|
import BarcodeReader from 'react-barcode-reader';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import ArticleDetails from '../Components/ArticleDetails';
|
import ArticleDetails from '../Components/ArticleDetails';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
export default class Stock extends React.Component {
|
export default class Stock extends React.Component {
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@ export default class Stock extends React.Component {
|
||||||
articlesJamalette:[],
|
articlesJamalette:[],
|
||||||
empty:true,
|
empty:true,
|
||||||
totalPrice:0,
|
totalPrice:0,
|
||||||
totalQuantity:0
|
totalQuantity:0,
|
||||||
|
redirect:false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handleScan = this.handleScan.bind(this);
|
this.handleScan = this.handleScan.bind(this);
|
||||||
|
@ -77,11 +78,13 @@ export default class Stock extends React.Component {
|
||||||
if (already){
|
if (already){
|
||||||
this.state.articlesJamalette[j].quantity++;
|
this.state.articlesJamalette[j].quantity++;
|
||||||
} else {
|
} else {
|
||||||
|
current.realQuantity = current.quantity;
|
||||||
current.quantity = 1;
|
current.quantity = 1;
|
||||||
this.state.articlesJamalette.push(current);
|
this.state.articlesJamalette.push(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
current.realQuantity = current.quantity;
|
||||||
current.quantity = 1;
|
current.quantity = 1;
|
||||||
this.state.articlesJamalette.push(current);
|
this.state.articlesJamalette.push(current);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +116,31 @@ export default class Stock extends React.Component {
|
||||||
this.getArticleByCode(code)
|
this.getArticleByCode(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleValidation = () => {
|
||||||
|
|
||||||
|
for (let i = 0 ; i < this.state.articlesJamalette.length ; i++) {
|
||||||
|
|
||||||
|
axios.put(`https://etud.insa-toulouse.fr/~proximo/v2/api/articles/${this.state.articlesJamalette[i].id}`,
|
||||||
|
{
|
||||||
|
'name':this.state.articlesJamalette[i].name,
|
||||||
|
'description':this.state.articlesJamalette[i].description,
|
||||||
|
'quantity':this.state.articlesJamalette[i].realQuantity-this.state.articlesJamalette[i].quantity,
|
||||||
|
'price':this.state.articlesJamalette[i].price,
|
||||||
|
'code':this.state.articlesJamalette[i].code,
|
||||||
|
'category_id':this.state.articlesJamalette[i].category.id
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.data)
|
||||||
|
this.setState({articlesJamalette:[],empty:true})
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error.response)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (!sessionStorage.getItem('token')){
|
if (!sessionStorage.getItem('token')){
|
||||||
return (<div id="errorRouteBlock"><div id="errorRouteTitle">ERREUR </div><br/><div id="errorRouteTxt">Vous n'êtes pas connecté</div><br/><Link id="link" to='/'>Retourner à l'Accueil</Link></div>)
|
return (<div id="errorRouteBlock"><div id="errorRouteTitle">ERREUR </div><br/><div id="errorRouteTxt">Vous n'êtes pas connecté</div><br/><Link id="link" to='/'>Retourner à l'Accueil</Link></div>)
|
||||||
|
@ -126,8 +154,7 @@ export default class Stock extends React.Component {
|
||||||
{!this.state.empty ?
|
{!this.state.empty ?
|
||||||
<div id="articlesInline">
|
<div id="articlesInline">
|
||||||
{this.state.articlesJamalette.map((article) =>
|
{this.state.articlesJamalette.map((article) =>
|
||||||
<ArticleDetails squaredBubble={false} deselect={this.props.deselect} select={this.props.select} handleCategories={this.props.handleCategories} editArticle={this.props.editionArticle} key={article.id} id={article.id} name={article.name} img={article.image} desc={article.description} price={article.price} quantity={article.quantity} code={article.code} category={article.category}/>
|
<ArticleDetails squaredBubble={false} deselect={this.props.deselect} select={this.props.select} handleCategories={this.props.handleCategories} editArticle={this.props.editionArticle} key={article.id} id={article.id} name={article.name} img={article.image} desc={article.description} price={article.price} quantity={article.quantity} code={article.code} category={article.category}/>
|
||||||
|
|
||||||
)}
|
)}
|
||||||
<div id="total">
|
<div id="total">
|
||||||
<div id="totalTxt">
|
<div id="totalTxt">
|
||||||
|
@ -142,6 +169,11 @@ export default class Stock extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="validateArticlesBlock">
|
||||||
|
<div id="validateArticlesBox" onClick={this.handleValidation}>
|
||||||
|
Valider
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
:<div id="emptyTicketBox">
|
:<div id="emptyTicketBox">
|
||||||
<p id="emptyTicket">
|
<p id="emptyTicket">
|
||||||
|
|
Loading…
Reference in a new issue