Skip to content

Commit e002aa2

Browse files
authored
Merge pull request #301 from w3bdesign/develop
Update tested with versions
2 parents 63a3b2d + 2216b02 commit e002aa2

File tree

9 files changed

+27
-30
lines changed

9 files changed

+27
-30
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Optional plugin:
1717

1818
The current release has been tested and is confirmed working with the following versions:
1919

20-
- WordPress version 5.5.1
21-
- WooCommerce version 4.6.1
22-
- WP GraphQL version 0.13.3
20+
- WordPress version 5.5.3
21+
- WooCommerce version 4.8.0
22+
- WP GraphQL version 1.0.3
2323
- WooGraphQL version 0.6.1
2424

2525
2. For debugging and testing, install either:

components/Cart/AddToCartButton.component.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { useState, useContext } from 'react';
2-
32
import { v4 as uuidv4 } from 'uuid';
4-
53
import { useQuery, useMutation } from '@apollo/client';
64

75
import { AppContext } from 'utils/context/AppContext';
@@ -18,9 +16,9 @@ import { getFormattedCart } from 'utils/functions/functions';
1816
* @param {Object} product
1917
*/
2018
const AddToCartButton = ({ product }) => {
21-
const [cart, setCart] = useContext(AppContext);
22-
const [requestError, setRequestError] = useState(null);
23-
const [showViewCart, setShowViewCart] = useState(false);
19+
const [, setCart] = useContext(AppContext);
20+
const [, setRequestError] = useState(null);
21+
const [, setShowViewCart] = useState(false);
2422
const [showAddToCart, setshowAddToCart] = useState(false);
2523

2624
const productId = product.databaseId ? product.databaseId : product;
@@ -31,7 +29,7 @@ const AddToCartButton = ({ product }) => {
3129
};
3230

3331
// Get Cart Data.
34-
const { loading, error, data, refetch } = useQuery(GET_CART, {
32+
const { data, refetch } = useQuery(GET_CART, {
3533
notifyOnNetworkStatusChange: true,
3634
onCompleted: () => {
3735
// Update cart in the localStorage.
@@ -44,12 +42,12 @@ const AddToCartButton = ({ product }) => {
4442

4543
const [
4644
addToCart,
47-
{ data: addToCartRes, loading: addToCartLoading, error: addToCartError },
45+
{ loading: addToCartLoading, error: addToCartError },
4846
] = useMutation(ADD_TO_CART, {
4947
variables: {
5048
input: productQueryInput,
5149
},
52-
onCompleted: (data) => {
50+
onCompleted: () => {
5351
// If error.
5452
if (addToCartError) {
5553
setRequestError(addToCartError.graphQLErrors[0].message);

components/Cart/CartPage/CartItem.component.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react';
2-
import { v4 } from 'uuid';
2+
import { v4 as uuidv4 } from 'uuid';
33

44
import SVGX from 'components/SVG/SVGX.component';
55
import { getUpdatedItems } from 'utils/functions/functions';
@@ -39,7 +39,7 @@ const CartItem = ({
3939
updateCart({
4040
variables: {
4141
input: {
42-
clientMutationId: v4(),
42+
clientMutationId: uuidv4(),
4343
items: updatedItems,
4444
},
4545
},

components/Cart/CartPage/CartItemsContainer.component.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Link from 'next/link';
2-
import { v4 } from 'uuid';
2+
import { v4 as uuidv4 } from 'uuid';
33
import { useContext, useState } from 'react';
44
import { useQuery, useMutation } from '@apollo/client';
55

@@ -50,7 +50,7 @@ const CartItemsContainer = () => {
5050
updateCart({
5151
variables: {
5252
input: {
53-
clientMutationId: v4(),
53+
clientMutationId: uuidv4(),
5454
items: updatedItems,
5555
},
5656
},

components/Cart/CartPage/MobileCart.component.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { v4 } from 'uuid';
1+
import { v4 as uuidv4 } from 'uuid';
22

33
import MobileCartItem from './MobileCartItem.component';
44

@@ -12,7 +12,7 @@ const MobileCart = ({ cart, handleRemoveProductClick, updateCart }) => {
1212
{cart.products.length &&
1313
cart.products.map(() => (
1414
<tr
15-
key={v4()}
15+
key={uuidv4()}
1616
className="flex flex-col mb-2 bg-white border border-gray-300 rounded-l-lg flex-no wrap sm:table-row sm:rounded-none sm:mb-0"
1717
>
1818
<th className="p-3 text-left">Fjern</th>
@@ -27,7 +27,7 @@ const MobileCart = ({ cart, handleRemoveProductClick, updateCart }) => {
2727
{cart.products.length &&
2828
cart.products.map((item) => (
2929
<MobileCartItem
30-
key={item}
30+
key={uuidv4()}
3131
item={item}
3232
products={cart.products}
3333
handleRemoveProductClick={handleRemoveProductClick}

components/Cart/CartPage/MobileCartItem.component.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react';
2-
import { v4 } from 'uuid';
2+
import { v4 as uuidv4 } from 'uuid';
33

44
import SVGX from 'components/SVG/SVGX.component';
55
import { getUpdatedItems } from 'utils/functions/functions';
@@ -37,7 +37,7 @@ const MobileCartItem = ({
3737
updateCart({
3838
variables: {
3939
input: {
40-
clientMutationId: v4(),
40+
clientMutationId: uuidv4(),
4141
items: updatedItems,
4242
},
4343
},
@@ -58,7 +58,8 @@ const MobileCartItem = ({
5858
</td>
5959
<td className="h-12 p-3">{item.name}</td>
6060
<td className="h-12 p-3">
61-
kr{'string' !== typeof item.price ? item.price.toFixed(2) : item.price}
61+
kr
62+
{'string' !== typeof item.price ? item.price.toFixed(2) : item.price}
6263
</td>
6364
<td className="h-12 p-3">
6465
<input

components/Category/Categories.component.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,21 @@ const Categories = ({ categories }) => {
1010
return (
1111
<>
1212
<section className="container mx-auto bg-white">
13-
<div className="grid gap-2 px-2 pt-2 pb-2 lg:px-0 xl:px-0 md:px-0 lg:grid-cols-4 sm:grid-cols-2 md:grid-cols-3 xs:grid-cols-3">
13+
<div className="grid gap-2 px-2 pt-2 pb-2 lg:px-0 xl:px-0 md:px-0 lg:grid-cols-4 sm:grid-cols-2 md:grid-cols-3 xs:grid-cols-3">
1414
{categories.map(({ id, name, slug }) => (
1515
<Link
1616
key={uuidv4()}
1717
as={`/kategori/${slug}?id=${id}`}
1818
href="/kategori/[id]"
1919
>
20-
<div
21-
className="p-6 cursor-pointer"
22-
>
20+
<div className="p-6 cursor-pointer">
2321
<div className="flex items-center justify-center w-full h-16 text-center border border-gray-300 rounded-lg shadow hover:shadow-outline">
2422
<p className="text-lg">{name}</p>
2523
</div>
2624
</div>
2725
</Link>
2826
))}
29-
</div>
27+
</div>
3028
</section>
3129
</>
3230
);

components/Checkout/MobileOrderDetails.component.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { v4 } from 'uuid';
1+
import { v4 as uuidv4 } from 'uuid';
22

33
import MobileOrderDetailsItem from './MobileOrderDetailsItem.component';
44

@@ -12,7 +12,7 @@ const MobileOrderDetails = ({ cart }) => {
1212
{cart.products.length &&
1313
cart.products.map(() => (
1414
<tr
15-
key={v4()}
15+
key={uuidv4()}
1616
className="flex flex-col mb-2 bg-white rounded-l-lg flex-no wrap sm:table-row sm:rounded-none sm:mb-0"
1717
>
1818
<th className="p-3 text-left">Navn</th>

utils/functions/functions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { v4 } from 'uuid';
1+
import { v4 as uuidv4 } from 'uuid';
22

33
import WOO_CONFIG from 'utils/config/nextConfig';
44

@@ -239,7 +239,7 @@ export const getFormattedCart = (data) => {
239239

240240
export const createCheckoutData = (order) => {
241241
const checkoutData = {
242-
clientMutationId: v4(),
242+
clientMutationId: uuidv4(),
243243

244244
billing: {
245245
firstName: order.firstName,

0 commit comments

Comments
 (0)