BareCodeScan

This commit is contained in:
Kongzibapt 2021-02-05 14:28:26 +01:00
parent 056396092b
commit 6f6cfc9a20
3 changed files with 22 additions and 1 deletions

11
package-lock.json generated
View file

@ -10885,6 +10885,17 @@
"whatwg-fetch": "^3.0.0"
}
},
"react-barcode-reader": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/react-barcode-reader/-/react-barcode-reader-0.0.2.tgz",
"integrity": "sha512-sbVTr/PFYd1iXeVCFiJk5xIQxaL7vNe8kNZ4cSx22rHumD9uxt9EH2xg2taIHxAruLtlI+gbNiJIgKSBiqjgFA==",
"requires": {
"babel-loader": "^8.1.0",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1"
}
},
"react-custom-scroll": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/react-custom-scroll/-/react-custom-scroll-4.2.1.tgz",

View file

@ -10,6 +10,7 @@
"@testing-library/user-event": "^7.2.1",
"axios": "^0.21.0",
"react": "^16.13.1",
"react-barcode-reader": "0.0.2",
"react-custom-scroll": "^4.2.1",
"react-dom": "^16.13.1",
"react-loader-spinner": "^3.1.14",

View file

@ -17,6 +17,7 @@ import EditCategory from '../Components/EditCategory';
import Sort from '../Components/Sort';
import { Link } from 'react-router-dom';
import Selected from '../Components/Selected';
import BarcodeReader from 'react-barcode-reader'
export default class Stock extends React.Component {
@ -37,7 +38,8 @@ export default class Stock extends React.Component {
onSearch:false,
sortOrder: 0,
selectedArticles:[],
counter:0
counter:0,
code:''
}
}
@ -219,12 +221,19 @@ export default class Stock extends React.Component {
}
}
handleScan = (data) => {
this.setState({code:data},()=>{
console.log(this.state.code)
})
}
render() {
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>)
} else {
return (
<div id="stock" tabIndex={-1} onKeyDown={this.closeWithEscape}>
<BarcodeReader onScan={this.handleScan}/>
<Header title='Le Stock'/>
<Navbar handleNewArticle={this.handleNewArticle} handleNewCategory={this.handleNewCategory} right="Le Ticket de Caisse" left="Créer" leftLeft="Article" leftMiddle="|" leftRight="Catégorie" redirect="/ticket"/>
{this.state.onNewArticle ?