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