diff --git a/src/Components/Products/BlobView/BlobView.tsx b/src/Components/Products/BlobView/BlobView.tsx new file mode 100644 index 0000000..3a0cbe0 --- /dev/null +++ b/src/Components/Products/BlobView/BlobView.tsx @@ -0,0 +1,29 @@ +import * as React from "react"; + +import styles from "../../../styles"; +import { ProductList } from "../../../Interfaces/Interfaces"; + +export default function BlobView({ Products }: ProductList) { + return ( +
+ {Products.map((row) => ( +
+

{row.name}

+

ID: {row.id}

+

Last Modified: {row.last_modified}

+
+ ))} +
+ ); +} diff --git a/src/Components/Products/TableView/TableView.tsx b/src/Components/Products/TableView/TableView.tsx new file mode 100644 index 0000000..8cfda06 --- /dev/null +++ b/src/Components/Products/TableView/TableView.tsx @@ -0,0 +1,45 @@ +import * as React from "react"; +import { + Button, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, +} from "@mui/material"; +import styles from "../../../styles"; +import { ProductList } from "../../../Interfaces/Interfaces"; + +export default function TableView({ Products }: ProductList) { + return ( + + + + + Product ID + Product + Last Modified + + + + {Products.map((row) => ( + + {row.id} + {row.name} + {row.last_modified} + + ))} + +
+
+ ); +} diff --git a/src/Interfaces/Interfaces.tsx b/src/Interfaces/Interfaces.tsx new file mode 100644 index 0000000..13037cf --- /dev/null +++ b/src/Interfaces/Interfaces.tsx @@ -0,0 +1,9 @@ +export interface ProductList { + Products: Product[]; +} + +export interface Product { + id: number; + name: string; + last_modified: string; +} diff --git a/src/Routes/Products/Products.tsx b/src/Routes/Products/Products.tsx index b651bb7..bf51052 100644 --- a/src/Routes/Products/Products.tsx +++ b/src/Routes/Products/Products.tsx @@ -1,22 +1,23 @@ -import React from "react"; +import React, { useState } from "react"; import styles from "../../styles"; import { useNavigate } from "react-router-dom"; import ProductsIcon from "../../Components/Icons/ProductsIcon/ProductsIcon"; import AddIcon from "../../Components/Icons/AddIcon/AddIcon"; -import { - Button, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, -} from "@mui/material"; +import { Button, Switch } from "@mui/material"; import { SampleProducts } from "../../Components/SampleData/SampleData"; +import TableView from "../../Components/Products/TableView/TableView"; +import BlobView from "../../Components/Products/BlobView/BlobView"; export default function Products() { const navigate = useNavigate(); - + const [tableView, toggleTableView] = useState(false); + function view() { + if (tableView) { + return ; + } else { + return ; + } + } return (
@@ -41,34 +42,8 @@ export default function Products() {
- - - - - Product ID - Product - Last Modified - - - - {SampleProducts.map((row) => ( - - {row.id} - {row.name} - {row.last_modified} - - ))} - -
-
+ toggleTableView(!tableView)} /> + {view()} ); }