From 9794d5e62614c55170946a9dc2b3bc77870e3e44 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Fri, 21 May 2021 15:06:21 -0500 Subject: [PATCH] Moved getAllPages everywhere --- pages/blog.tsx | 4 ++-- pages/cart.tsx | 4 ++-- pages/index.tsx | 4 ++-- pages/orders.tsx | 4 ++-- pages/product/[slug].tsx | 4 ++-- pages/profile.tsx | 4 ++-- pages/search.tsx | 21 ++++++++++----------- pages/wishlist.tsx | 4 ++-- 8 files changed, 24 insertions(+), 25 deletions(-) diff --git a/pages/blog.tsx b/pages/blog.tsx index eca3b2295..10dba8c56 100644 --- a/pages/blog.tsx +++ b/pages/blog.tsx @@ -1,6 +1,6 @@ import type { GetStaticPropsContext } from 'next' import { getConfig } from '@framework/api' -import getAllPages from '@framework/common/get-all-pages' +import commerce from '@lib/api/commerce' import { Layout } from '@components/common' import { Container } from '@components/ui' @@ -9,7 +9,7 @@ export async function getStaticProps({ locale, }: GetStaticPropsContext) { const config = getConfig({ locale }) - const { pages } = await getAllPages({ config, preview }) + const { pages } = await commerce.getAllPages({ config, preview }) return { props: { pages }, } diff --git a/pages/cart.tsx b/pages/cart.tsx index cd5bedacc..e318ee6e9 100644 --- a/pages/cart.tsx +++ b/pages/cart.tsx @@ -1,8 +1,8 @@ import type { GetStaticPropsContext } from 'next' import { getConfig } from '@framework/api' -import getAllPages from '@framework/common/get-all-pages' import useCart from '@framework/cart/use-cart' import usePrice from '@framework/product/use-price' +import commerce from '@lib/api/commerce' import { Layout } from '@components/common' import { Button, Text } from '@components/ui' import { Bag, Cross, Check, MapPin, CreditCard } from '@components/icons' @@ -13,7 +13,7 @@ export async function getStaticProps({ locale, }: GetStaticPropsContext) { const config = getConfig({ locale }) - const { pages } = await getAllPages({ config, preview }) + const { pages } = await commerce.getAllPages({ config, preview }) return { props: { pages }, } diff --git a/pages/index.tsx b/pages/index.tsx index 3a84112e5..ac01a5dbe 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,3 +1,4 @@ +import commerce from '@lib/api/commerce' import { Layout } from '@components/common' import { Grid, Marquee, Hero } from '@components/ui' import { ProductCard } from '@components/product' @@ -7,7 +8,6 @@ import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import { getConfig } from '@framework/api' import getAllProducts from '@framework/product/get-all-products' import getSiteInfo from '@framework/common/get-site-info' -import getAllPages from '@framework/common/get-all-pages' export async function getStaticProps({ preview, @@ -22,7 +22,7 @@ export async function getStaticProps({ }) const { categories, brands } = await getSiteInfo({ config, preview }) - const { pages } = await getAllPages({ config, preview }) + const { pages } = await commerce.getAllPages({ config, preview }) return { props: { diff --git a/pages/orders.tsx b/pages/orders.tsx index db4ab55b2..f1dd630ac 100644 --- a/pages/orders.tsx +++ b/pages/orders.tsx @@ -1,16 +1,16 @@ import type { GetStaticPropsContext } from 'next' +import commerce from '@lib/api/commerce' import { Bag } from '@components/icons' import { Layout } from '@components/common' import { Container, Text } from '@components/ui' import { getConfig } from '@framework/api' -import getAllPages from '@framework/common/get-all-pages' export async function getStaticProps({ preview, locale, }: GetStaticPropsContext) { const config = getConfig({ locale }) - const { pages } = await getAllPages({ config, preview }) + const { pages } = await commerce.getAllPages({ config, preview }) return { props: { pages }, } diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 61420a8d9..f1a94032a 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -4,12 +4,12 @@ import type { InferGetStaticPropsType, } from 'next' import { useRouter } from 'next/router' +import commerce from '@lib/api/commerce' import { Layout } from '@components/common' import { ProductView } from '@components/product' import { getConfig } from '@framework/api' import getProduct from '@framework/product/get-product' -import getAllPages from '@framework/common/get-all-pages' import getAllProductPaths from '@framework/product/get-all-product-paths' export async function getStaticProps({ @@ -18,7 +18,7 @@ export async function getStaticProps({ preview, }: GetStaticPropsContext<{ slug: string }>) { const config = getConfig({ locale }) - const { pages } = await getAllPages({ config, preview }) + const { pages } = await commerce.getAllPages({ config, preview }) const { product } = await getProduct({ variables: { slug: params!.slug }, config, diff --git a/pages/profile.tsx b/pages/profile.tsx index ec845c879..0c9d7b26d 100644 --- a/pages/profile.tsx +++ b/pages/profile.tsx @@ -1,7 +1,7 @@ import type { GetStaticPropsContext } from 'next' import { getConfig } from '@framework/api' -import getAllPages from '@framework/common/get-all-pages' import useCustomer from '@framework/customer/use-customer' +import commerce from '@lib/api/commerce' import { Layout } from '@components/common' import { Container, Text } from '@components/ui' @@ -10,7 +10,7 @@ export async function getStaticProps({ locale, }: GetStaticPropsContext) { const config = getConfig({ locale }) - const { pages } = await getAllPages({ config, preview }) + const { pages } = await commerce.getAllPages({ config, preview }) return { props: { pages }, } diff --git a/pages/search.tsx b/pages/search.tsx index da2edccd8..42c7f7af5 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -10,11 +10,18 @@ import { Container, Grid, Skeleton } from '@components/ui' import { getConfig } from '@framework/api' import useSearch from '@framework/product/use-search' -import getAllPages from '@framework/common/get-all-pages' import getSiteInfo from '@framework/common/get-site-info' - +import commerce from '@lib/api/commerce' import rangeMap from '@lib/range-map' +import { + filterQuery, + getCategoryPath, + getDesignerPath, + useSearchMeta, +} from '@lib/search' +import { Product } from '@commerce/types' + // TODO(bc) Remove this. This should come from the API import getSlug from '@lib/get-slug' @@ -26,20 +33,12 @@ const SORT = Object.entries({ 'price-desc': 'Price: High to low', }) -import { - filterQuery, - getCategoryPath, - getDesignerPath, - useSearchMeta, -} from '@lib/search' -import { Product } from '@commerce/types' - export async function getStaticProps({ preview, locale, }: GetStaticPropsContext) { const config = getConfig({ locale }) - const { pages } = await getAllPages({ config, preview }) + const { pages } = await commerce.getAllPages({ config, preview }) const { categories, brands } = await getSiteInfo({ config, preview }) return { props: { diff --git a/pages/wishlist.tsx b/pages/wishlist.tsx index 0dddaf23d..ef49dfff3 100644 --- a/pages/wishlist.tsx +++ b/pages/wishlist.tsx @@ -1,4 +1,5 @@ import type { GetStaticPropsContext } from 'next' +import commerce from '@lib/api/commerce' import { Heart } from '@components/icons' import { Layout } from '@components/common' import { Text, Container } from '@components/ui' @@ -7,7 +8,6 @@ import { getConfig } from '@framework/api' import { useCustomer } from '@framework/customer' import { WishlistCard } from '@components/wishlist' import useWishlist from '@framework/wishlist/use-wishlist' -import getAllPages from '@framework/common/get-all-pages' export async function getStaticProps({ preview, @@ -21,7 +21,7 @@ export async function getStaticProps({ } const config = getConfig({ locale }) - const { pages } = await getAllPages({ config, preview }) + const { pages } = await commerce.getAllPages({ config, preview }) return { props: { pages,