correction error messages

This commit is contained in:
David Belisle 2022-10-18 11:55:30 -04:00
parent 2ebe676626
commit 9b186a1725
3 changed files with 54 additions and 6 deletions

View File

@ -1,19 +1,23 @@
import { useState } from "react" import { useState } from "react"
import { Dropdown } from "react-bootstrap";
const Ajouter = ({ onCreation }) => { const Ajouter = ({ onCreation }) => {
const [currentStatus, setStatus] = useState("Disponible");
const [title, setTitle] = useState(""); const [title, setTitle] = useState("");
const [description, setDescription] = useState(""); const [description, setDescription] = useState("");
const [category, setCategory] = useState(""); const [category, setCategory] = useState("");
const [price, setPrice] = useState(""); const [price, setPrice] = useState("");
const [quantity, setQuantity] = useState(""); const [quantity, setQuantity] = useState("");
const [imageName, setImageName] = useState("sqdc.jpg"); const [imageName, setImageName] = useState("sqdc.jpg");
const [statusValue, setStatusValue] = useState(0)
const handleSubmit = (e) => { const handleSubmit = (e) => {
e.preventDefault(); // Empêcher de reloader la page au submit. e.preventDefault(); // Empêcher de reloader la page au submit.
// Appeler le comportement onCreation // Appeler le comportement onCreation
onCreation({ title, description, category, price, quantity, imageName }) onCreation({ title, description, category, price, quantity, imageName, statusValue })
// Reset les états du formulaire. // Reset les états du formulaire.
setTitle("") setTitle("")
@ -71,6 +75,50 @@ const Ajouter = ({ onCreation }) => {
value={imageName} value={imageName}
onChange={(e) => setImageName(e.target.value)} /> onChange={(e) => setImageName(e.target.value)} />
</div> </div>
<Dropdown className='status-dropdown'>
<Dropdown.Toggle id="dropdown-status">
{currentStatus}
</Dropdown.Toggle>
<Dropdown.Menu className='sorting-menu'>
<Dropdown.Item key="0" onClick={() => {
setStatus("Disponible"); // Mets le nom afficher quand le dropdown est fermé
setStatusValue(0);
}}>
Disponible {/*Le nom de l'option*/}
</Dropdown.Item>
<Dropdown.Item key="1" onClick={() => {
setStatus("Indisponible");
setStatusValue(1);
}}>
Indisponible
</Dropdown.Item>
<Dropdown.Item key="2" onClick={() => {
setStatus("En Commande");
setStatusValue(2);
}}>
En Commande
</Dropdown.Item>
<Dropdown.Item key="3" onClick={() => {
setStatus("Liquidation");
setStatusValue(3);
}}>
Liquidation
</Dropdown.Item>
<Dropdown.Item key="4" onClick={() => {
setStatus("Promotion");
setStatusValue(4);
}}>
Promotion
</Dropdown.Item>
<Dropdown.Item key="5" onClick={() => {
setStatus("Discontinué");
setStatusValue(5);
}}>
Discontinué
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
<input className="btn-primary ajouter" type="submit" value="Ajouter Morceau"></input> <input className="btn-primary ajouter" type="submit" value="Ajouter Morceau"></input>
</form> </form>

View File

@ -36,7 +36,7 @@ const Home = () => {
<div className="home-text"> <div className="home-text">
<h1 className="home-title">Les Grosses Mitaines</h1> <h1 className="home-title">Les Grosses Mitaines</h1>
<h4 className="home-subtitle">(à Ginette et Monique)</h4> <h4 className="home-subtitle">(à Ginette et Monique)</h4>
<img src="/images/LesGrossesMitaines.png" className="home-img"/> <img src="/images/LesGrossesMitaines.png" className="home-img" alt="home"/>
<br/> <br/>
<h2 className="home-description">Des produits bien commodes faits par des aînées d'expérience.</h2> <h2 className="home-description">Des produits bien commodes faits par des aînées d'expérience.</h2>
</div> </div>

View File

@ -1,5 +1,5 @@
import { useEffect } from "react"; import { useEffect } from "react";
import { json, useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { useState } from "react"; import { useState } from "react";
const MorceauDetail = () => { const MorceauDetail = () => {
@ -18,11 +18,11 @@ const MorceauDetail = () => {
} }
fetchData(); fetchData();
setIsLoading(false); setIsLoading(false);
},[]); });
function renderPrice(price, newPrice, status) { function renderPrice(price, newPrice, status) {
if (price !== undefined) { if (price !== undefined) {
if (status != 3 && status != 4) { if (status !== 3 && status !== 4) {
return ( return (
<h3 className="detail-price"> <h3 className="detail-price">
{price.toFixed(2).toString().replace(".", ",")} $ CA {price.toFixed(2).toString().replace(".", ",")} $ CA
@ -99,7 +99,7 @@ const MorceauDetail = () => {
<div className="detail-container"> <div className="detail-container">
<div className="detail-container-left"> <div className="detail-container-left">
<img className="detail-image" src={`/images/${item.imageName}.jpg`} /> <img className="detail-image" alt="" src={`/images/${item.imageName}.jpg`} />
<p className="detail-description">{item.description}</p> <p className="detail-description">{item.description}</p>
</div> </div>
<div className="detail-container-right"> <div className="detail-container-right">