diff --git a/public/static/placeholder.png b/public/static/placeholder.png
new file mode 100644
index 0000000..09639d4
Binary files /dev/null and b/public/static/placeholder.png differ
diff --git a/src/apollo/ApolloClient.js b/src/apollo/ApolloClient.js
index 2baba7e..bfcf280 100644
--- a/src/apollo/ApolloClient.js
+++ b/src/apollo/ApolloClient.js
@@ -23,7 +23,8 @@ const link = createHttpLink({
const client = new ApolloClient({
link,
cache,
- defaultOptions
+ defaultOptions,
+ connectToDevTools: true
});
export default client;
diff --git a/src/components/Image.js b/src/components/Image.js
new file mode 100644
index 0000000..da5b1d7
--- /dev/null
+++ b/src/components/Image.js
@@ -0,0 +1,60 @@
+import { useState } from 'react';
+import Img from 'next/image';
+import PropTypes from 'prop-types';
+
+const Image = (props) => {
+
+ const [error, setError] = useState(false);
+
+ const {
+ src,
+ width,
+ height,
+ alt,
+ ...otherProps
+ } = props;
+
+ // URL to use if the actual image fails to load.
+ const fallBackUrl = '/static/placeholder.png';
+
+ /**
+ * Handles any error when loading the image.
+ *
+ * @return {void}
+ */
+ const errorHandler = () => {
+ setError(true);
+ }
+
+ return (
+
+ );
+};
+
+Image.propTypes = {
+ src: PropTypes.string.isRequired,
+ width: PropTypes.number,
+ height: PropTypes.number,
+ alt: PropTypes.string,
+ layout: PropTypes.oneOf(['fixed', 'intrinsic', 'responsive', 'fill']),
+ sizes: PropTypes.string,
+ quality: PropTypes.number,
+ priority: PropTypes.bool,
+ objectFit: PropTypes.string,
+ objectPosition: PropTypes.string,
+ className: PropTypes.string,
+ id: PropTypes.string
+}
+
+Image.defaultProps = {
+ width: 240,
+ height: 240,
+}
+
+export default Image;
diff --git a/src/components/cart/cart-page/CartItem.js b/src/components/cart/cart-page/CartItem.js
index 944d91e..ed22082 100644
--- a/src/components/cart/cart-page/CartItem.js
+++ b/src/components/cart/cart-page/CartItem.js
@@ -1,6 +1,6 @@
import { useState } from 'react';
import { updateCart } from '../../../utils/cart-functions';
-
+import Image from '../../Image';
const CartItem = ({ item, handleRemoveProductClick, setCart }) => {
const [productCount, setProductCount] = useState(item.qty);
@@ -40,11 +40,11 @@ const CartItem = ({ item, handleRemoveProductClick, setCart }) => {
-
|
{item.name} |
diff --git a/src/components/checkout/CheckoutCartItem.js b/src/components/checkout/CheckoutCartItem.js
index eb8fed8..f5228d7 100644
--- a/src/components/checkout/CheckoutCartItem.js
+++ b/src/components/checkout/CheckoutCartItem.js
@@ -2,11 +2,11 @@ const CheckoutCartItem = ({ item }) => {
return (
-
|
{item.name} |
diff --git a/src/components/home/Categories.js b/src/components/home/Categories.js
index 991ae79..c0eac34 100644
--- a/src/components/home/Categories.js
+++ b/src/components/home/Categories.js
@@ -9,12 +9,11 @@ const Categories = () => {
-
@@ -26,12 +25,11 @@ const Categories = () => {
-
@@ -43,12 +41,11 @@ const Categories = () => {
-
diff --git a/src/styles/sass/products.scss b/src/styles/sass/products.scss
index 49f8e0b..3191aca 100644
--- a/src/styles/sass/products.scss
+++ b/src/styles/sass/products.scss
@@ -23,9 +23,7 @@
color: #333333;
}
-.product-image {
- max-width: 240px;
-}
+
.product-name {
margin: 16px;
}