J'suis pas en train de devenir fou nonon
This commit is contained in:
parent
c7070de05e
commit
5a2f0fa8b0
@ -1,8 +1,8 @@
|
||||
import { Form } from "react-bootstrap";
|
||||
|
||||
const QtySelect = ({ qty }) => {
|
||||
const QtySelect = ({onChange, qty }) => {
|
||||
return (
|
||||
<Form.Select className="qty-select">
|
||||
<Form.Select onChange={(e)=>onChange(e.target.value)} className="qty-select">
|
||||
{Array.from(Array(qty), (e, i) => {
|
||||
return (
|
||||
<option value={i+1} key={i+1}>{i+1}</option>
|
||||
|
@ -10,11 +10,16 @@ const MorceauDetail = () => {
|
||||
const [item, setItem] = useState({});
|
||||
const [imageSrc, setImageSrc] = useState(null);
|
||||
const [itemQty, setItemQty] = useState(0);
|
||||
const [currentQty, setCurrentQty] = useState(1);
|
||||
|
||||
const isNoStock = () => {
|
||||
return item.status == 1 || item.status == 2 || item.status == 5;
|
||||
}
|
||||
|
||||
const currentQtyChange = (newQty) =>{
|
||||
setCurrentQty(newQty);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
document.title = 'Morceaux';
|
||||
async function fetchData() {
|
||||
@ -136,6 +141,7 @@ const MorceauDetail = () => {
|
||||
<div className="detail-container-controls">
|
||||
<QtySelect
|
||||
qty={isNoStock() ? 0 : itemQty}
|
||||
onChange={currentQtyChange}
|
||||
/>
|
||||
<Button disabled={isNoStock()} className="add-to-cart">
|
||||
Ajouter au panier
|
||||
|
Loading…
Reference in New Issue
Block a user