4
0
forked from crowetic/commerce

Merge pull request #15 from okbel/use-bigcommerce-package

Use @bigcommerce/storefront-data-hooks
This commit is contained in:
Luc Leray 2020-10-27 02:49:54 +01:00 committed by GitHub
commit 8513c4b18b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 70 additions and 58 deletions

View File

@ -3,7 +3,7 @@ import { validate } from 'email-validator'
import { Info } from '@components/icons'
import { useUI } from '@components/ui/context'
import { Logo, Button, Input } from '@components/ui'
import useSignup from '@lib/bigcommerce/use-signup'
import useSignup from '@bigcommerce/storefront-data-hooks/dist/use-signup'
interface Props {}

View File

@ -1,6 +1,6 @@
import { FC, useEffect, useState, useCallback } from 'react'
import { Logo, Modal, Button, Input } from '@components/ui'
import useLogin from '@lib/bigcommerce/use-login'
import useLogin from '@bigcommerce/storefront-data-hooks/dist/use-login'
import { useUI } from '@components/ui/context'
import { validate } from 'email-validator'

View File

@ -3,7 +3,7 @@ import { validate } from 'email-validator'
import { Info } from '@components/icons'
import { useUI } from '@components/ui/context'
import { Logo, Button, Input } from '@components/ui'
import useSignup from '@lib/bigcommerce/use-signup'
import useSignup from '@bigcommerce/storefront-data-hooks/dist/use-signup'
interface Props {}

View File

