Browse Source

BareCodeScan

Kongzibapt 3 years ago
parent
commit
6f6cfc9a20
3 changed files with 22 additions and 1 deletions
  1. 11
    0
      package-lock.json
  2. 1
    0
      package.json
  3. 10
    1
      src/js/Views/Stock.js

+ 11
- 0
package-lock.json View File

@@ -10885,6 +10885,17 @@
10885 10885
         "whatwg-fetch": "^3.0.0"
10886 10886
       }
10887 10887
     },
10888
+    "react-barcode-reader": {
10889
+      "version": "0.0.2",
10890
+      "resolved": "https://registry.npmjs.org/react-barcode-reader/-/react-barcode-reader-0.0.2.tgz",
10891
+      "integrity": "sha512-sbVTr/PFYd1iXeVCFiJk5xIQxaL7vNe8kNZ4cSx22rHumD9uxt9EH2xg2taIHxAruLtlI+gbNiJIgKSBiqjgFA==",
10892
+      "requires": {
10893
+        "babel-loader": "^8.1.0",
10894
+        "prop-types": "^15.7.2",
10895
+        "react": "^16.13.1",
10896
+        "react-dom": "^16.13.1"
10897
+      }
10898
+    },
10888 10899
     "react-custom-scroll": {
10889 10900
       "version": "4.2.1",
10890 10901
       "resolved": "https://registry.npmjs.org/react-custom-scroll/-/react-custom-scroll-4.2.1.tgz",

+ 1
- 0
package.json View File

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

+ 10
- 1
src/js/Views/Stock.js View File

@@ -17,6 +17,7 @@ import EditCategory from '../Components/EditCategory';
17 17
 import Sort from '../Components/Sort';
18 18
 import { Link } from 'react-router-dom';
19 19
 import Selected from '../Components/Selected';
20
+import BarcodeReader from 'react-barcode-reader'
20 21
 
21 22
 export default class Stock extends React.Component {
22 23
 
@@ -37,7 +38,8 @@ export default class Stock extends React.Component {
37 38
       onSearch:false,
38 39
       sortOrder: 0,
39 40
       selectedArticles:[],
40
-      counter:0
41
+      counter:0,
42
+      code:''
41 43
     }
42 44
   }
43 45
 
@@ -219,12 +221,19 @@ export default class Stock extends React.Component {
219 221
     }
220 222
   }
221 223
 
224
+  handleScan = (data) => {
225
+    this.setState({code:data},()=>{
226
+      console.log(this.state.code)
227
+    })
228
+  }
229
+
222 230
   render() {
223 231
     if (!sessionStorage.getItem('token')){
224 232
       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>)
225 233
     } else {
226 234
       return (
227 235
           <div id="stock" tabIndex={-1} onKeyDown={this.closeWithEscape}>
236
+          <BarcodeReader onScan={this.handleScan}/>
228 237
               <Header title='Le Stock'/>
229 238
               <Navbar handleNewArticle={this.handleNewArticle} handleNewCategory={this.handleNewCategory} right="Le Ticket de Caisse" left="Créer" leftLeft="Article" leftMiddle="|" leftRight="Catégorie" redirect="/ticket"/>
230 239
               {this.state.onNewArticle ?

Loading…
Cancel
Save