loading cat in inventory

This commit is contained in:
Victor Turgeon 2022-11-01 19:07:35 -04:00
parent 16e0321db0
commit e92dfc0772

View File

@ -7,8 +7,10 @@ const Inventaire = () => {
const [morceaux, setMorceaux] = useState([]);
const [isFormvisible, setFormVisibility] = useState(false);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
document.title = 'Inventaire';
async function fetchData() {
const response = await fetch(`https://localhost:7292/api/Inventory?all=true`);
const json = await response.json();
@ -16,7 +18,7 @@ const Inventaire = () => {
setMorceaux([...json]);
}
fetchData();
document.title = 'Inventaire';
setIsLoading(false);
}, []);
const handleAddItem = async (morceau) => {
@ -101,6 +103,7 @@ const Inventaire = () => {
</header>
{isFormvisible && <Ajouter onCreation={handleAddItem}></Ajouter>}
{isLoading && <div className="cat-load" />}
{morceaux.length > 0 ?
(<SimpleItemList simpleItems={morceaux}
onDelete={handleDeleteItem}