Skip to content

Commit

Permalink
Wired up commercejs
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtweedy committed Feb 4, 2021
1 parent bc146c1 commit 7987f0c
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 50 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_CHEC_PUBLIC_KEY=pk_test_193037b865ee81e89ff82cb93aa448630d5614b9b0098
16 changes: 16 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@capacitor/core": "2.4.6",
"@chec/commerce.js": "^2.3.1",
"@ionic/react": "^5.5.0",
"@ionic/react-router": "^5.5.0",
"@testing-library/jest-dom": "^5.11.9",
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Redirect, Route } from "react-router-dom";
import { IonApp, IonRouterOutlet, setupConfig, isPlatform } from "@ionic/react";
import { IonReactRouter } from "@ionic/react-router";
import Home from "./pages/Home";
import Home from "./pages/home/Home";

/* Core CSS required for Ionic components to work properly */
import "@ionic/react/css/core.css";
Expand Down
24 changes: 0 additions & 24 deletions src/components/ExploreContainer.css

This file was deleted.

14 changes: 0 additions & 14 deletions src/components/ExploreContainer.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions src/components/product-listing/ProductListing.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.container {

}
15 changes: 15 additions & 0 deletions src/components/product-listing/ProductListing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import "./ProductListing.css";

interface ProductListingProps {
product: object;
}

const ProductListing: React.FC<ProductListingProps> = ({ product }) => {
return (
<div className="container">
<p>My product</p>
</div>
);
};

export default ProductListing;
File renamed without changes.
20 changes: 18 additions & 2 deletions src/pages/Home.tsx → src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import {
IonCol,
IonContent,
IonGrid,
IonHeader,
IonPage,
IonRow,
IonTitle,
IonToolbar,
} from "@ionic/react";
import ExploreContainer from "../components/ExploreContainer";
import "./Home.css";
import Commerce from "@chec/commerce.js";
import { useEffect, useState } from "react";

const Home: React.FC = () => {
const [products, setProducts] = useState([]);

useEffect(() => {
const commerce = new Commerce(process.env.REACT_APP_CHEC_PUBLIC_KEY);
commerce.products.list().then((products) => setProducts(products));
}, []);

return (
<IonPage>
<IonHeader>
Expand All @@ -22,7 +33,12 @@ const Home: React.FC = () => {
<IonTitle size="large">ChopChop</IonTitle>
</IonToolbar>
</IonHeader>
<ExploreContainer />
<IonGrid>
<IonRow>
<IonCol>1 of 2</IonCol>
<IonCol>2 of 2</IonCol>
</IonRow>
</IonGrid>
</IonContent>
</IonPage>
);
Expand Down
12 changes: 3 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
Expand All @@ -20,7 +16,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
"include": ["src"]
}

0 comments on commit 7987f0c

Please sign in to comment.