-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
537 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
) | ||
} |
Oops, something went wrong.