Skip to content

Commit

Permalink
WIP Testing Cart
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjcai committed Oct 21, 2023
1 parent f83e719 commit eebad1e
Show file tree
Hide file tree
Showing 10 changed files with 537 additions and 4 deletions.
194 changes: 191 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"boostrap": "^2.0.0",
"dotenv": "^16.3.1",
"eslint-config-next": "13.5.2",
"next": "^13.5.4",
"react": "^18.2.0",
"react-bootstrap": "^2.9.0",
"react-dom": "18.2.0",
"styled-components": "^6.0.8"
},
Expand Down
41 changes: 41 additions & 0 deletions src/app/Store.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Col, Row } from "react-bootstrap"
import { useEffect, useState } from "react"
import { StoreItem } from "../components/cart/StoreItem"
import {fetchProducts} from "../supabase/product_queries"
import {Product} from "../schema/schema"
// eslint-disable-next-line import/prefer-default-export
export function Store() {

const [storeItems, setStoreItems] = useState<Product[]>([]); // State to store the fetched products

useEffect(() => {
// Function to fetch products and set them in the state
const fetchStoreItems = async () => {
try {
const response = await fetchProducts();
if (response.data) {
setStoreItems(response.data);
} else {
console.error('Error fetching products:', response.error);
}
} catch (error) {
console.error('Error fetching products:', error);
}
};

fetchStoreItems();
}, []);

return (
<>
<h1>Store</h1>
<Row md={2} xs={1} lg={3} className="g-3">
{storeItems.map(item => (
<Col key={item.product_id}>
<StoreItem id={0} {...item} />
</Col>
))}
</Row>
</>
)
}
Loading

0 comments on commit eebad1e

Please sign in to comment.