diff --git a/GrossesMitaines/grosses-mitaines-ui/src/components/Ajouter.js b/GrossesMitaines/grosses-mitaines-ui/src/components/Ajouter.js index ee2f5db..5a909e1 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/components/Ajouter.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/components/Ajouter.js @@ -133,15 +133,15 @@ const Ajouter = ({ onCreation }) => { }}> Disponible {/*Le nom de l'option*/} - { + { setStatus("Indisponible"); - setStatusValue(1); + setStatusValue(2); }}> Indisponible - { + { setStatus("En Commande"); - setStatusValue(2); + setStatusValue(1); }}> En Commande diff --git a/GrossesMitaines/grosses-mitaines-ui/src/components/Modify.js b/GrossesMitaines/grosses-mitaines-ui/src/components/Modify.js index 95e173e..fd783b2 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/components/Modify.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/components/Modify.js @@ -157,15 +157,15 @@ const Modify = ({ morceau, onModify }) => { }}> Disponible {/*Le nom de l'option*/} - { + { setStatus("Indisponible"); - setStatusValue(1); + setStatusValue(2); }}> Indisponible - { + { setStatus("En Commande"); - setStatusValue(2); + setStatusValue(1); }}> En Commande diff --git a/GrossesMitaines/grosses-mitaines-ui/src/components/QtySelect.js b/GrossesMitaines/grosses-mitaines-ui/src/components/QtySelect.js new file mode 100644 index 0000000..bc2cfa1 --- /dev/null +++ b/GrossesMitaines/grosses-mitaines-ui/src/components/QtySelect.js @@ -0,0 +1,16 @@ +import { Form } from "react-bootstrap"; + +const QtySelect = ({ qty }) => { + return ( + + {Array.from(Array(qty), (e, i) => { + return ( + + ) + })} + + ); + +} + +export default QtySelect; \ No newline at end of file diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/MorceauDetail.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/MorceauDetail.js index 400cbbd..25cea8a 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/pages/MorceauDetail.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/MorceauDetail.js @@ -1,6 +1,8 @@ import { useEffect } from "react"; import { useParams } from "react-router-dom"; import { useState } from "react"; +import { Button } from "react-bootstrap"; +import QtySelect from "../components/QtySelect"; const MorceauDetail = () => { @@ -8,6 +10,25 @@ const MorceauDetail = () => { const [item, setItem] = useState({}); const [isLoading, setIsLoading] = useState(false); const [imageSrc, setImageSrc] = useState(null); + const [itemQty, setItemQty] = useState(0); + + + const updateQty = () => { + window.setTimeout(() => { + fetch(`https://localhost:7292/api/Product/Quantity?id=${id}`) + .then(async (response) => { + if (response.ok) { + const qty = await response.json(); + setItemQty(qty); + } + else { + console.log("Un erreur est survenu lors de l'appelle de: " + + `https://localhost:7292/api/Product/Quantity?id=${id}`); + } + updateQty(); + }) + }, 10000); + } useEffect(() => { document.title = 'Morceaux'; @@ -16,6 +37,7 @@ const MorceauDetail = () => { const response = await fetch(`https://localhost:7292/api/Product?id=${id}`); const json = await response.json(); setItem(json); + setItemQty(json.quantity); } @@ -48,12 +70,12 @@ const MorceauDetail = () => { else { return ( <> -

- {price.toFixed(2).toString().replace(".", ",")} $ CA -

{newPrice.toFixed(2).toString().replace(".", ",")} $ CA

+
+ {price.toFixed(2).toString().replace(".", ",")} $ CA +
); } @@ -112,23 +134,34 @@ const MorceauDetail = () => { return ( <>
-
+
-

{item.description}

-
+

{item.title}

-

Catégorie: {item.category}

-
- {renderPrice(item.price, item.promoPrice, item.status)} -
+

({item.category})

+
{renderStatus(item.status)}
+
+ {renderPrice(item.price, item.promoPrice, item.status)} +
+
- Quantité: {item.quantity} + Qté. restante: {item.status == 1 || item.status == 2 || item.status == 5 ? "Aucun" : itemQty}
+

{item.description}

+
+
+ + +
diff --git a/GrossesMitaines/grosses-mitaines-ui/src/stylesheets/site.css b/GrossesMitaines/grosses-mitaines-ui/src/stylesheets/site.css index 1933ebc..20ccf9d 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/stylesheets/site.css +++ b/GrossesMitaines/grosses-mitaines-ui/src/stylesheets/site.css @@ -592,34 +592,86 @@ a { height: 200px; } + + +.detail-status-container { + margin-top: 25px; +} + +.detail-status-available { + +} + +.detail-status-backorder {} + +.detail-status-unavailable {} + +.detail-status-clearence {} + +.detail-status-promotion {} + +.detail-status-discontinued {} + + .detail-container { display: flex; - background-color: plum; + background-color: white; padding: 16px; } -.detail-container-left { - margin: auto; - width: 48%; +.detail-container-image { + margin:auto; + margin-top:25px; + width: 35%; height: 100%; } -.detail-container-right { - margin: auto; - width: 48%; + +.detail-container-info { + margin:auto; + width: 35%; height: 100%; } +.detail-container-controls { + margin:auto; + display:inline-flex; + width:20%; + height:100%; +} + +.qty-select { + width: fit-content; + height:fit-content; + margin:auto; +} + +.add-to-cart{ + width:auto; + margin-left: 10px; +} + .detail-image { width: 100%; height: auto; } +.detail-price{ + font-weight: bold; +} + +.detail-new-price { + font-weight: bold; +} + .detail-old-price { + font-weight: lighter; text-decoration: line-through; } + + .btn-fermer { background-color: red !important; color: white !important; @@ -662,7 +714,7 @@ a { } #cart-count { - color:green; + color: green; } @@ -689,11 +741,11 @@ a { display: inline-block; } - .detail-container-left { + .detail-container-image { width: 95%; } - .detail-container-right { + .detail-container-info { width: 95%; }