Setup pour list d'invoices/commandes

This commit is contained in:
Victor Turgeon 2022-11-07 20:57:38 -05:00
parent fa7e93261e
commit 6d29d85edf
4 changed files with 56 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import Login from "../pages/Login";
import Logout from "../pages/Logout";
import Register from "../pages/Register";
import Formulaire from "../pages/Formulaire";
import MyInvoices from "../pages/MyInvoices";
import { useState, useEffect } from "react";
import React from 'react';
import { useCookies } from 'react-cookie';
@ -47,6 +48,7 @@ const App = () => {
<Route path="logout" element={<Logout/>}/>
<Route path="register" element={<Register/>}/>
<Route path="formulaire" element={<Formulaire/>}/>
<Route path="myinvoices" element={<MyInvoices/>}/>
</Route>
</Routes>
</BrowserRouter>

View File

@ -0,0 +1,11 @@
const InvoiceItem = (invoice) => {
return (
<>
Invoice Item
</>
);
}
export default InvoiceItem;

View File

@ -0,0 +1,15 @@
import InvoiceItem from "./InvoiceItem";
const InvoiceList = ({ invoices }) => {
return (
<>
{invoices.map((invoice) => {
<InvoiceItem
invoice={invoice}
/>
})}
</>
);
}
export default InvoiceList;

View File

@ -0,0 +1,28 @@
import { useEffect } from "react";
import { useState } from "react";
import InvoiceList from "../components/InvoiceList";
const MyInvoices = () => {
const [invoices, setInvoices] = useState([]);
useEffect(() => {
fetch(`https://localhost:7292/api/Invoices`, {
method: 'GET',
mode: 'cors',
credentials: 'include'
}).then(async (response) => {
console.log(response);
});
}, []);
return (
<>
<InvoiceList
invoices={invoices}
/>
</>
);
}
export default MyInvoices