-
Notifications
You must be signed in to change notification settings - Fork 8
/
Home.tsx
84 lines (80 loc) · 2.08 KB
/
Home.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import {
IonCol,
IonContent,
IonFooter,
IonGrid,
IonHeader,
IonIcon,
IonImg,
IonPage,
IonRow,
IonSplitPane,
IonTitle,
IonToolbar,
} from "@ionic/react";
import "./Home.css";
import Commerce from "@chec/commerce.js";
import { useEffect, useState } from "react";
import ProductCard from "../../components/product/product-card/ProductCard";
const Home: React.FC = () => {
const [products, setProducts] = useState([]);
useEffect(() => {
const commerce = new Commerce(process.env.REACT_APP_CHEC_PUBLIC_KEY);
commerce.products
.list({ active: 1 })
.then((products) => setProducts(products.data));
}, []);
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>
<img src="assets/chopchop.svg" height="28px" width="144px" />
</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent fullscreen>
<IonHeader collapse="condense">
<IonToolbar>
<IonTitle size="large">
<img src="assets/chopchop.svg" height="28px" />
</IonTitle>
</IonToolbar>
</IonHeader>
<IonGrid>
<IonRow>
<IonCol className="ion-hide-md-down" size="5">
</IonCol>
<IonCol>
<IonGrid>
<IonRow>
{products.map((product) => {
return (
<IonCol
size="12"
sizeSm="6"
sizeMd="6"
sizeLg="6"
sizeXl="6"
key={product.id}
>
<ProductCard product={product} />
</IonCol>
);
})}
</IonRow>
</IonGrid>
</IonCol>
</IonRow>
</IonGrid>
</IonContent>
<IonFooter>
<IonToolbar>
<IonTitle>Powered By Commerce.JS</IonTitle>
</IonToolbar>
</IonFooter>
</IonPage>
);
};
export default Home;