@ -3,9 +3,9 @@ import Image from 'next/image'
import Link from 'next/link'
import { ChangeEvent, useEffect, useState } from 'react'
import { Trash, Plus, Minus } from '@components/icons'
import usePrice from '@lib/bigcommerce/use-price'
import useUpdateItem from '@lib/bigcommerce/cart/use-update-item'
import useRemoveItem from '@lib/bigcommerce/cart/use-remove-item'
import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price'
import useUpdateItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-update-item'
import useRemoveItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-remove-item'
const CartItem = ({
item,

View File

@ -4,8 +4,8 @@ import { UserNav } from '@components/core'
import { Button } from '@components/ui'
import { ArrowLeft, Bag, Cross, Check } from '@components/icons'
import { useUI } from '@components/ui/context'
import useCart from '@lib/bigcommerce/cart/use-cart'
import usePrice from '@lib/bigcommerce/use-price'
import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart'
import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price'
import CartItem from '../CartItem'
import s from './CartSidebarView.module.css'

View File

@ -2,7 +2,7 @@ import { FC } from 'react'
import cn from 'classnames'
import Link from 'next/link'
import { useRouter } from 'next/router'
import type { Page } from '@lib/bigcommerce/api/operations/get-all-pages'
import type { Page } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages'
import getSlug from '@utils/get-slug'
import { Github } from '@components/icons'
import { Logo, Container } from '@components/ui'

View File

@ -1,8 +1,8 @@
import { FC, useCallback, useEffect, useState } from 'react'
import cn from 'classnames'
import { useRouter } from 'next/router'
import type { Page } from '@lib/bigcommerce/api/operations/get-all-pages'
import { CommerceProvider } from '@lib/bigcommerce'
import type { Page } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages'
import { CommerceProvider } from '@bigcommerce/storefront-data-hooks/dist'
import { CartSidebarView } from '@components/cart'
import { Container, Sidebar, Button, Modal, Toast } from '@components/ui'
import { Navbar, Featurebar, Footer } from '@components/core'

View File

@ -5,7 +5,7 @@ import cn from 'classnames'
import s from './DropdownMenu.module.css'
import { Moon, Sun } from '@components/icons'
import { Menu, Transition } from '@headlessui/react'
import useLogout from '@lib/bigcommerce/use-logout'
import useLogout from '@bigcommerce/storefront-data-hooks/dist/use-logout'
import { useRouter } from 'next/router'
interface DropdownMenuProps {

View File

@ -7,8 +7,8 @@ import { Avatar } from '@components/core'
import { useUI } from '@components/ui/context'
import DropdownMenu from './DropdownMenu'
import { Menu } from '@headlessui/react'
import useCart from '@lib/bigcommerce/cart/use-cart'
import useCustomer from '@lib/bigcommerce/use-customer'
import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart'
import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer'
interface Props {
className?: string
}

View File

@ -1,8 +1,8 @@
import type { FC } from 'react'
import cn from 'classnames'
import Link from 'next/link'
import type { ProductNode } from '@lib/bigcommerce/api/operations/get-all-products'
import usePrice from '@lib/bigcommerce/use-price'
import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-products'
import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price'
import { EnhancedImage } from '@components/core'
import s from './ProductCard.module.css'
import WishlistButton from '@components/wishlist/WishlistButton'

View File

@ -10,8 +10,8 @@ import { Swatch, ProductSlider } from '@components/product'
import { Button, Container } from '@components/ui'
import { HTMLContent } from '@components/core'
import useAddItem from '@lib/bigcommerce/cart/use-add-item'
import type { ProductNode } from '@lib/bigcommerce/api/operations/get-product'
import useAddItem from '@bigcommerce/storefront-data-hooks/dist/cart/use-add-item'
import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product'
import { getProductOptions } from '../helpers'
interface Props {

View File

@ -1,4 +1,4 @@
import type { ProductNode } from '@lib/bigcommerce/api/operations/get-product'
import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product'
export function getProductOptions(product: ProductNode) {
const options = product.productOptions.edges?.map(({ node }: any) => ({

View File

@ -1,10 +1,10 @@
import React, { FC, useState } from 'react'
import cn from 'classnames'
import type { ProductNode } from '@lib/bigcommerce/api/operations/get-all-products'
import useAddItem from '@lib/bigcommerce/wishlist/use-add-item'
import useRemoveItem from '@lib/bigcommerce/wishlist/use-remove-item'
import useWishlist from '@lib/bigcommerce/wishlist/use-wishlist'
import useCustomer from '@lib/bigcommerce/use-customer'
import type { ProductNode } from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-products'
import useAddItem from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-add-item'
import useRemoveItem from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-remove-item'
import useWishlist from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-wishlist'
import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer'
import { Heart } from '@components/icons'
import { useUI } from '@components/ui/context'

View File

@ -19,6 +19,7 @@
"singleQuote": true
},
"dependencies": {
"@bigcommerce/storefront-data-hooks": "^1.0.0",
"@headlessui/react": "^0.2.0",
"@next/bundle-analyzer": "^9.5.5",
"@react-aria/overlays": "^3.4.0",

View File

@ -1,7 +1,7 @@
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
import getSlug from '@utils/get-slug'
import getPage from '@lib/bigcommerce/api/operations/get-page'
import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages'
import getPage from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-page'
import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages'
import { Layout, HTMLContent } from '@components/core'
export async function getStaticProps({

View File

@ -1,3 +1,3 @@
import cartApi from '@lib/bigcommerce/api/cart'
import cartApi from '@bigcommerce/storefront-data-hooks/dist/api/cart'
export default cartApi()

View File

@ -1,3 +1,3 @@
import catalogProductsApi from '@lib/bigcommerce/api/catalog/products'
import catalogProductsApi from '@bigcommerce/storefront-data-hooks/dist/api/catalog/products'
export default catalogProductsApi()

View File

@ -1,3 +1,3 @@
import checkoutApi from '@lib/bigcommerce/api/checkout'
import checkoutApi from '@bigcommerce/storefront-data-hooks/dist/api/checkout'
export default checkoutApi()

View File

@ -1,3 +1,3 @@
import customersApi from '@lib/bigcommerce/api/customers'
import customersApi from '@bigcommerce/storefront-data-hooks/dist/api/customers'
export default customersApi()

View File

@ -1,3 +1,3 @@
import loginApi from '@lib/bigcommerce/api/customers/login'
import loginApi from '@bigcommerce/storefront-data-hooks/dist/api/customers/login'
export default loginApi()

View File

@ -1,3 +1,3 @@
import logoutApi from '@lib/bigcommerce/api/customers/logout'
import logoutApi from '@bigcommerce/storefront-data-hooks/dist/api/customers/logout'
export default logoutApi()

View File

@ -1,3 +1,3 @@
import signupApi from '@lib/bigcommerce/api/customers/signup'
import signupApi from '@bigcommerce/storefront-data-hooks/dist/api/customers/signup'
export default signupApi()

View File

@ -1,3 +1,3 @@
import wishlistApi from '@lib/bigcommerce/api/wishlist'
import wishlistApi from '@bigcommerce/storefront-data-hooks/dist/api/wishlist'
export default wishlistApi()

View File

@ -1,5 +1,5 @@
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages'
import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages'
import { Layout } from '@components/core'
import { Container } from '@components/ui'

View File

@ -1,10 +1,10 @@
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages'
import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages'
import { Layout } from '@components/core'
import { Button } from '@components/ui'
import { Bag, Cross, Check } from '@components/icons'
import useCart from '@lib/bigcommerce/cart/use-cart'
import usePrice from '@lib/bigcommerce/use-price'
import useCart from '@bigcommerce/storefront-data-hooks/dist/cart/use-cart'
import usePrice from '@bigcommerce/storefront-data-hooks/dist/use-price'
import { CartItem } from '@components/cart'
import { Text } from '@components/ui'

View File

@ -1,9 +1,9 @@
import { useMemo } from 'react'
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
import { getConfig } from '@lib/bigcommerce/api'
import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products'
import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info'
import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages'
import { getConfig } from '@bigcommerce/storefront-data-hooks/dist/api'
import getAllProducts from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-products'
import getSiteInfo from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-site-info'
import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages'
import rangeMap from '@lib/range-map'
import { Layout } from '@components/core'
import { Grid, Marquee, Hero } from '@components/ui'

View File

@ -4,12 +4,12 @@ import {
InferGetStaticPropsType,
} from 'next'
import { useRouter } from 'next/router'
import { getConfig } from '@lib/bigcommerce/api'
import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages'
import getProduct from '@lib/bigcommerce/api/operations/get-product'
import { getConfig } from '@bigcommerce/storefront-data-hooks/dist/api'
import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages'
import getProduct from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-product'
import { Layout } from '@components/core'
import { ProductView } from '@components/product'
import getAllProductPaths from '@lib/bigcommerce/api/operations/get-all-product-paths'
import getAllProductPaths from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-product-paths'
export async function getStaticProps({
params,

View File

@ -1,6 +1,6 @@
import { Layout } from '@components/core'
import { Container, Text } from '@components/ui'
import useCustomer from '@lib/bigcommerce/use-customer'
import useCustomer from '@bigcommerce/storefront-data-hooks/dist/use-customer'
export default function Profile() {
const { data } = useCustomer()
console.log(data)

View File

@ -5,9 +5,9 @@ import { useRouter } from 'next/router'
import { Layout } from '@components/core'
import { ProductCard } from '@components/product'
import { Container, Grid, Skeleton } from '@components/ui'
import useSearch from '@lib/bigcommerce/products/use-search'
import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages'
import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info'
import useSearch from '@bigcommerce/storefront-data-hooks/dist/products/use-search'
import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages'
import getSiteInfo from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-site-info'
import rangeMap from '@lib/range-map'
import getSlug from '@utils/get-slug'
import {

View File

@ -1,11 +1,11 @@
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages'
import getAllPages from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-all-pages'
import { Layout } from '@components/core'
import { Container, Text } from '@components/ui'
import { WishlistCard } from '@components/wishlist'
import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info'
import useWishlist from '@lib/bigcommerce/wishlist/use-wishlist'
import getSiteInfo from '@bigcommerce/storefront-data-hooks/dist/api/operations/get-site-info'
import useWishlist from '@bigcommerce/storefront-data-hooks/dist/wishlist/use-wishlist'
export async function getStaticProps({ preview }: GetStaticPropsContext) {
const { pages } = await getAllPages()

View File

@ -1140,6 +1140,17 @@
lodash "^4.17.19"
to-fast-properties "^2.0.0"
"@bigcommerce/storefront-data-hooks@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bigcommerce/storefront-data-hooks/-/storefront-data-hooks-1.0.0.tgz#1f5fe03f44190552e457609f12976deb159711ed"
integrity sha512-vdfNA8dVVBKjbVwCj4KS4hZULTHYEnH0fRFa3ujPybQbvaVO2ltVRTiGbA+hqCZkSMNI5koE6FEO9CIhMrHFsQ==
dependencies:
"@vercel/fetch" "6.1.0"
cookie "0.4.1"
js-cookie "2.2.1"
lodash.debounce "4.0.8"
swr "0.3.6"
"@csstools/convert-colors@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
@ -2400,7 +2411,7 @@
async-retry "^1.3.1"
debug "^3.1.0"
"@vercel/fetch@^6.1.0":
"@vercel/fetch@6.1.0", "@vercel/fetch@^6.1.0":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@vercel/fetch/-/fetch-6.1.0.tgz#4959cd264d25e811b46491818a9d9ca5d752a2a9"
integrity sha512-xR0GQggKhPvwEWrqcrobsQFjyR/bDDbX24BkSaRyLzW+8SydKhkBc/mBCUV8h4SBZSlJMJnqhrxjFCZ1uJcqNg==
@ -3573,7 +3584,7 @@ cookie@0.4.0:
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==
cookie@^0.4.1:
cookie@0.4.1, cookie@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1"
integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==
@ -5303,7 +5314,7 @@ jest-worker@^26.6.1:
merge-stream "^2.0.0"
supports-color "^7.0.0"
js-cookie@^2.2.1:
js-cookie@2.2.1, js-cookie@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
@ -5592,7 +5603,7 @@ lodash._reinterpolate@^3.0.0:
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=
lodash.debounce@^4.0.8:
lodash.debounce@4.0.8, lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
@ -8074,7 +8085,7 @@ supports-color@^7.0.0, supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"
swr@^0.3.3:
swr@0.3.6, swr@^0.3.3:
version "0.3.6"
resolved "https://registry.yarnpkg.com/swr/-/swr-0.3.6.tgz#b1d59439e5114fdf95bb408e1c628ff48f967aac"
integrity sha512-LHbX9vVQSW8Kgyr86zz2fVVKmmT13qxB61uXuUAg6NT4cGu6afzAzT2SVCGEh8pJAD2o8NTZMgclIUxIAbvk7Q==