Nouvelle View : Ticket

This commit is contained in:
Kongzibapt 2021-01-30 10:02:06 +01:00
parent fb2673ffc8
commit 5c15b94cc3
6 changed files with 54 additions and 12 deletions

0
src/css/Views/ticket.css Normal file
View file

View file

@ -2,6 +2,7 @@ import React from 'react';
import {Switch, Route} from "react-router-dom"; import {Switch, Route} from "react-router-dom";
import Stock from '../Views/Stock'; import Stock from '../Views/Stock';
import Home from '../Views/Home'; import Home from '../Views/Home';
import Ticket from '../Views/Ticket';
class AppRouter extends React.Component { class AppRouter extends React.Component {
render() { render() {
@ -9,6 +10,7 @@ import Home from '../Views/Home';
<> <>
<Switch> <Switch>
<Route exact path="/stock" component={Stock}/> <Route exact path="/stock" component={Stock}/>
<Route exact path="/ticket" component={Ticket}/>
<Route exact path="/" component={Home}/> <Route exact path="/" component={Home}/>
</Switch> </Switch>
</> </>

View file

@ -1,4 +1,5 @@
import React from 'react' import React from 'react'
import { Redirect } from 'react-router';
import '../../css/Components/navbar.css'; import '../../css/Components/navbar.css';
@ -19,7 +20,14 @@ class Navbar extends React.Component {
this.setState({mouseOn:false}) this.setState({mouseOn:false})
} }
navToTicket = () => {
this.setState({redirect:true})
}
render(){ render(){
if (this.state.redirect){
return (<Redirect to="/ticket"/>)
}
return ( return (
<div id="navbar"> <div id="navbar">
<div id="createedit" onClick={this.handleDisplay} onMouseLeave={this.handleNormal}> <div id="createedit" onClick={this.handleDisplay} onMouseLeave={this.handleNormal}>
@ -29,8 +37,8 @@ class Navbar extends React.Component {
<div id="blank"> <div id="blank">
OK OK
</div> </div>
<div id="update"> <div id="update" onClick={this.navToTicket}>
<p>Mettre à jour</p> <p>Le Ticket de Caisse</p>
</div> </div>
</div> </div>
) )

View file

@ -19,6 +19,7 @@ class Sort extends Component {
<div id="selectBlock"> <div id="selectBlock">
<div id="selectBox"> <div id="selectBox">
<select id="sortSelect" onChange={this.props.handleChangeSortType}> <select id="sortSelect" onChange={this.props.handleChangeSortType}>
<option className="optionSort" value="Id"></option>
<option className="optionSort" value="Ordre Alphabétique">Ordre Alphabétique</option> <option className="optionSort" value="Ordre Alphabétique">Ordre Alphabétique</option>
<option className="optionSort" value="Catégorie">Catégorie</option> <option className="optionSort" value="Catégorie">Catégorie</option>
<option className="optionSort" value="Quantité">Quantité</option> <option className="optionSort" value="Quantité">Quantité</option>

View file

@ -30,19 +30,18 @@ export default class Stock extends React.Component {
imageFile:{}, imageFile:{},
search:'', search:'',
articles:[], articles:[],
categoryToModify:'', categoryToModify:''
sortType:''
} }
} }
componentDidMount() { componentDidMount() {
this.getArticles("name") this.getArticles()
} }
getArticles = sortType => { // Implémenter la fonction sortArticles :
let bodyFormData = new FormData();
bodyFormData.set('sortType', sortType) getArticles = () => {
axios.post('https://etud.insa-toulouse.fr/~proximo/v2/api/articles/sort',bodyFormData) axios.get('https://etud.insa-toulouse.fr/~proximo/v2/api/articles')
.then(res => { .then(res => {
this.setState({articles : res.data}, () => { this.setState({articles : res.data}, () => {
console.log(this.state.articles) console.log(this.state.articles)
@ -130,11 +129,11 @@ export default class Stock extends React.Component {
handleChangeSortType = e => { handleChangeSortType = e => {
this.setState({sortType:e.target.value},()=>{ this.setState({sortType:e.target.value},()=>{
if (this.state.sortType === "Ordre Alphabétique"){ if (this.state.sortType === "Ordre Alphabétique"){
this.getArticles("name") this.sortArticles("name")
} else if(this.state.sortType === "Catégorie"){ } else if(this.state.sortType === "Catégorie"){
this.getArticles("category_id") this.sortArticles("category_id")
} else if(this.state.sortType === "Quantité"){ } else if(this.state.sortType === "Quantité"){
this.getArticles("quantity") this.sortArticles("quantity")
} }
}) })

32
src/js/Views/Ticket.js Normal file
View file

@ -0,0 +1,32 @@
import React from 'react';
import '../../css/Views/ticket.css';
import Header from '../Components/Header';
import Navbar from '../Components/Navbar';
import 'react-perfect-scrollbar/dist/css/styles.css';
import Footer from '../Components/Footer';
import { Link } from 'react-router-dom';
export default class Stock extends React.Component {
constructor(props){
super(props)
this.state = {
}
}
componentDidMount() {
}
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">
<Header title='Le Ticket de Caisse'/>
<Navbar/>
<Footer/>
</div>
)}
}
}