From 9b186a17256d96952d5527e512dbf16f836637e9 Mon Sep 17 00:00:00 2001 From: David Belisle <79233327+DavidBelisle@users.noreply.github.com> Date: Tue, 18 Oct 2022 11:55:30 -0400 Subject: [PATCH 1/2] correction error messages --- .../src/components/Ajouter.js | 50 ++++++++++++++++++- .../grosses-mitaines-ui/src/pages/Home.js | 2 +- .../src/pages/MorceauDetail.js | 8 +-- 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/GrossesMitaines/grosses-mitaines-ui/src/components/Ajouter.js b/GrossesMitaines/grosses-mitaines-ui/src/components/Ajouter.js index 91ad91a..be57fde 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/components/Ajouter.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/components/Ajouter.js @@ -1,19 +1,23 @@ import { useState } from "react" +import { Dropdown } from "react-bootstrap"; const Ajouter = ({ onCreation }) => { + const [currentStatus, setStatus] = useState("Disponible"); + const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [category, setCategory] = useState(""); const [price, setPrice] = useState(""); const [quantity, setQuantity] = useState(""); const [imageName, setImageName] = useState("sqdc.jpg"); + const [statusValue, setStatusValue] = useState(0) const handleSubmit = (e) => { e.preventDefault(); // Empêcher de reloader la page au submit. // Appeler le comportement onCreation - onCreation({ title, description, category, price, quantity, imageName }) + onCreation({ title, description, category, price, quantity, imageName, statusValue }) // Reset les états du formulaire. setTitle("") @@ -71,6 +75,50 @@ const Ajouter = ({ onCreation }) => { value={imageName} onChange={(e) => setImageName(e.target.value)} /> + + + {currentStatus} + + + + { + setStatus("Disponible"); // Mets le nom afficher quand le dropdown est fermé + setStatusValue(0); + }}> + Disponible {/*Le nom de l'option*/} + + { + setStatus("Indisponible"); + setStatusValue(1); + }}> + Indisponible + + { + setStatus("En Commande"); + setStatusValue(2); + }}> + En Commande + + { + setStatus("Liquidation"); + setStatusValue(3); + }}> + Liquidation + + { + setStatus("Promotion"); + setStatusValue(4); + }}> + Promotion + + { + setStatus("Discontinué"); + setStatusValue(5); + }}> + Discontinué + + + diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/Home.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/Home.js index 9d6dd78..92afb71 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/pages/Home.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/Home.js @@ -36,7 +36,7 @@ const Home = () => {

Les Grosses Mitaines

(à Ginette et Monique)

- + home

Des produits bien commodes faits par des aînées d'expérience.

diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/MorceauDetail.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/MorceauDetail.js index b79a18e..8778daa 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/pages/MorceauDetail.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/MorceauDetail.js @@ -1,5 +1,5 @@ import { useEffect } from "react"; -import { json, useParams } from "react-router-dom"; +import { useParams } from "react-router-dom"; import { useState } from "react"; const MorceauDetail = () => { @@ -18,11 +18,11 @@ const MorceauDetail = () => { } fetchData(); setIsLoading(false); - },[]); + }); function renderPrice(price, newPrice, status) { if (price !== undefined) { - if (status != 3 && status != 4) { + if (status !== 3 && status !== 4) { return (

{price.toFixed(2).toString().replace(".", ",")} $ CA @@ -99,7 +99,7 @@ const MorceauDetail = () => {
- +

{item.description}

From d031b0b998b1ed6d5b93ab418183f5af4a213f79 Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Tue, 18 Oct 2022 11:53:57 -0700 Subject: [PATCH 2/2] Update InventoryController.cs --- .../Controllers/InventoryController.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs index 4f8210e..40baa59 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs @@ -105,14 +105,16 @@ public class InventoryController : Controller { // Inventory/Delete => Décrémenter un produit. [EnableCors("_myAllowSpecificOrigins")] [HttpDelete(Name = "Inventory")] - public void Delete(int? id) { + public ActionResult Delete(int? id) { + int rid = 0; if (!id.HasValue) { _logger.LogError(8, "Delete sans Id."); - return; + return BadRequest(); } try { Product prod = _context.Products.First(x => x.Id == id); + rid = prod.Id; if (prod.Quantity > 0) { prod.Quantity = prod.Quantity - 1; if (prod.Quantity == 0) @@ -122,13 +124,15 @@ public class InventoryController : Controller { } else { _logger.LogError(8, "Vente de produit pas en stock."); - return; + return BadRequest(); } _context.Products.Update(prod); _context.SaveChanges(); } catch (Exception e) { _logger.LogError(8, e.Message); + return BadRequest(); } + return rid; } }