Skip to content

Commit b7ce3d6

Browse files
committed
Add ssrMode to ApolloClient and make checkout responsive
1 parent 891358a commit b7ce3d6

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

components/Checkout/OrderDetails.component.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ const OrderDetails = ({ cart }) => {
99
{cart ? (
1010
<div className="p-6 mx-auto mt-5">
1111
<CheckoutTitle title="Handlekurv" />
12-
12+
1313
<table className="table-auto">
1414
<thead>
15-
<tr>
16-
<th className="px-4 py-2" scope="col" />
15+
<tr>
1716
<th className="px-4 py-2" scope="col" />
1817
<th className="px-4 py-2" scope="col">
1918
Produkt

components/Checkout/OrderDetailsCartItem.component.jsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
import { useState } from 'react';
22

3-
import SVGCloseX from 'components/SVG/SVGCloseX.component';
4-
5-
const OrderDetailsCartItem = ({
6-
item,
7-
products,
8-
updateCartProcessing,
9-
handleRemoveProductClick,
10-
updateCart,
11-
}) => {
3+
const OrderDetailsCartItem = ({ item }) => {
124
const [productCount, setProductCount] = useState(item.qty);
135

146
return (
157
<tr className="bg-gray-100">
16-
<td className="px-4 py-2 border">
17-
<SVGCloseX />
18-
</td>
19-
<td className="px-4 py-2 border">
8+
<td className="px-0 py-2 border sm:px-4 md:px-4 lg:px-4 xl:px-4">
209
<img
10+
className="hidden sm:block md:block lg:block xl:block"
2111
width="64"
2212
src={item.image.sourceUrl}
2313
srcSet={item.image.srcSet}
@@ -31,19 +21,13 @@ const OrderDetailsCartItem = ({
3121
{'string' !== typeof item.price ? item.price.toFixed(2) : item.price}
3222
</td>
3323

34-
<td className="px-4 py-2 border">
35-
<input type="number" min="1" value={productCount} />
36-
</td>
24+
<td className="px-4 py-2 border">{productCount}</td>
3725

3826
<td className="px-4 py-2 border">
3927
{'string' !== typeof item.totalPrice
4028
? item.totalPrice.toFixed(2)
4129
: item.totalPrice}
4230
</td>
43-
44-
45-
46-
4731
</tr>
4832
);
4933
};

pages/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import { FETCH_ALL_PRODUCTS_QUERY } from 'utils/const/GQL_QUERIES';
1414
const HomePage = ({ products }) => {
1515
return (
1616
<>
17-
18-
<Hero/>
17+
<Hero />
1918
<PageTitle title="Produkter" />
2019
{products && <IndexProducts products={products} />}
2120
</>
@@ -24,10 +23,10 @@ const HomePage = ({ products }) => {
2423

2524
export default HomePage;
2625

27-
//export async function getStaticProps() {
28-
export async function getServerSideProps() {
26+
export async function getStaticProps() {
27+
//export async function getServerSideProps() {
28+
2929
const { data, loading, networkStatus } = await client.query({
30-
//const result = await client.query({
3130
query: FETCH_ALL_PRODUCTS_QUERY,
3231
});
3332

@@ -37,5 +36,6 @@ export async function getServerSideProps() {
3736
loading: loading,
3837
networkStatus: networkStatus,
3938
},
39+
unstable_revalidate: 5,
4040
};
4141
}

utils/apollo/ApolloClient.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const afterware = new ApolloLink((operation, forward) => {
6767

6868
// Apollo GraphQL client.
6969
const client = new ApolloClient({
70+
ssrMode: typeof window === 'undefined',
7071
link: middleware.concat(
7172
afterware.concat(
7273
createHttpLink({

0 commit comments

Comments
 (0)