File tree Expand file tree Collapse file tree 5 files changed +62
-28
lines changed Expand file tree Collapse file tree 5 files changed +62
-28
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const CheckoutForm = () => {
22
22
23
23
const [ orderData , setOrderData ] = useState ( null ) ;
24
24
const [ requestError , setRequestError ] = useState ( null ) ;
25
- const [ orderCompleted , setorderCompleted ] = useState ( false ) ;
25
+ const [ orderCompleted , setorderCompleted ] = useState ( false ) ;
26
26
27
27
// Checkout GraphQL mutation
28
28
const [
@@ -70,7 +70,7 @@ const CheckoutForm = () => {
70
70
71
71
return (
72
72
< >
73
- { cart ? (
73
+ { cart && ! orderCompleted ? (
74
74
< div className = "container mx-auto" >
75
75
{ /* Order*/ }
76
76
< OrderDetails cart = { cart } />
Original file line number Diff line number Diff line change 1
1
import Link from 'next/link' ;
2
2
import { v4 as uuidv4 } from 'uuid' ;
3
3
4
+ import { WOO_CONFIG } from 'utils/config/nextConfig' ;
5
+
4
6
/**
5
7
* Displays all of the products as long as length is defined.
6
8
* Does a map() over the props array and utilizes uuidv4 for unique key values.
@@ -32,19 +34,36 @@ const IndexProducts = ({ products }) => {
32
34
as = { `/produkt/${ slug } ?productId=${ productId } ` }
33
35
>
34
36
< a >
35
- { image && (
37
+ { image ? (
36
38
< img
37
39
id = "product-image"
38
40
className = "transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
39
41
alt = { name }
40
42
src = { image . sourceUrl }
41
43
/>
44
+ ) : (
45
+ < img
46
+ id = "product-image"
47
+ className = "transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
48
+ alt = { name }
49
+ src = { WOO_CONFIG . PLACEHOLDER_SMALL_IMAGE_URL }
50
+ />
42
51
) }
43
52
</ a >
44
53
</ Link >
45
- < div className = "flex justify-center pt-3" >
46
- < p className = "font-bold text-center" > { name } </ p >
47
- </ div >
54
+ < Link
55
+ href = "/produkt/[post]"
56
+ as = { `/produkt/${ slug } ?productId=${ productId } ` }
57
+ >
58
+ < a >
59
+ < div className = "flex justify-center pt-3" >
60
+ < p className = "font-bold text-center cursor-pointer" >
61
+ { name }
62
+ </ p >
63
+ </ div >
64
+ </ a >
65
+ </ Link >
66
+
48
67
{ /* Display sale price when on sale */ }
49
68
{ onSale && (
50
69
< >
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import { useState, useEffect } from 'react';
3
3
import AddToCartButton from 'components/Cart/AddToCartButton.component' ;
4
4
import LoadingSpinner from 'components/LoadingSpinner/LoadingSpinner.component' ;
5
5
6
+ import { WOO_CONFIG } from 'utils/config/nextConfig' ;
7
+
6
8
/**
7
9
* Shows a single product with an Add To Cart button.
8
10
* Uses GraphQL for product data
@@ -41,12 +43,22 @@ const SingleProduct = ({ product }) => {
41
43
) : (
42
44
< div className = "container flex flex-wrap items-center pt-4 pb-12 mx-auto " >
43
45
< div className = "grid grid-cols-1 gap-4 mt-16 lg:grid-cols-2 xl:grid-cols-2 md:grid-cols-2 sm:grid-cols-2" >
44
- < img
45
- id = "product-image"
46
- className = "h-auto p-8 transition duration-500 ease-in-out transform xl:p-2 md:p-2 lg:p-2 hover:grow hover:shadow-lg hover:scale-105"
47
- alt = { name }
48
- src = { image . sourceUrl }
49
- />
46
+ { image ? (
47
+ < img
48
+ id = "product-image"
49
+ className = "h-auto p-8 transition duration-500 ease-in-out transform xl:p-2 md:p-2 lg:p-2 hover:grow hover:shadow-lg hover:scale-105"
50
+ alt = { name }
51
+ src = { image . sourceUrl }
52
+ />
53
+ ) : (
54
+ < img
55
+ id = "product-image"
56
+ className = "h-auto p-8 transition duration-500 ease-in-out transform xl:p-2 md:p-2 lg:p-2 hover:grow hover:shadow-lg hover:scale-105"
57
+ alt = { name }
58
+ src = { WOO_CONFIG . PLACEHOLDER_LARGE_IMAGE_URL }
59
+ />
60
+ ) }
61
+
50
62
< div className = "ml-8" >
51
63
< p className = "text-3xl font-bold text-left" > { name } </ p >
52
64
< br />
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export const WOO_CONFIG = {
8
8
ALGOLIA_APP_ID: '7L9M5Y0B1K',
9
9
ALGOLIA_PUBLIC_API_KEY: '925cc92373120f1bf477bb8ce0e71649',
10
10
ALGOLIA_INDEX_NAME: 'dfweb',
11
+ PLACEHOLDER_IMAGE_URL: "https://via.placeholder.com/272",
11
12
};
12
13
*/
13
14
@@ -17,7 +18,9 @@ export const WOO_CONFIG = {
17
18
GRAPHQL_URL : 'http://localhost/wp/graphql' ,
18
19
ALGOLIA_APP_ID : '7L9M5Y0B1K' ,
19
20
ALGOLIA_PUBLIC_API_KEY : '925cc92373120f1bf477bb8ce0e71649' ,
21
+ ALGOLIA_INDEX_NAME : 'dfweb' ,
22
+ PLACEHOLDER_SMALL_IMAGE_URL : 'https://via.placeholder.com/272' ,
23
+ PLACEHOLDER_LARGE_IMAGE_URL : 'https://via.placeholder.com/616' ,
20
24
} ;
21
25
22
-
23
26
export default WOO_CONFIG ;
Original file line number Diff line number Diff line change @@ -34,19 +34,19 @@ export const GET_SINGLE_PRODUCT = gql`
34
34
}
35
35
}
36
36
variations {
37
- nodes {
38
- id
39
- variationId
40
- name
41
- stockStatus
42
- stockQuantity
43
- purchasable
44
- onSale
45
- salePrice
46
- regularPrice
37
+ nodes {
38
+ id
39
+ variationId
40
+ name
41
+ stockStatus
42
+ stockQuantity
43
+ purchasable
44
+ onSale
45
+ salePrice
46
+ regularPrice
47
+ }
47
48
}
48
49
}
49
- }
50
50
... on ExternalProduct {
51
51
price
52
52
id
@@ -98,11 +98,11 @@ export const FETCH_FIRST_PRODUCTS_FROM_HOODIES_QUERY = `
98
98
` ;
99
99
100
100
/**
101
- * Fetch all Woocommerce products from GraphQL
101
+ * Fetch first 24 Woocommerce products from GraphQL
102
102
*/
103
103
export const FETCH_ALL_PRODUCTS_QUERY = gql `
104
104
query MyQuery {
105
- products(first: 8 ) {
105
+ products(first: 24 ) {
106
106
nodes {
107
107
productId
108
108
name
@@ -127,11 +127,11 @@ export const FETCH_ALL_PRODUCTS_QUERY = gql`
127
127
` ;
128
128
129
129
/**
130
- * Fetch all categories from GraphQL
130
+ * Fetch first 20 categories from GraphQL
131
131
*/
132
132
export const FETCH_ALL_CATEGORIES_QUERY = gql `
133
133
query Categories {
134
- productCategories(first: 10 ) {
134
+ productCategories(first: 20 ) {
135
135
nodes {
136
136
id
137
137
name
You can’t perform that action at this time.
0 commit comments