petit merge
This commit is contained in:
commit
fed2e84e4d
11 changed files with 295 additions and 109 deletions
0
src/css/Components/money.css
Normal file
0
src/css/Components/money.css
Normal file
36
src/css/Components/notinbdd.css
Normal file
36
src/css/Components/notinbdd.css
Normal file
|
@ -0,0 +1,36 @@
|
|||
#warningBlock{
|
||||
height:40vh;
|
||||
display:flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#warningBox{
|
||||
color:white;
|
||||
font-family: 'Wellfleet',cursive;
|
||||
font-size:2vw;
|
||||
padding : 1vw 1vw 0 1vw;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#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;
|
||||
margin: 2vh 0 2vh 0;
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
text-align: center;
|
||||
font-family: 'Wellfleet', cursive;
|
||||
font-size:max(2.5vw,30px);
|
||||
width:25%;
|
||||
width:35%;
|
||||
}
|
||||
|
||||
#articlesInline{
|
||||
|
@ -87,7 +87,6 @@
|
|||
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;
|
||||
|
|
|
@ -21,6 +21,9 @@ class ArticleDetails extends React.Component {
|
|||
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
|
||||
}
|
||||
|
||||
handleDesc = () => {
|
||||
this.setState({currentArticle:this.props.id})
|
||||
|
@ -68,31 +71,75 @@ class ArticleDetails extends React.Component {
|
|||
})
|
||||
}
|
||||
|
||||
plusQuantity = () => {
|
||||
plusQuantity = (element) => {
|
||||
this.setState({quantity:this.state.quantity+1},()=>{
|
||||
this.updateArticle();
|
||||
if (this.state.quantity > 0 ){
|
||||
if (this.state.selected){
|
||||
this.props.colorArticle("white",element)
|
||||
} else {
|
||||
this.props.colorArticle("grey",element)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
minusQuantity = () => {
|
||||
minusQuantity = (element) => {
|
||||
if(this.state.quantity > 0){
|
||||
this.setState({quantity:this.state.quantity-1},()=>{
|
||||
this.updateArticle();
|
||||
if (this.state.quantity === 0){
|
||||
if (this.state.selected){
|
||||
this.props.colorArticle("red&white",element)
|
||||
} else {
|
||||
this.props.colorArticle("red",element)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// OnClick : selon si on clique sur tel ou tel element : on va colorer en blanc et selectionner
|
||||
// on va minus ou plus quantity et colorer en rouge
|
||||
|
||||
selectArticles = (e) => {
|
||||
console.log(e.target.id)
|
||||
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")){
|
||||
let currentElement = e.target;
|
||||
let iconElement;
|
||||
if (e.target.tagName === "path"){
|
||||
currentElement = e.target.parentElement
|
||||
iconElement = currentElement
|
||||
}
|
||||
if ((e.target.id === "minusIcon") || (e.target.id === "plusIcon")){
|
||||
iconElement = currentElement
|
||||
}
|
||||
while (currentElement.id !== "bulle"){
|
||||
currentElement = currentElement.parentElement
|
||||
}
|
||||
|
||||
console.log(currentElement);
|
||||
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")){
|
||||
this.setState({selected:!this.state.selected},()=>{
|
||||
console.log(this.state.selected)
|
||||
if (this.state.selected){
|
||||
this.props.select(this.props.id)
|
||||
if (this.state.quantity === 0){
|
||||
this.props.colorArticle("red&white",currentElement)
|
||||
} else {
|
||||
this.props.colorArticle("white",currentElement)
|
||||
}
|
||||
} else {
|
||||
this.props.deselect(this.props.id)
|
||||
if (this.state.quantity === 0){
|
||||
this.props.colorArticle("red",currentElement)
|
||||
} else {
|
||||
this.props.colorArticle("grey",currentElement)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else if (iconElement.id === "minusIcon"){
|
||||
this.minusQuantity(currentElement)
|
||||
} else if (iconElement.id === "plusIcon"){
|
||||
this.plusQuantity(currentElement)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,59 +152,6 @@ class ArticleDetails extends React.Component {
|
|||
|
||||
// SQUARE
|
||||
|
||||
this.state.selected ?
|
||||
|
||||
// SELECTED
|
||||
|
||||
<div onClick={this.selectArticles} id="bulleSelect" onMouseEnter={this.handleDesc} onMouseLeave={this.handlePhoto}>
|
||||
{this.state.redcrossPressed ?
|
||||
<div id="confirmation">
|
||||
<div id="confirmationTxt">Tu veux vraiment supprimer cet article ?</div>
|
||||
<div id="choice">
|
||||
<div id="yes" onClick={this.deleteArticle}>Oui</div>
|
||||
<div id="no" onClick={this.handleNoDelete}>Non</div>
|
||||
</div>
|
||||
</div>
|
||||
:
|
||||
<>
|
||||
<div id="imageordescblock">
|
||||
{this.state.currentArticle === this.props.id ?
|
||||
<>
|
||||
<div id="icons">
|
||||
<div id="bluepen" onClick={() => this.props.editArticle(this.props)}>
|
||||
<Icon id="penblue" icon={editSolid} style={{color: '#ffffff', fontSize: '25px'}} rotate="270deg" />
|
||||
</div>
|
||||
<div id="redcross" onClick={this.handleRedCross}>
|
||||
<Icon id="crossred" icon={plusIcon} style={{transform : 'rotate(-45deg)', color: '#ffffff', fontSize: '25px'}} />
|
||||
</div>
|
||||
</div>
|
||||
<div id="categoryDiv">
|
||||
<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}`}/>
|
||||
</div>
|
||||
<div id="descandprice">
|
||||
<h1 id="desc">{this.props.desc}</h1>
|
||||
<p id ="price">{this.props.price} €</p>
|
||||
</div>
|
||||
</>
|
||||
: <img id="image" src={`https://etud.insa-toulouse.fr/~proximo/api_proximo/storage/app/public/img/${this.props.img}`} alt='bonjour'/>
|
||||
}
|
||||
</div>
|
||||
<h1 id="name">{this.props.name}</h1>
|
||||
<div id="count">
|
||||
<Icon onClick={this.minusQuantity} icon={minusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
||||
<div id="countNumber">
|
||||
<p id="countNumberTxt">{this.state.quantity}</p>
|
||||
</div>
|
||||
<Icon onClick={this.plusQuantity} icon={plusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
|
||||
:
|
||||
|
||||
// NOT SELECTED
|
||||
|
||||
<div onClick={this.selectArticles} id="bulle" onMouseEnter={this.handleDesc} onMouseLeave={this.handlePhoto}>
|
||||
{this.state.redcrossPressed ?
|
||||
<div id="confirmation">
|
||||
|
@ -168,7 +162,7 @@ class ArticleDetails extends React.Component {
|
|||
</div>
|
||||
</div>
|
||||
:
|
||||
<>
|
||||
<div id="bulleContainer">
|
||||
<div id="imageordescblock">
|
||||
{this.state.currentArticle === this.props.id ?
|
||||
<>
|
||||
|
@ -193,13 +187,13 @@ class ArticleDetails extends React.Component {
|
|||
</div>
|
||||
<h1 id="name">{this.props.name}</h1>
|
||||
<div id="count">
|
||||
<Icon onClick={this.minusQuantity} icon={minusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
||||
<Icon id="minusIcon" icon={minusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
||||
<div id="countNumber">
|
||||
<p id="countNumberTxt">{this.state.quantity}</p>
|
||||
</div>
|
||||
<Icon onClick={this.plusQuantity} icon={plusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
||||
<Icon id="plusIcon" icon={plusIcon} style={{color: '#ffffff', fontSize: '18.558874130249023px',cursor:'pointer'}} />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
@ -207,14 +201,6 @@ class ArticleDetails extends React.Component {
|
|||
|
||||
// INLINE
|
||||
|
||||
this.state.selected ?
|
||||
|
||||
// SELECTED
|
||||
|
||||
<div>Ok</div>
|
||||
|
||||
:
|
||||
|
||||
// NOT SELECTED
|
||||
|
||||
<div id="line">
|
||||
|
|
|
@ -11,8 +11,33 @@ class Articles extends React.Component {
|
|||
}
|
||||
|
||||
componentDidMount(){
|
||||
|
||||
let articles = document.getElementById("articles")
|
||||
console.log(articles);
|
||||
for (let i = 0; i<articles.childElementCount; i++){
|
||||
if (this.props.articles[i].quantity === 0){
|
||||
this.colorArticle("red",articles.children[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
colorArticle = (color,element) => {
|
||||
|
||||
switch (color) {
|
||||
case "white":
|
||||
element.style.cssText = "background-color:rgba(255, 255, 255, 0.75);"
|
||||
break;
|
||||
case "grey" :
|
||||
element.style.cssText = "background-color:rgba(105, 105, 105, 0.28);"
|
||||
break;
|
||||
case "red" :
|
||||
element.style.cssText = "background-color:rgba(255, 21, 21, 0.28);"
|
||||
break;
|
||||
case "red&white" :
|
||||
element.style.cssText = "background-color:rgba(255, 107, 107, 0.28);"
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
render() {
|
||||
|
@ -21,7 +46,7 @@ class Articles extends React.Component {
|
|||
<div id="articles">
|
||||
{
|
||||
this.props.articles.map((article) =>
|
||||
<ArticleDetails squaredBubble={true} 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 colorArticle={this.colorArticle} squaredBubble={true} 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>
|
||||
</div>
|
||||
|
|
50
src/js/Components/Money.js
Normal file
50
src/js/Components/Money.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import '../../css/Components/money.css'
|
||||
|
||||
class Money extends Component {
|
||||
|
||||
constructor(props){
|
||||
super(props)
|
||||
this.state = {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
<div id="transp">
|
||||
<div id="formBody">
|
||||
{this.props.empty ?
|
||||
<div id="warningBlock">
|
||||
<div id="warningBox">
|
||||
Tu n'as pas encore rempli le ticket de caisse !
|
||||
</div>
|
||||
<div id="warningAdvice">
|
||||
Scanne tes articles avec la Jamalette
|
||||
</div>
|
||||
<div id="returningButton" onClick={this.props.handleCloseAbove}>
|
||||
Ok
|
||||
</div>
|
||||
</div>
|
||||
:
|
||||
// A faire : input pour rentrer la somme en espèce + Affichage de la différence avec le prix
|
||||
|
||||
<>
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Money;
|
|
@ -14,6 +14,9 @@ class Navbar extends React.Component {
|
|||
|
||||
handleDisplay = () =>{
|
||||
this.setState({mouseOn:true})
|
||||
if (this.props.handleMoney){
|
||||
this.props.handleMoney()
|
||||
}
|
||||
}
|
||||
|
||||
handleNormal = () => {
|
||||
|
|
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;
|
|
@ -15,7 +15,6 @@ class Sort extends Component {
|
|||
}
|
||||
|
||||
changeArrowDirection = () => {
|
||||
console.log('ok');
|
||||
this.setState({unwound:!this.state.unwound})
|
||||
}
|
||||
|
||||
|
@ -83,6 +82,9 @@ class Sort extends Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
// console.log(this.state.orderText)
|
||||
// console.log(this.state.orderText.split(""))
|
||||
// console.log(document.getElementById("sortOrder"))
|
||||
return (
|
||||
<div id="sortBox">
|
||||
<div id="sortTxt">
|
||||
|
|
|
@ -205,7 +205,6 @@ export default class Stock extends React.Component {
|
|||
|
||||
//ATTENTION ça a changé, on passe directement le string en argument (j'avais besoin d'utiliser cette fonction autrement, voir dans Sort.js)
|
||||
handleChangeSortType = (type) => {
|
||||
console.log(type)
|
||||
this.setState({sortType: type}, () => {
|
||||
this.sortArticles(this.state.sortType)
|
||||
})
|
||||
|
@ -214,7 +213,6 @@ export default class Stock extends React.Component {
|
|||
//Gère le choix de tri par ordre croissant ou décroissant quand c'est possible avec le tri actuel
|
||||
handleChangeSortOrder = () => {
|
||||
this.setState({lowToHigh: !this.state.lowToHigh},() => {
|
||||
console.log(this.state.sortType)
|
||||
this.sortArticles(this.state.sortType);
|
||||
});
|
||||
}
|
||||
|
@ -264,7 +262,6 @@ export default class Stock extends React.Component {
|
|||
|
||||
|
||||
render() {
|
||||
console.log("rendered");
|
||||
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 {
|
||||
|
|
|
@ -9,6 +9,8 @@ import BarcodeReader from 'react-barcode-reader';
|
|||
import axios from 'axios';
|
||||
import ArticleDetails from '../Components/ArticleDetails';
|
||||
import { Link } from 'react-router-dom';
|
||||
import NotInBdd from '../Components/NotInBdd';
|
||||
import Money from '../Components/Money';
|
||||
|
||||
export default class Stock extends React.Component {
|
||||
|
||||
|
@ -21,7 +23,8 @@ export default class Stock extends React.Component {
|
|||
empty:true,
|
||||
totalPrice:0,
|
||||
totalQuantity:0,
|
||||
redirect:false
|
||||
redirect:false,
|
||||
onNotInBdd:false
|
||||
}
|
||||
|
||||
this.handleScan = this.handleScan.bind(this);
|
||||
|
@ -49,14 +52,18 @@ export default class Stock extends React.Component {
|
|||
let i=0;
|
||||
let current = this.state.articles[i];
|
||||
let trouve = current.code === code ? true : false;
|
||||
while(!trouve) {
|
||||
while(!trouve && i < this.state.articles.length-1) {
|
||||
i++;
|
||||
current = this.state.articles[i];
|
||||
if (current.code === code) {
|
||||
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);
|
||||
|
||||
|
@ -96,7 +103,7 @@ export default class Stock extends React.Component {
|
|||
this.calculateTotaux()
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
calculateTotaux = () => {
|
||||
|
@ -116,6 +123,24 @@ export default class Stock extends React.Component {
|
|||
this.getArticleByCode(code)
|
||||
}
|
||||
|
||||
colorArticle = (color,element) => {
|
||||
|
||||
switch (color) {
|
||||
case "white":
|
||||
element.style.cssText = "background-color:rgba(255, 255, 255, 0.75);"
|
||||
break;
|
||||
case "grey" :
|
||||
element.style.cssText = "background-color:rgba(105, 105, 105, 0.28);"
|
||||
break;
|
||||
case "red" :
|
||||
element.style.cssText = "background-color:rgba(255, 21, 21, 0.28);"
|
||||
break;
|
||||
case "red&white" :
|
||||
element.style.cssText = "background-color:rgba(255, 107, 107, 0.28);"
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
handleValidation = () => {
|
||||
|
||||
for (let i = 0 ; i < this.state.articlesJamalette.length ; i++) {
|
||||
|
@ -141,6 +166,20 @@ export default class Stock extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
closeNotInBdd = () => {
|
||||
|
||||
this.setState({onNotInBdd:false})
|
||||
|
||||
}
|
||||
|
||||
handleMoney = () => {
|
||||
this.setState({onMoney:true})
|
||||
}
|
||||
|
||||
handleCloseMoney = () => {
|
||||
this.setState({onMoney:false})
|
||||
}
|
||||
|
||||
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>)
|
||||
|
@ -148,9 +187,15 @@ export default class Stock extends React.Component {
|
|||
return (
|
||||
<div id="stock">
|
||||
<Header title='Le Ticket de Caisse'/>
|
||||
<Navbar redirect="/stock" left="Monnaie" right="Le Stock"/>
|
||||
<Navbar redirect="/stock" left="Monnaie" right="Le Stock" handleMoney={this.handleMoney}/>
|
||||
<BarcodeReader onScan={this.handleScan}/>
|
||||
<SearchBar/>
|
||||
{this.state.onMoney &&
|
||||
<Money empty={this.state.empty} handleCloseAbove={this.handleCloseMoney}/>
|
||||
}
|
||||
{this.state.onNotInBdd &&
|
||||
<NotInBdd handleCloseAbove={this.closeNotInBdd}/>
|
||||
}
|
||||
{!this.state.empty ?
|
||||
<div id="articlesInline">
|
||||
{this.state.articlesJamalette.map((article) =>
|
||||
|
@ -177,7 +222,7 @@ export default class Stock extends React.Component {
|
|||
</div>
|
||||
:<div id="emptyTicketBox">
|
||||
<p id="emptyTicket">
|
||||
Scanne tes articles pour remplir le ticket de caisse !
|
||||
Scanne tes articles avec la Jamalette pour remplir le ticket de caisse !
|
||||
</p>
|
||||
</div> }
|
||||
<Footer/>
|
||||
|
|
Loading…
Reference in a new issue