├── .babelrc ├── .gitignore ├── README.md ├── doc └── recording.gif ├── next-env.d.ts ├── next.config.js ├── package.json ├── public ├── favicon.ico ├── images │ ├── background-3045402_1280.png │ ├── carousel-demo-images │ │ ├── bazaar-1853361_1920.jpg │ │ ├── fashion-1031469_1920.jpg │ │ └── vinyl-records-945396_1920.jpg │ ├── guitar-756326_1280.jpg │ └── person-692159_1280.jpg └── zeit.svg ├── src ├── actions │ ├── cart │ │ ├── cart.ts │ │ └── cart_interfaces.ts │ ├── category │ │ ├── category.ts │ │ └── category_interfaces.ts │ ├── index.ts │ ├── product │ │ ├── product.ts │ │ └── product_interfaces.ts │ └── types.ts ├── assets │ └── css │ │ └── antd-custom.less ├── components │ ├── Cart │ │ ├── CartItem.tsx │ │ ├── CartList.tsx │ │ ├── CartListRenderer.tsx │ │ ├── Checkout │ │ │ ├── CheckoutItem.tsx │ │ │ ├── CheckoutList.less │ │ │ ├── CheckoutList.tsx │ │ │ └── CheckoutModal.tsx │ │ ├── OrderSummary.tsx │ │ └── ProductInfo.tsx │ ├── CategoryList │ │ ├── CategoryItem.tsx │ │ ├── CategoryList.less │ │ ├── CategoryList.tsx │ │ └── CategoryListRenderer.tsx │ ├── MainCarousel │ │ ├── MainCarousel.less │ │ └── MainCarousel.tsx │ ├── MainLayout │ │ ├── HeaderMeta.tsx │ │ ├── MainFooter.tsx │ │ ├── MainLayout.tsx │ │ └── MainNav │ │ │ ├── MainNav.less │ │ │ └── MainNav.tsx │ ├── MainPageHeader │ │ ├── MainPageHeader.less │ │ └── MainPageHeader.tsx │ ├── MainRowLayout │ │ └── MainRowLayout.tsx │ ├── ProductList │ │ ├── ProductItem.tsx │ │ ├── ProductList.less │ │ ├── ProductList.tsx │ │ └── ProductListRenderer.tsx │ ├── ProgressLine.tsx │ ├── SimpleHeading.tsx │ ├── SingleProduct │ │ ├── CartNotification.tsx │ │ ├── SingleProduct.less │ │ ├── SingleProduct.tsx │ │ ├── SingleProductRenderer.tsx │ │ └── SingleProductSkeleton │ │ │ ├── SingleProductSkeleton.less │ │ │ └── SingleProductSkeleton.tsx │ ├── SkeletonList │ │ ├── SkeletonItem.tsx │ │ ├── SkeletonList.less │ │ └── SkeletonList.tsx │ └── Spinner │ │ ├── Spinner.less │ │ └── Spinner.tsx ├── config │ └── index.ts ├── contexts │ └── index.ts ├── helpers │ ├── cart_helper.ts │ └── index.ts ├── pages │ ├── _app.tsx │ ├── app.less │ ├── cart.less │ ├── cart.tsx │ ├── category │ │ └── [...category].tsx │ ├── index.tsx │ └── product │ │ └── [...product].tsx ├── reducers │ ├── cart_reducer.ts │ ├── category_reducer.ts │ ├── index.ts │ └── product_reducer.ts └── selectors │ └── index.ts ├── tsconfig.json └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["next/babel"], 3 | "plugins": [ 4 | [ 5 | "import", 6 | { 7 | "libraryName": "antd", 8 | "style": true 9 | } 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | .env* 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | .now -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | :sparkles::sparkles::sparkles: **I am currently updating this project to use WP GraphQL & NextJS's SSG (Static Site Generation)!** :tada::tada: 2 | 3 | ## :moneybag: React eCommerce Application 4 | 5 |

6 | 7 |

8 | 9 | ## Basic Overview 10 | 11 | This simple eCommerce application shows how to integrate WooCommerce REST API into a NextJS framework. It is also using Typescript, Redux & React hooks making this application fun to use. Also with Ant Design as the design system, this project can be a very good starting point for your next shopping cart website. 12 | 13 | ## Setup 14 | 15 | ```bash 16 | yarn install 17 | yarn dev 18 | ``` 19 | 20 | Then open http://localhost:3000/ 21 | 22 | ## Copyright and license 23 | 24 | MIT 25 | -------------------------------------------------------------------------------- /doc/recording.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loq24/react-ecommerce/e32c2979da2df275fa0da17a718a40920e909dc2/doc/recording.gif -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const withLess = require('@zeit/next-less'); 3 | const lessToJS = require('less-vars-to-js'); 4 | const fs = require('fs'); 5 | const path = require('path'); 6 | const FilterWarningsPlugin = require('webpack-filter-warnings-plugin'); 7 | 8 | // Where your antd-custom.less file lives 9 | const themeVariables = lessToJS( 10 | fs.readFileSync( 11 | path.resolve(__dirname, './src/assets/css/antd-custom.less'), 12 | 'utf8' 13 | ) 14 | ); 15 | 16 | module.exports = withLess({ 17 | lessLoaderOptions: { 18 | javascriptEnabled: true, 19 | modifyVars: themeVariables // make your antd custom effective 20 | }, 21 | webpack: (config, { isServer }) => { 22 | config.plugins.push( 23 | new FilterWarningsPlugin({ 24 | // ignore ANTD chunk styles [mini-css-extract-plugin] warning 25 | exclude: /Conflicting order/ 26 | }) 27 | ); 28 | 29 | if (isServer) { 30 | const antStyles = /antd\/.*?\/style.*?/; 31 | const origExternals = [...config.externals]; 32 | config.externals = [ 33 | (context, request, callback) => { 34 | if (request.match(antStyles)) return callback(); 35 | if (typeof origExternals[0] === 'function') { 36 | origExternals[0](context, request, callback); 37 | } else { 38 | callback(); 39 | } 40 | }, 41 | ...(typeof origExternals[0] === 'function' ? [] : origExternals) 42 | ]; 43 | 44 | config.module.rules.unshift({ 45 | test: antStyles, 46 | use: 'null-loader' 47 | }); 48 | } 49 | return config; 50 | } 51 | }); 52 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-ecommerce", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start" 9 | }, 10 | "dependencies": { 11 | "@ant-design/icons": "^4.0.0", 12 | "@woocommerce/woocommerce-rest-api": "^1.0.1", 13 | "antd": "^4.0.2", 14 | "js-cookie": "^2.2.1", 15 | "less": "^3.11.1", 16 | "less-vars-to-js": "^1.3.0", 17 | "next": "9.3.2", 18 | "react": "16.12.0", 19 | "react-dom": "16.12.0", 20 | "react-progress": "^0.0.12", 21 | "react-redux": "^7.2.0", 22 | "redux": "^4.0.5", 23 | "redux-thunk": "^2.3.0" 24 | }, 25 | "devDependencies": { 26 | "@testing-library/react": "^10.0.2", 27 | "@types/js-cookie": "^2.2.5", 28 | "@types/node": "^13.7.1", 29 | "@types/react": "^16.9.20", 30 | "@types/react-redux": "^7.1.7", 31 | "@zeit/next-less": "^1.0.1", 32 | "babel-plugin-import": "^1.13.0", 33 | "jest": "^25.2.6", 34 | "null-loader": "^3.0.0", 35 | "typescript": "^3.7.5", 36 | "webpack-filter-warnings-plugin": "^1.2.1" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loq24/react-ecommerce/e32c2979da2df275fa0da17a718a40920e909dc2/public/favicon.ico -------------------------------------------------------------------------------- /public/images/background-3045402_1280.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loq24/react-ecommerce/e32c2979da2df275fa0da17a718a40920e909dc2/public/images/background-3045402_1280.png -------------------------------------------------------------------------------- /public/images/carousel-demo-images/bazaar-1853361_1920.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loq24/react-ecommerce/e32c2979da2df275fa0da17a718a40920e909dc2/public/images/carousel-demo-images/bazaar-1853361_1920.jpg -------------------------------------------------------------------------------- /public/images/carousel-demo-images/fashion-1031469_1920.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loq24/react-ecommerce/e32c2979da2df275fa0da17a718a40920e909dc2/public/images/carousel-demo-images/fashion-1031469_1920.jpg -------------------------------------------------------------------------------- /public/images/carousel-demo-images/vinyl-records-945396_1920.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loq24/react-ecommerce/e32c2979da2df275fa0da17a718a40920e909dc2/public/images/carousel-demo-images/vinyl-records-945396_1920.jpg -------------------------------------------------------------------------------- /public/images/guitar-756326_1280.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loq24/react-ecommerce/e32c2979da2df275fa0da17a718a40920e909dc2/public/images/guitar-756326_1280.jpg -------------------------------------------------------------------------------- /public/images/person-692159_1280.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loq24/react-ecommerce/e32c2979da2df275fa0da17a718a40920e909dc2/public/images/person-692159_1280.jpg -------------------------------------------------------------------------------- /public/zeit.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/actions/cart/cart.ts: -------------------------------------------------------------------------------- 1 | import Cookies from 'js-cookie'; 2 | import { Dispatch } from 'redux'; 3 | import { CartTypes } from '../types'; 4 | import { 5 | AddToCart, 6 | RemoveFromCart, 7 | UpdateCartItemCount 8 | } from './cart_interfaces'; 9 | 10 | export const addToCart = (id: string, price: string, count = 1) => { 11 | return (dispatch: Dispatch) => { 12 | dispatch({ 13 | type: CartTypes.addToCart, 14 | payload: { id, price, count } 15 | }); 16 | }; 17 | }; 18 | 19 | export const removeFromCart = (id: string) => { 20 | return (dispatch: Dispatch) => { 21 | dispatch({ 22 | type: CartTypes.removeFromCart, 23 | payload: id 24 | }); 25 | }; 26 | }; 27 | 28 | export const updateCartItemCount = ( 29 | id: string, 30 | price: string, 31 | count: number 32 | ) => { 33 | return (dispatch: Dispatch) => { 34 | dispatch({ 35 | type: CartTypes.updateCartItemCount, 36 | payload: { id, price, count } 37 | }); 38 | }; 39 | }; 40 | -------------------------------------------------------------------------------- /src/actions/cart/cart_interfaces.ts: -------------------------------------------------------------------------------- 1 | import { CartTypes } from '../types'; 2 | 3 | export interface Cart { 4 | id: string; 5 | price: string; 6 | count: number; 7 | } 8 | 9 | export interface AddToCart { 10 | type: CartTypes.addToCart; 11 | payload: Cart; 12 | } 13 | 14 | export interface RemoveFromCart { 15 | type: CartTypes.removeFromCart; 16 | payload: string; 17 | } 18 | 19 | export interface UpdateCartItemCount { 20 | type: CartTypes.updateCartItemCount; 21 | payload: Cart; 22 | } 23 | -------------------------------------------------------------------------------- /src/actions/category/category.ts: -------------------------------------------------------------------------------- 1 | import { Dispatch } from 'redux'; 2 | import { wooApi } from '../../config'; 3 | import { 4 | FetchMainProductCategories, 5 | FetchCategory 6 | } from './category_interfaces'; 7 | import { CategoryTypes } from '../types'; 8 | 9 | export const fetchMainProductCategories = () => { 10 | return async (dispatch: Dispatch) => { 11 | try { 12 | const response = await wooApi.get( 13 | `products/categories?hide_empty=true&parent=0` 14 | ); 15 | dispatch({ 16 | type: CategoryTypes.fetchMainProductCategories, 17 | payload: response.data 18 | }); 19 | } catch (error) { 20 | console.log(error); 21 | } 22 | }; 23 | }; 24 | 25 | export const fetchCategory = (id: string) => { 26 | return async (dispatch: Dispatch) => { 27 | try { 28 | const response = await wooApi.get(`products/categories/${id}`); 29 | dispatch({ 30 | type: CategoryTypes.fetchCategory, 31 | payload: response.data 32 | }); 33 | } catch (error) { 34 | console.log(error); 35 | } 36 | }; 37 | }; 38 | -------------------------------------------------------------------------------- /src/actions/category/category_interfaces.ts: -------------------------------------------------------------------------------- 1 | import { CategoryTypes } from '../types'; 2 | 3 | export interface ProductCategory { 4 | id: number; 5 | name: string; 6 | slug: string; 7 | description: string; 8 | parent: number; 9 | count: number; 10 | image: { 11 | id: number; 12 | src: string; 13 | }; 14 | } 15 | 16 | export interface FetchMainProductCategories { 17 | type: CategoryTypes.fetchMainProductCategories; 18 | payload: ProductCategory[]; 19 | } 20 | 21 | export interface FetchCategory { 22 | type: CategoryTypes.fetchCategory; 23 | payload: ProductCategory; 24 | } 25 | -------------------------------------------------------------------------------- /src/actions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './types'; 2 | export * from './product/product'; 3 | export * from './product/product_interfaces'; 4 | export * from './category/category'; 5 | export * from './category/category_interfaces'; 6 | export * from './cart/cart'; 7 | export * from './cart/cart_interfaces'; 8 | -------------------------------------------------------------------------------- /src/actions/product/product.ts: -------------------------------------------------------------------------------- 1 | //@ts-nocheck 2 | import { wooApi } from '../../config'; 3 | import { Dispatch } from 'redux'; 4 | import { ProductTypes } from '../types'; 5 | import { 6 | FetchSaleProducts, 7 | FetchCategoryProducts, 8 | FetchProductById, 9 | FetchProductsByIds 10 | } from './product_interfaces'; 11 | 12 | export const fetchSaleProducts = (itemCount = 4) => { 13 | return async (dispatch: Dispatch) => { 14 | try { 15 | const response = await wooApi.get( 16 | `products?per_page=${itemCount}&purchasable=true&on_sale=true` 17 | ); 18 | 19 | dispatch({ 20 | type: ProductTypes.fetchSaleProduts, 21 | payload: response.data 22 | }); 23 | } catch (error) { 24 | console.log(error); 25 | } 26 | }; 27 | }; 28 | 29 | export const fetchCategoryProducts = ( 30 | categoryId: string, 31 | callback?: () => void 32 | ) => { 33 | return async (dispatch: Dispatch) => { 34 | try { 35 | const response = await wooApi.get(`products?category=${categoryId}`); 36 | 37 | dispatch({ 38 | type: ProductTypes.fetchCategoryProducts, 39 | payload: response.data 40 | }); 41 | callback(); 42 | } catch (error) { 43 | console.log(error); 44 | } 45 | }; 46 | }; 47 | 48 | export const fetchProductById = (id: string, callback?: () => void) => { 49 | return async (dispatch: Dispatch) => { 50 | try { 51 | const response = await wooApi.get(`products/${id}`); 52 | 53 | dispatch({ 54 | type: ProductTypes.fetchProductById, 55 | payload: response.data 56 | }); 57 | callback(); 58 | } catch (error) { 59 | console.log(error); 60 | } 61 | }; 62 | }; 63 | 64 | export const fetchProductsByIds = (ids: string) => { 65 | return async (dispatch: Dispatch) => { 66 | try { 67 | const response = await wooApi.get(`products?include=${ids}`); 68 | 69 | dispatch({ 70 | type: ProductTypes.fetchProductsByIds, 71 | payload: response.data 72 | }); 73 | } catch (error) { 74 | console.log(error); 75 | } 76 | }; 77 | }; 78 | -------------------------------------------------------------------------------- /src/actions/product/product_interfaces.ts: -------------------------------------------------------------------------------- 1 | import { ProductTypes } from '../types'; 2 | 3 | export interface ProductImage { 4 | id: number; 5 | src: string; 6 | alt: string; 7 | } 8 | 9 | export interface Product { 10 | id: number; 11 | name: string; 12 | slug: string; 13 | date_created: string; 14 | description: string; 15 | price: string; 16 | regular_price: string; 17 | sale_price: string; 18 | on_sale: boolean; 19 | related_ids: number[]; 20 | images: ProductImage[]; 21 | } 22 | 23 | export interface FetchSaleProducts { 24 | type: ProductTypes.fetchSaleProduts; 25 | payload: Product[]; 26 | } 27 | 28 | export interface FetchCategoryProducts { 29 | type: ProductTypes.fetchCategoryProducts; 30 | payload: Product[]; 31 | } 32 | 33 | export interface FetchProductById { 34 | type: ProductTypes.fetchProductById; 35 | payload: Product; 36 | } 37 | 38 | export interface FetchProductsByIds { 39 | type: ProductTypes.fetchProductsByIds; 40 | payload: Product[]; 41 | } 42 | -------------------------------------------------------------------------------- /src/actions/types.ts: -------------------------------------------------------------------------------- 1 | export enum ProductTypes { 2 | fetchSaleProduts = 'FETCH_SALE_PRODUCTS', 3 | fetchCategoryProducts = 'FETCH_CATEGORY_PRODUCTS', 4 | fetchProductById = 'FETCH_PRODUCT_BY_ID', 5 | fetchProductsByIds = 'FETCH_PRODUCTS_BY_IDS' 6 | } 7 | 8 | export enum CategoryTypes { 9 | fetchMainProductCategories = 'FETCH_MAIN_PRODUCT_CATEGORIES', 10 | fetchCategory = 'FETCH_CATEGORY' 11 | } 12 | 13 | export enum CartTypes { 14 | addToCart = 'ADD_TO_CART', 15 | removeFromCart = 'REMOVE_FROM_CART', 16 | updateCartItemCount = 'UPDATE_CART_ITEM_COUNT' 17 | } 18 | -------------------------------------------------------------------------------- /src/assets/css/antd-custom.less: -------------------------------------------------------------------------------- 1 | @primary-color: #1890ff; // primary color for all components 2 | @link-color: #1890ff; // link color 3 | @success-color: #52c41a; // success state color 4 | @warning-color: #faad14; // warning state color 5 | @error-color: #f5222d; // error state color 6 | @font-size-base: 14px; // major text font size 7 | @heading-color: rgba(0, 0, 0, 0.85); // heading text color 8 | @text-color: rgba(0, 0, 0, 0.65); // major text color 9 | @text-color-secondary: rgba(0, 0, 0, 0.45); // secondary text color 10 | @disabled-color: rgba(0, 0, 0, 0.25); // disable state color 11 | @border-radius-base: 4px; // major border radius 12 | @border-color-base: #d9d9d9; // major border color 13 | @box-shadow-base: 0 2px 8px rgba(0, 0, 0, 0.15); // major shadow for layers 14 | 15 | @primary-color: #ff4c3b; 16 | @menu-item-color: #777; 17 | @layout-header-padding: 0px 0px; 18 | @layout-header-background: #ffffff; 19 | @layout-body-background: #ffffff; 20 | @layout-footer-padding: 24px 50px; 21 | @layout-footer-background: @layout-header-background; 22 | @border-radius-base: 2px; 23 | @collapse-content-bg: #ffffff; 24 | @full-box-width: 1200px; 25 | -------------------------------------------------------------------------------- /src/components/Cart/CartItem.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import { useDispatch } from 'react-redux'; 3 | import { Product, removeFromCart, updateCartItemCount } from '../../actions'; 4 | import { InputNumber } from 'antd'; 5 | import { DeleteOutlined } from '@ant-design/icons'; 6 | import { useCartSelector } from '../../selectors'; 7 | import { getCartItemCount } from '../../helpers'; 8 | import ProductInfo from './ProductInfo'; 9 | 10 | interface CartItemProps { 11 | product: Product; 12 | } 13 | 14 | const CartItem: React.FC = ({ product }) => { 15 | const [isDeleting, setDeleting] = useState(false); 16 | const [itemCount, setItemCount] = useState(0); 17 | 18 | const { id, price } = product; 19 | const product_id = `${id}`; 20 | 21 | const { items } = useCartSelector(); 22 | const dispatch = useDispatch(); 23 | 24 | const removeThisItem = () => { 25 | setDeleting(true); 26 | dispatch(removeFromCart(product_id)); 27 | }; 28 | 29 | const handleUpdateCartItem = (count = 1) => { 30 | if (itemCount > count) { 31 | dispatch(updateCartItemCount(product_id, price, -1)); 32 | } else { 33 | dispatch(updateCartItemCount(product_id, price, 1)); 34 | } 35 | }; 36 | 37 | useEffect(() => { 38 | const totalItemCount = getCartItemCount(items, product_id); 39 | setItemCount(totalItemCount); 40 | }); 41 | 42 | return ( 43 |
44 | 45 |
46 | handleUpdateCartItem(count)} 51 | /> 52 |
53 |
54 | 55 |
56 |
57 | ); 58 | }; 59 | 60 | export default CartItem; 61 | -------------------------------------------------------------------------------- /src/components/Cart/CartList.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import CartItem from './CartItem'; 3 | import { Product } from '../../actions'; 4 | 5 | interface CartListProps { 6 | products: Product[]; 7 | } 8 | 9 | const CartList: React.FC = ({ products }) => { 10 | return ( 11 |
12 | {products.map((product) => { 13 | return ; 14 | })} 15 |
16 | ); 17 | }; 18 | 19 | export default CartList; 20 | -------------------------------------------------------------------------------- /src/components/Cart/CartListRenderer.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Product } from '../../actions'; 3 | import CartList from './CartList'; 4 | import SkeletonList from '../SkeletonList/SkeletonList'; 5 | 6 | interface CartListRendererProps { 7 | cartProducts: Product[]; 8 | totalItems: number; 9 | } 10 | 11 | const CartListRenderer: React.FC = ({ 12 | cartProducts, 13 | totalItems 14 | }) => { 15 | return ( 16 | <> 17 | {cartProducts.length > 0 && totalItems > 0 ? ( 18 | 19 | ) : ( 20 | 21 | )} 22 | 23 | ); 24 | }; 25 | 26 | export default CartListRenderer; 27 | -------------------------------------------------------------------------------- /src/components/Cart/Checkout/CheckoutItem.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Link from 'next/link'; 3 | import { Product } from '../../../actions'; 4 | import { useCartSelector } from '../../../selectors'; 5 | import { getCartItemCount } from '../../../helpers'; 6 | import ProductInfo from '../ProductInfo'; 7 | 8 | interface CheckoutItemProps { 9 | product: Product; 10 | } 11 | 12 | const CheckoutItem: React.FC = ({ product }) => { 13 | const { items } = useCartSelector(); 14 | const { id, price } = product; 15 | 16 | const product_id = `${id}`; 17 | const totalItemCount = getCartItemCount(items, product_id); 18 | const subtotal = parseFloat(price) * totalItemCount; 19 | 20 | return ( 21 |
22 | 23 |
{totalItemCount}
24 |
${subtotal}
25 |
26 | ); 27 | }; 28 | 29 | export default CheckoutItem; 30 | -------------------------------------------------------------------------------- /src/components/Cart/Checkout/CheckoutList.less: -------------------------------------------------------------------------------- 1 | .checkout-list { 2 | .table-heading { 3 | display: flex; 4 | flex-flow: row wrap; 5 | font-size: 16px; 6 | margin-bottom: 20px; 7 | @media (max-width: 767px) { 8 | display: none; 9 | } 10 | 11 | & > div:not(:first-child) { 12 | width: 20%; 13 | color: #bbb; 14 | } 15 | & > div:first-child { 16 | width: 385px; 17 | padding-left: 10px; 18 | } 19 | & > div:last-child { 20 | color: #bbb; 21 | margin-left: auto; 22 | text-align: center; 23 | } 24 | } 25 | .overall-total-price { 26 | width: 100%; 27 | display: flex; 28 | text-align: center; 29 | padding: 25px; 30 | background: #f7f7f7; 31 | justify-content: flex-end; 32 | div { 33 | width: 25%; 34 | font-size: 15px; 35 | @media (max-width: 767px) { 36 | width: 35%; 37 | } 38 | span { 39 | font-size: 30px; 40 | margin-left: 10px; 41 | color: @primary-color; 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/components/Cart/Checkout/CheckoutList.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import CheckoutItem from './CheckoutItem'; 3 | import { Product } from '../../../actions'; 4 | import { CartContext } from '../../../contexts'; 5 | import './CheckoutList.less'; 6 | 7 | interface CheckoutListProps { 8 | products: Product[]; 9 | } 10 | 11 | const CheckoutList: React.FC = ({ products }) => { 12 | const { totalPrice } = React.useContext(CartContext); 13 | 14 | return ( 15 |
16 |
17 |
Products Ordered
18 |
Amount
19 |
Item Subtotal
20 |
21 | {products.map((product) => { 22 | return ; 23 | })} 24 |
25 |
26 | TOTAL: ${totalPrice} 27 |
28 |
29 |
30 | ); 31 | }; 32 | 33 | export default CheckoutList; 34 | -------------------------------------------------------------------------------- /src/components/Cart/Checkout/CheckoutModal.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Modal } from 'antd'; 3 | import CheckoutList from './CheckoutList'; 4 | import { useProductSelector } from '../../../selectors'; 5 | 6 | interface CheckoutSummaryProps { 7 | visible: boolean; 8 | hideModal: () => void; 9 | } 10 | 11 | const CheckoutSummary: React.FC = ({ 12 | visible, 13 | hideModal, 14 | }) => { 15 | const { cartProducts } = useProductSelector(); 16 | 17 | return ( 18 | 26 | 27 | 28 | ); 29 | }; 30 | 31 | export default CheckoutSummary; 32 | -------------------------------------------------------------------------------- /src/components/Cart/OrderSummary.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { Typography, Button } from 'antd'; 3 | import { Product } from '../../actions'; 4 | import { CartContext } from '../../contexts'; 5 | import CheckoutModal from './Checkout/CheckoutModal'; 6 | 7 | const { Title, Text } = Typography; 8 | 9 | interface OrderSummaryProps { 10 | cartProducts: Product[]; 11 | totalItems: number; 12 | } 13 | 14 | const OrderSummary: React.FC = ({ 15 | cartProducts, 16 | totalItems, 17 | }) => { 18 | const { totalPrice } = React.useContext(CartContext); 19 | const [modalVisibility, setModalVisibility] = useState(false); 20 | 21 | return ( 22 |
23 | Order Summary 24 |
25 | Total 26 | ₱{Number(totalPrice)} 27 |
28 | 36 | setModalVisibility(false)} 39 | /> 40 |
41 | ); 42 | }; 43 | 44 | export default OrderSummary; 45 | -------------------------------------------------------------------------------- /src/components/Cart/ProductInfo.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Link from 'next/link'; 3 | import { Product } from '../../actions'; 4 | import { Typography } from 'antd'; 5 | 6 | const { Title, Text } = Typography; 7 | 8 | interface ProductInfoProps { 9 | product: Product; 10 | } 11 | 12 | const ProductInfo: React.FC = ({ product }) => { 13 | const { 14 | id, 15 | name, 16 | images, 17 | regular_price, 18 | sale_price, 19 | on_sale, 20 | slug, 21 | } = product; 22 | const featured_image = images.length > 0 ? images[0].src : ''; 23 | const product_id = `${id}`; 24 | return ( 25 | <> 26 |
27 | 31 | {featured_image && } 32 | 33 |
34 | 54 | 55 | ); 56 | }; 57 | 58 | export default ProductInfo; 59 | -------------------------------------------------------------------------------- /src/components/CategoryList/CategoryItem.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Link from 'next/link'; 3 | import { ProductCategory } from '../../actions'; 4 | import { Col, Card } from 'antd'; 5 | import { SkeletonListContext } from '../../contexts'; 6 | const { Meta } = Card; 7 | 8 | interface CategoryItemProps { 9 | category: ProductCategory; 10 | } 11 | 12 | const CategoryItem: React.FC = ({ category }) => { 13 | const { xl, md, sm, lg, xs } = React.useContext(SkeletonListContext); 14 | const { name, description, image } = category; 15 | const featured_image = image?.src ?? ''; 16 | 17 | return ( 18 | 19 | 24 | : null 29 | } 30 | > 31 | 32 | 33 | 34 | 35 | ); 36 | }; 37 | 38 | export default CategoryItem; 39 | -------------------------------------------------------------------------------- /src/components/CategoryList/CategoryList.less: -------------------------------------------------------------------------------- 1 | .category-item-card { 2 | .ant-card-cover { 3 | min-height: 224px; 4 | background-color: #ededed; 5 | @media (max-width: 1200px) { 6 | min-height: auto; 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/components/CategoryList/CategoryList.tsx: -------------------------------------------------------------------------------- 1 | import { ProductCategory } from '../../actions'; 2 | import CategoryItem from './CategoryItem'; 3 | import MainRowLayout from '../MainRowLayout/MainRowLayout'; 4 | import './CategoryList.less'; 5 | 6 | interface CategoryListProps { 7 | categories: ProductCategory[]; 8 | } 9 | 10 | const CategoryList: React.FC = ({ categories }) => { 11 | return ( 12 | 13 | {categories.map(category => { 14 | return ; 15 | })} 16 | 17 | ); 18 | }; 19 | 20 | export default CategoryList; 21 | -------------------------------------------------------------------------------- /src/components/CategoryList/CategoryListRenderer.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import CategoryList from './CategoryList'; 3 | import SkeletonList from '../SkeletonList/SkeletonList'; 4 | import { ProductCategory } from '../../actions'; 5 | import { SkeletonListContext, Breakpoints } from '../../contexts'; 6 | 7 | interface CategoryListRendererProps { 8 | categories: ProductCategory[]; 9 | breakpoints: Breakpoints; 10 | } 11 | 12 | const CategoryListRenderer: React.FC = ({ 13 | categories, 14 | breakpoints 15 | }) => { 16 | return ( 17 | 18 | {categories.length === 0 ? ( 19 | 20 | ) : ( 21 | 22 | )} 23 | 24 | ); 25 | }; 26 | 27 | export default CategoryListRenderer; 28 | -------------------------------------------------------------------------------- /src/components/MainCarousel/MainCarousel.less: -------------------------------------------------------------------------------- 1 | .ant-carousel { 2 | .slick-slide { 3 | text-align: center; 4 | height: 500px; 5 | line-height: 160px; 6 | background: #364d79; 7 | overflow: hidden; 8 | } 9 | } 10 | 11 | .ant-carousel { 12 | .slick-slide { 13 | img { 14 | object-fit: cover; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/components/MainCarousel/MainCarousel.tsx: -------------------------------------------------------------------------------- 1 | import { Carousel } from 'antd'; 2 | import './MainCarousel.less'; 3 | 4 | const MainCarousel = () => { 5 | return ( 6 | 7 |
8 | 9 |
10 |
11 | 12 |
13 |
14 | 15 |
16 |
17 | ); 18 | }; 19 | 20 | export default MainCarousel; 21 | -------------------------------------------------------------------------------- /src/components/MainLayout/HeaderMeta.tsx: -------------------------------------------------------------------------------- 1 | import Head from 'next/head'; 2 | 3 | interface HeaderMetaProps { 4 | title: string; 5 | } 6 | 7 | const HeaderMeta: React.FC = ({ title }) => { 8 | return ( 9 | 10 | {title} 11 | 12 | 13 | 14 | ); 15 | }; 16 | 17 | export default HeaderMeta; 18 | -------------------------------------------------------------------------------- /src/components/MainLayout/MainFooter.tsx: -------------------------------------------------------------------------------- 1 | import { Layout } from 'antd'; 2 | const { Footer } = Layout; 3 | 4 | const MainFooter = () => { 5 | return ( 6 | 17 | ); 18 | }; 19 | 20 | export default MainFooter; 21 | -------------------------------------------------------------------------------- /src/components/MainLayout/MainLayout.tsx: -------------------------------------------------------------------------------- 1 | import HeaderMeta from './HeaderMeta'; 2 | import MainNav from './MainNav/MainNav'; 3 | import MainFooter from './MainFooter'; 4 | import { Layout } from 'antd'; 5 | 6 | const { Content } = Layout; 7 | 8 | interface LayoutProps { 9 | children: React.ReactNode; 10 | title: string; 11 | } 12 | 13 | const MainLayout: React.FC = ({ children, title }) => { 14 | return ( 15 | <> 16 | 17 | 18 | 19 | {children} 20 | 21 | 22 | 23 | ); 24 | }; 25 | 26 | export default MainLayout; 27 | -------------------------------------------------------------------------------- /src/components/MainLayout/MainNav/MainNav.less: -------------------------------------------------------------------------------- 1 | .main-nav { 2 | max-width: @full-box-width; 3 | width: 100%; 4 | margin: 0 auto; 5 | padding: 0 16px; 6 | .left-nav-items { 7 | display: flex; 8 | flex-flow: row wrap; 9 | justify-content: space-between; 10 | width: 80px; 11 | a { 12 | color: @menu-item-color; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/components/MainLayout/MainNav/MainNav.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Link from 'next/link'; 3 | import { Layout, Row, Col, Badge } from 'antd'; 4 | import { ShoppingCartOutlined, GithubOutlined } from '@ant-design/icons'; 5 | import { useCartSelector } from '../../../selectors'; 6 | import './MainNav.less'; 7 | 8 | const { Header } = Layout; 9 | 10 | const MainNav = () => { 11 | const { totalItems } = useCartSelector(); 12 | 13 | return ( 14 |
15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | Home 23 | 24 |
25 | 26 | 27 | 28 |
29 | 37 | 40 | 41 |
42 | 43 | 44 |
45 |
46 | ); 47 | }; 48 | 49 | export default MainNav; 50 | -------------------------------------------------------------------------------- /src/components/MainPageHeader/MainPageHeader.less: -------------------------------------------------------------------------------- 1 | .site-page-header { 2 | margin: 30px auto 20px; 3 | 4 | .ant-page-header-heading-title { 5 | text-transform: capitalize; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/components/MainPageHeader/MainPageHeader.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useRouter } from 'next/router'; 3 | import { PageHeader } from 'antd'; 4 | import './MainPageHeader.less'; 5 | 6 | interface MainPageHeaderProps { 7 | title: string; 8 | subTitle?: string; 9 | } 10 | 11 | const MainPageHeader: React.FC = ({ 12 | title, 13 | subTitle = '' 14 | }) => { 15 | const router = useRouter(); 16 | const goBack = React.useCallback(() => { 17 | router.back(); 18 | }, []); 19 | 20 | return ( 21 | 27 | ); 28 | }; 29 | 30 | export default MainPageHeader; 31 | -------------------------------------------------------------------------------- /src/components/MainRowLayout/MainRowLayout.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Layout, Row } from 'antd'; 3 | 4 | interface MainRowLayoutProps { 5 | children: React.ReactNode; 6 | rowClassName?: string; 7 | } 8 | 9 | const MainRowLayout: React.FC = ({ 10 | children, 11 | rowClassName 12 | }) => { 13 | return ( 14 | 15 | 16 | {children} 17 | 18 | 19 | ); 20 | }; 21 | 22 | export default MainRowLayout; 23 | -------------------------------------------------------------------------------- /src/components/ProductList/ProductItem.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Link from 'next/link'; 3 | import { Product } from '../../actions'; 4 | import { Row, Col, Card, Typography, Button } from 'antd'; 5 | import { SkeletonListContext } from '../../contexts'; 6 | const { Text } = Typography; 7 | 8 | interface SaleProductItemProps { 9 | product: Product; 10 | } 11 | 12 | const SaleProductItem: React.FC = ({ product }) => { 13 | const { xl, md, sm, lg, xs } = React.useContext(SkeletonListContext); 14 | const { 15 | id, 16 | slug, 17 | name, 18 | regular_price, 19 | sale_price, 20 | on_sale, 21 | images 22 | } = product; 23 | const featured_image = images.length > 0 ? images[0].src : ''; 24 | return ( 25 | 26 | 27 | : null 31 | } 32 | > 33 | 34 | 35 | {name} 36 | 37 | {on_sale && } 38 | 39 | 40 | 41 | {`$${regular_price}`} 42 | 43 | {on_sale && ( 44 | {`$${sale_price}`} 45 | )} 46 | 47 | 48 | 49 | 50 | ); 51 | }; 52 | 53 | export default SaleProductItem; 54 | -------------------------------------------------------------------------------- /src/components/ProductList/ProductList.less: -------------------------------------------------------------------------------- 1 | .product-list { 2 | .ant-card-cover { 3 | min-height: 282px; 4 | background-color: #ededed; 5 | @media (max-width: 1200px) { 6 | min-height: auto; 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/components/ProductList/ProductList.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Product } from '../../actions'; 3 | import ProductItem from './ProductItem'; 4 | import MainRowLayout from '../MainRowLayout/MainRowLayout'; 5 | import './ProductList.less'; 6 | 7 | interface SaleProductListProps { 8 | products: Product[]; 9 | } 10 | 11 | const ProductList: React.FC = ({ products }) => { 12 | return ( 13 | 14 | {products.map(product => { 15 | return ; 16 | })} 17 | 18 | ); 19 | }; 20 | 21 | export default ProductList; 22 | -------------------------------------------------------------------------------- /src/components/ProductList/ProductListRenderer.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ProductList from './ProductList'; 3 | import Spinner from '../Spinner/Spinner'; 4 | import { Product } from '../../actions'; 5 | import SkeletonList from '../SkeletonList/SkeletonList'; 6 | import { SkeletonListContext, Breakpoints } from '../../contexts'; 7 | 8 | interface ProductListRendererProps { 9 | products: Product[]; 10 | skeletonCount?: number; 11 | skeleton?: boolean; 12 | spin?: boolean; 13 | breakpoints: Breakpoints; 14 | } 15 | 16 | const ProductListRenderer: React.FC = ({ 17 | products, 18 | skeleton, 19 | skeletonCount = 0, 20 | spin, 21 | breakpoints 22 | }) => { 23 | return ( 24 | 25 | {skeleton && products.length === 0 && ( 26 | 27 | )} 28 | {products.length > 0 && !spin && } 29 | {spin && } 30 | 31 | ); 32 | }; 33 | 34 | export default ProductListRenderer; 35 | -------------------------------------------------------------------------------- /src/components/ProgressLine.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | // @ts-ignore 3 | import Progress from 'react-progress'; 4 | import Router from 'next/router'; 5 | 6 | const ProgressLine = () => { 7 | const [percent, setPercent] = useState(0); 8 | 9 | useEffect(() => { 10 | Router.events.on('routeChangeStart', () => { 11 | setPercent(95); 12 | }); 13 | Router.events.on('routeChangeComplete', () => { 14 | setPercent(100); 15 | }); 16 | }); 17 | 18 | return ( 19 |
20 | 21 |
22 | ); 23 | }; 24 | 25 | export default ProgressLine; 26 | -------------------------------------------------------------------------------- /src/components/SimpleHeading.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Typography, Row, Col } from 'antd'; 3 | const { Title } = Typography; 4 | 5 | interface SimpleHeadingProps extends React.CSSProperties { 6 | title: string; 7 | level?: 1 | 2 | 3 | 4; 8 | } 9 | 10 | const SimpleHeading: React.FC = ({ 11 | marginTop = 50, 12 | marginBottom = 30, 13 | textTransform = 'none', 14 | level, 15 | title 16 | }) => { 17 | return ( 18 | 19 | 20 | 21 | {title} 22 | 23 | 24 | 25 | ); 26 | }; 27 | 28 | export default SimpleHeading; 29 | -------------------------------------------------------------------------------- /src/components/SingleProduct/CartNotification.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { notification, Button } from 'antd'; 3 | import { SmileOutlined } from '@ant-design/icons'; 4 | import Link from 'next/link'; 5 | 6 | const cartNotification = () => { 7 | const key = `open${Date.now()}`; 8 | const btn = ( 9 | 10 | 17 | 18 | ); 19 | 20 | notification.open({ 21 | message: 'Item added to cart', 22 | description: 23 | 'You have successfully added an item to your cart. To check out, click the button below.', 24 | icon: , 25 | top: 50, 26 | duration: 2, 27 | btn, 28 | key 29 | }); 30 | }; 31 | 32 | export default cartNotification; 33 | -------------------------------------------------------------------------------- /src/components/SingleProduct/SingleProduct.less: -------------------------------------------------------------------------------- 1 | .product-wrapper { 2 | max-width: 700px; 3 | margin: 50px auto; 4 | @media (max-width: 767px) { 5 | margin: 0 auto; 6 | } 7 | .product-image { 8 | background-color: #ededed; 9 | img { 10 | width: 100%; 11 | object-fit: cover; 12 | } 13 | } 14 | .product-description { 15 | padding-left: 25px; 16 | @media (max-width: 700px) { 17 | padding-right: 25px; 18 | } 19 | .price-description { 20 | span.ant-typography { 21 | font-size: 30px; 22 | &:not(.on_sale) { 23 | color: @primary-color; 24 | } 25 | } 26 | } 27 | .ant-descriptions-title { 28 | font-size: 35px; 29 | } 30 | .ant-descriptions-item-label { 31 | font-size: 18px; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/components/SingleProduct/SingleProduct.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Row, Col, Typography, Descriptions, Button } from 'antd'; 3 | import cartNotification from './CartNotification'; 4 | import { Product, addToCart } from '../../actions'; 5 | import { useDispatch } from 'react-redux'; 6 | import { SingleProductContext } from '../../contexts'; 7 | import './SingleProduct.less'; 8 | 9 | const { Text } = Typography; 10 | const { Item } = Descriptions; 11 | 12 | interface SingleProductProps { 13 | product: Product; 14 | } 15 | 16 | const SingleProduct: React.FC = ({ product }) => { 17 | const breakpoints = React.useContext(SingleProductContext); 18 | const dispatch = useDispatch(); 19 | 20 | const { 21 | id, 22 | name, 23 | description, 24 | images, 25 | regular_price, 26 | sale_price, 27 | on_sale, 28 | price 29 | } = product; 30 | const productId = `${id}`; 31 | const featured_image = images.length > 0 ? images[0].src : ''; 32 | 33 | const addItemToCart = () => { 34 | dispatch(addToCart(productId, price)); 35 | cartNotification(); 36 | }; 37 | 38 | return ( 39 | <> 40 | 41 | 48 | {featured_image && } 49 | 50 | 57 | 58 | 59 | 64 | ${regular_price} 65 | 66 | {on_sale && ${sale_price}} 67 | 68 | 69 |

70 | 71 | 72 | 75 | 76 | 77 | 78 | 79 | 80 | ); 81 | }; 82 | 83 | export default SingleProduct; 84 | -------------------------------------------------------------------------------- /src/components/SingleProduct/SingleProductRenderer.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Product } from '../../actions'; 3 | import SingleProduct from './SingleProduct'; 4 | import SingleProductSkeleton from './SingleProductSkeleton/SingleProductSkeleton'; 5 | import { SingleProductContext, Breakpoints } from '../../contexts'; 6 | 7 | interface SingleProductRendererProps { 8 | product?: Product; 9 | loading: boolean; 10 | breakpoints: Breakpoints[]; 11 | } 12 | 13 | const SingleProductRenderer: React.FC = ({ 14 | product, 15 | loading, 16 | breakpoints 17 | }) => { 18 | return ( 19 | 20 | {!product || loading ? ( 21 | 22 | ) : ( 23 | 24 | )} 25 | 26 | ); 27 | }; 28 | 29 | export default SingleProductRenderer; 30 | -------------------------------------------------------------------------------- /src/components/SingleProduct/SingleProductSkeleton/SingleProductSkeleton.less: -------------------------------------------------------------------------------- 1 | .product-skeleton-wrapper { 2 | max-width: 700px; 3 | margin: 50px auto; 4 | 5 | .product-skeleton-image { 6 | @media (max-width: 700px) { 7 | width: 100%; 8 | } 9 | .ant-skeleton-header { 10 | padding-right: 0; 11 | .ant-skeleton-avatar { 12 | width: 100%; 13 | min-height: 350px; 14 | } 15 | } 16 | } 17 | .product-skeleton-description { 18 | padding-left: 25px; 19 | @media (max-width: 700px) { 20 | width: 100%; 21 | padding-right: 25px; 22 | } 23 | .ant-skeleton-title { 24 | height: 40px; 25 | margin-bottom: 35px; 26 | } 27 | .ant-skeleton-paragraph { 28 | & > li:nth-child(1) { 29 | height: 30px; 30 | margin-bottom: 30px; 31 | } 32 | & > li:nth-child(2) { 33 | height: 20px; 34 | } 35 | } 36 | .ant-skeleton-button { 37 | width: 100px; 38 | margin-top: 20px; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/components/SingleProduct/SingleProductSkeleton/SingleProductSkeleton.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Row, Col, Skeleton } from 'antd'; 3 | import { SingleProductContext } from '../../../contexts'; 4 | import './SingleProductSkeleton.less'; 5 | 6 | const { Button } = Skeleton; 7 | 8 | const SingleProductSkeleton: React.FC = () => { 9 | const breakpoints = React.useContext(SingleProductContext); 10 | 11 | return ( 12 | 13 | 20 | 27 | 28 | 35 | 45 |