Skip to content

Commit 71398c0

Browse files
committed
Code cleanup
1 parent ce0c152 commit 71398c0

File tree

8 files changed

+16
-20
lines changed

8 files changed

+16
-20
lines changed

components/Cart/AddToCartButton.component.jsx

Lines changed: 0 additions & 2 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';

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: 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';
@@ -37,7 +37,7 @@ const MobileCartItem = ({
3737
updateCart({
3838
variables: {
3939
input: {
40-
clientMutationId: v4(),
40+
clientMutationId: uuidv4(),
4141
items: updatedItems,
4242
},
4343
},

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)