Gestion erreur jamalette
This commit is contained in:
parent
a7464eca23
commit
be3b7b8230
5 changed files with 96 additions and 6 deletions
33
src/css/Components/notinbdd.css
Normal file
33
src/css/Components/notinbdd.css
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#warningBlock{
|
||||||
|
height:30vh;
|
||||||
|
display:flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
#warningBox{
|
||||||
|
color:white;
|
||||||
|
font-family: 'Wellfleet',cursive;
|
||||||
|
font-size:2vw
|
||||||
|
}
|
||||||
|
|
||||||
|
#warningAdvice{
|
||||||
|
color:rgb(65, 65, 65);;
|
||||||
|
font-family: 'Wellfleet',cursive;
|
||||||
|
font-size:2vw
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#returningButton{
|
||||||
|
font-family: 'Wellfleet', cursive;
|
||||||
|
display:block;
|
||||||
|
color:white;
|
||||||
|
font-size:2vw;
|
||||||
|
background-image:linear-gradient(#057B26,#044616);
|
||||||
|
border: 0.3vw solid black;
|
||||||
|
border-radius: 2.2vw;
|
||||||
|
padding:0.7vw 1.5vw 0.7vw 1.5vw;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#sortOrder:hover {
|
#sortOrder:hover {
|
||||||
animation: rotate180 2s forwards
|
animation: rotate180 2s forwards022314015174
|
||||||
}
|
}
|
||||||
|
|
||||||
.letter {
|
.letter {
|
||||||
|
|
|
@ -87,7 +87,6 @@
|
||||||
font-family: 'Wellfleet', cursive;
|
font-family: 'Wellfleet', cursive;
|
||||||
display:block;
|
display:block;
|
||||||
color:white;
|
color:white;
|
||||||
font-family: 'Wellfleet', cursive;
|
|
||||||
font-size:2vw;
|
font-size:2vw;
|
||||||
background-image:linear-gradient(#057B26,#044616);
|
background-image:linear-gradient(#057B26,#044616);
|
||||||
border: 0.3vw solid black;
|
border: 0.3vw solid black;
|
||||||
|
|
43
src/js/Components/NotInBdd.js
Normal file
43
src/js/Components/NotInBdd.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import '../../css/Components/notinbdd.css'
|
||||||
|
|
||||||
|
class NotInBdd extends Component {
|
||||||
|
|
||||||
|
constructor(props){
|
||||||
|
super(props)
|
||||||
|
this.state = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
render() {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div id="transp">
|
||||||
|
<div id="formBody">
|
||||||
|
<div id="warningBlock">
|
||||||
|
<div id="warningBox">
|
||||||
|
Cette article n'est pas dans le stock !
|
||||||
|
</div>
|
||||||
|
<div id="warningAdvice">
|
||||||
|
Ajoute le depuis la page <Link id="link" to='/stock'>Stock</Link> !
|
||||||
|
</div>
|
||||||
|
<div id="returningButton" onClick={this.props.handleCloseAbove}>
|
||||||
|
Ok
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NotInBdd;
|
|
@ -9,6 +9,7 @@ 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';
|
import { Link } from 'react-router-dom';
|
||||||
|
import NotInBdd from '../Components/NotInBdd';
|
||||||
|
|
||||||
export default class Stock extends React.Component {
|
export default class Stock extends React.Component {
|
||||||
|
|
||||||
|
@ -21,7 +22,8 @@ export default class Stock extends React.Component {
|
||||||
empty:true,
|
empty:true,
|
||||||
totalPrice:0,
|
totalPrice:0,
|
||||||
totalQuantity:0,
|
totalQuantity:0,
|
||||||
redirect:false
|
redirect:false,
|
||||||
|
onNotInBdd:false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handleScan = this.handleScan.bind(this);
|
this.handleScan = this.handleScan.bind(this);
|
||||||
|
@ -49,14 +51,18 @@ export default class Stock extends React.Component {
|
||||||
let i=0;
|
let i=0;
|
||||||
let current = this.state.articles[i];
|
let current = this.state.articles[i];
|
||||||
let trouve = current.code === code ? true : false;
|
let trouve = current.code === code ? true : false;
|
||||||
while(!trouve) {
|
while(!trouve && i < this.state.articles.length-1) {
|
||||||
i++;
|
i++;
|
||||||
current = this.state.articles[i];
|
current = this.state.articles[i];
|
||||||
if (current.code === code) {
|
if (current.code === code) {
|
||||||
trouve = !trouve;
|
trouve = !trouve;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// current.quantity = 1
|
|
||||||
|
// Gestion d'erreur si le code n'est pas dans la BDD
|
||||||
|
if (!trouve){
|
||||||
|
this.setState({onNotInBdd:true})
|
||||||
|
} else {
|
||||||
|
|
||||||
console.log(current);
|
console.log(current);
|
||||||
|
|
||||||
|
@ -96,7 +102,7 @@ export default class Stock extends React.Component {
|
||||||
this.calculateTotaux()
|
this.calculateTotaux()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateTotaux = () => {
|
calculateTotaux = () => {
|
||||||
|
@ -141,6 +147,12 @@ export default class Stock extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeNotInBdd = () => {
|
||||||
|
|
||||||
|
this.setState({onNotInBdd:false})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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>)
|
||||||
|
@ -151,6 +163,9 @@ export default class Stock extends React.Component {
|
||||||
<Navbar redirect="/stock" left="Monnaie" right="Le Stock"/>
|
<Navbar redirect="/stock" left="Monnaie" right="Le Stock"/>
|
||||||
<BarcodeReader onScan={this.handleScan}/>
|
<BarcodeReader onScan={this.handleScan}/>
|
||||||
<SearchBar/>
|
<SearchBar/>
|
||||||
|
{this.state.onNotInBdd &&
|
||||||
|
<NotInBdd handleCloseAbove={this.closeNotInBdd}/>
|
||||||
|
}
|
||||||
{!this.state.empty ?
|
{!this.state.empty ?
|
||||||
<div id="articlesInline">
|
<div id="articlesInline">
|
||||||
{this.state.articlesJamalette.map((article) =>
|
{this.state.articlesJamalette.map((article) =>
|
||||||
|
|
Loading…
Reference in a new issue