Skip to content

Commit 1b5ebc5

Browse files
authored
Merge pull request #226 from w3bdesign/development
Development
2 parents 9cb52a3 + 86026d2 commit 1b5ebc5

File tree

5 files changed

+62
-28
lines changed

5 files changed

+62
-28
lines changed

components/Checkout/CheckoutForm.component.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const CheckoutForm = () => {
2222

2323
const [orderData, setOrderData] = useState(null);
2424
const [requestError, setRequestError] = useState(null);
25-
const [orderCompleted, setorderCompleted] = useState(false);
25+
const [orderCompleted, setorderCompleted] = useState(false);
2626

2727
// Checkout GraphQL mutation
2828
const [
@@ -70,7 +70,7 @@ const CheckoutForm = () => {
7070

7171
return (
7272
<>
73-
{cart ? (
73+
{cart && !orderCompleted ? (
7474
<div className="container mx-auto">
7575
{/* Order*/}
7676
<OrderDetails cart={cart} />

components/Product/IndexProducts.component.jsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Link from 'next/link';
22
import { v4 as uuidv4 } from 'uuid';
33

4+
import { WOO_CONFIG } from 'utils/config/nextConfig';
5+
46
/**
57
* Displays all of the products as long as length is defined.
68
* Does a map() over the props array and utilizes uuidv4 for unique key values.
@@ -32,19 +34,36 @@ const IndexProducts = ({ products }) => {
3234
as={`/produkt/${slug}?productId=${productId}`}
3335
>
3436
<a>
35-
{image && (
37+
{image ? (
3638
<img
3739
id="product-image"
3840
className="transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
3941
alt={name}
4042
src={image.sourceUrl}
4143
/>
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+
/>
4251
)}
4352
</a>
4453
</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+
4867
{/* Display sale price when on sale */}
4968
{onSale && (
5069
<>

components/Product/SingleProduct.component.jsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { useState, useEffect } from 'react';
33
import AddToCartButton from 'components/Cart/AddToCartButton.component';
44
import LoadingSpinner from 'components/LoadingSpinner/LoadingSpinner.component';
55

6+
import { WOO_CONFIG } from 'utils/config/nextConfig';
7+
68
/**
79
* Shows a single product with an Add To Cart button.
810
* Uses GraphQL for product data
@@ -41,12 +43,22 @@ const SingleProduct = ({ product }) => {
4143
) : (
4244
<div className="container flex flex-wrap items-center pt-4 pb-12 mx-auto ">
4345
<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+
5062
<div className="ml-8">
5163
<p className="text-3xl font-bold text-left">{name}</p>
5264
<br />

utils/config/nextConfig.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const WOO_CONFIG = {
88
ALGOLIA_APP_ID: '7L9M5Y0B1K',
99
ALGOLIA_PUBLIC_API_KEY: '925cc92373120f1bf477bb8ce0e71649',
1010
ALGOLIA_INDEX_NAME: 'dfweb',
11+
PLACEHOLDER_IMAGE_URL: "https://via.placeholder.com/272",
1112
};
1213
*/
1314

@@ -17,7 +18,9 @@ export const WOO_CONFIG = {
1718
GRAPHQL_URL: 'http://localhost/wp/graphql',
1819
ALGOLIA_APP_ID: '7L9M5Y0B1K',
1920
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',
2024
};
2125

22-
2326
export default WOO_CONFIG;

utils/const/GQL_QUERIES.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ export const GET_SINGLE_PRODUCT = gql`
3434
}
3535
}
3636
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+
}
4748
}
4849
}
49-
}
5050
... on ExternalProduct {
5151
price
5252
id
@@ -98,11 +98,11 @@ export const FETCH_FIRST_PRODUCTS_FROM_HOODIES_QUERY = `
9898
`;
9999

100100
/**
101-
* Fetch all Woocommerce products from GraphQL
101+
* Fetch first 24 Woocommerce products from GraphQL
102102
*/
103103
export const FETCH_ALL_PRODUCTS_QUERY = gql`
104104
query MyQuery {
105-
products(first: 8) {
105+
products(first: 24) {
106106
nodes {
107107
productId
108108
name
@@ -127,11 +127,11 @@ export const FETCH_ALL_PRODUCTS_QUERY = gql`
127127
`;
128128

129129
/**
130-
* Fetch all categories from GraphQL
130+
* Fetch first 20 categories from GraphQL
131131
*/
132132
export const FETCH_ALL_CATEGORIES_QUERY = gql`
133133
query Categories {
134-
productCategories(first: 10) {
134+
productCategories(first: 20) {
135135
nodes {
136136
id
137137
name

0 commit comments

Comments
 (0)