loading first item when open morceaux. Pi j'ai enlevé le height du root parce que ça fait que le foot est par dessus du stock

This commit is contained in:
Victor Turgeon 2022-10-18 00:34:43 -07:00
parent cf3647fe73
commit b9787c7aff
6 changed files with 124 additions and 89 deletions

View File

@ -13,6 +13,7 @@
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"axios": "^1.1.3", "axios": "^1.1.3",
"bootstrap": "^5.2.1", "bootstrap": "^5.2.1",
"fa": "^1.0.1",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-bootstrap": "^2.5.0", "react-bootstrap": "^2.5.0",
@ -8427,6 +8428,14 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
}, },
"node_modules/fa": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/fa/-/fa-1.0.1.tgz",
"integrity": "sha512-9uU7yoeKcoXvONbZuoRAEzIz/v80RlS6QfN4sWWyrpy5rScGrDPxpeZ3AV6y+jssjFJUEQoZiR5lgXBLrtAHKQ==",
"engines": {
"node": "*"
}
},
"node_modules/fast-deep-equal": { "node_modules/fast-deep-equal": {
"version": "3.1.3", "version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@ -24554,6 +24563,11 @@
} }
} }
}, },
"fa": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/fa/-/fa-1.0.1.tgz",
"integrity": "sha512-9uU7yoeKcoXvONbZuoRAEzIz/v80RlS6QfN4sWWyrpy5rScGrDPxpeZ3AV6y+jssjFJUEQoZiR5lgXBLrtAHKQ=="
},
"fast-deep-equal": { "fast-deep-equal": {
"version": "3.1.3", "version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",

View File

@ -8,6 +8,7 @@
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"axios": "^1.1.3", "axios": "^1.1.3",
"bootstrap": "^5.2.1", "bootstrap": "^5.2.1",
"fa": "^1.0.1",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-bootstrap": "^2.5.0", "react-bootstrap": "^2.5.0",

View File

@ -9,6 +9,8 @@ import { Card } from "react-bootstrap";
// Discontinued // Discontinued
// } // }
function renderStatus(statusCode) { function renderStatus(statusCode) {
if (statusCode !== undefined) {
switch (statusCode) { switch (statusCode) {
case 0: case 0:
return ( return (
@ -54,7 +56,11 @@ function renderStatus(statusCode) {
} }
} }
}
function renderPrice(price, newPrice, status) { function renderPrice(price, newPrice, status) {
if (price !== undefined) {
if (status != 3 && status != 4) { if (status != 3 && status != 4) {
return ( return (
@ -77,10 +83,12 @@ function renderPrice(price, newPrice, status) {
</Card.Text> </Card.Text>
); );
} }
}
} }
const Item = ({ imageUrl, name, price, newPrice, status }) => { const Item = ({ imageUrl, name, price, newPrice, status }) => {
if (name !== undefined) {
return ( return (
<Card className="item"> <Card className="item">
@ -102,5 +110,9 @@ const Item = ({ imageUrl, name, price, newPrice, status }) => {
</Card> </Card>
); );
} }
else {
return (<></>);
}
}
export default Item; export default Item;

View File

@ -18,7 +18,7 @@ const MorceauDetail = () => {
} }
fetchData(); fetchData();
setIsLoading(false); setIsLoading(false);
}); },[]);
function renderPrice(price, newPrice, status) { function renderPrice(price, newPrice, status) {
if (price !== undefined) { if (price !== undefined) {

View File

@ -6,11 +6,6 @@ import Sorting from "../components/Sorting"
const Morceaux = (startingProducts) => { const Morceaux = (startingProducts) => {
useEffect(() => {
document.title = 'Morceaux';
});
const [products, setProducts] = useState([]); const [products, setProducts] = useState([]);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
@ -18,6 +13,19 @@ const Morceaux = (startingProducts) => {
var filterPrice = ""; var filterPrice = "";
var filterState = ""; var filterState = "";
useEffect(() => {
document.title = 'Morceaux';
setIsLoading(true);
async function fetchData() {
const response = await fetch(`https://localhost:7292/api/Inventory`);
const json = await response.json();
if (json.length > 0)
setProducts([...json]);
}
fetchData();
setIsLoading(false);
},[]);
const handleNextItems = async () => { const handleNextItems = async () => {
var url; var url;
@ -57,7 +65,7 @@ const Morceaux = (startingProducts) => {
} }
return ( return (
<div className="morceaux"div> <div className="morceaux">
<div className="sorting-container"> <div className="sorting-container">
<Sorting onChange={handleOrder} /> <Sorting onChange={handleOrder} />
</div> </div>

View File

@ -1,5 +1,5 @@
#root { #root {
height: 100vh; min-height: 100vh;
} }
body { body {