From 67d05ea165c22a8cedf98b38d73ca9593b73a70b Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Tue, 23 Feb 2021 11:32:54 -0500 Subject: [PATCH] Moved the features to be environment variable only --- components/product/ProductCard/ProductCard.tsx | 2 -- components/product/ProductView/ProductView.tsx | 3 +-- next.config.js | 2 +- pages/index.tsx | 10 ---------- pages/product/[slug].tsx | 11 +---------- pages/search.tsx | 8 -------- pages/wishlist.tsx | 3 +-- 7 files changed, 4 insertions(+), 35 deletions(-) diff --git a/components/product/ProductCard/ProductCard.tsx b/components/product/ProductCard/ProductCard.tsx index 52ce129dd..3c28e6663 100644 --- a/components/product/ProductCard/ProductCard.tsx +++ b/components/product/ProductCard/ProductCard.tsx @@ -11,7 +11,6 @@ interface Props { product: Product variant?: 'slim' | 'simple' imgProps?: Omit - wishlist?: boolean } const placeholderImg = '/product-img-placeholder.svg' @@ -21,7 +20,6 @@ const ProductCard: FC = ({ product, variant, imgProps, - wishlist = false, ...props }) => ( diff --git a/components/product/ProductView/ProductView.tsx b/components/product/ProductView/ProductView.tsx index e666e1a08..51b9888b0 100644 --- a/components/product/ProductView/ProductView.tsx +++ b/components/product/ProductView/ProductView.tsx @@ -19,10 +19,9 @@ interface Props { className?: string children?: any product: Product - wishlist?: boolean } -const ProductView: FC = ({ product, wishlist = false }) => { +const ProductView: FC = ({ product }) => { const addItem = useAddItem() const { price } = usePrice({ amount: product.price.value, diff --git a/next.config.js b/next.config.js index 939031884..fe4441dda 100644 --- a/next.config.js +++ b/next.config.js @@ -7,7 +7,7 @@ module.exports = { defaultLocale: 'en-US', }, env: { - WISHLIST_ENABLED: false, + WISHLIST_ENABLED: true, }, rewrites() { return [ diff --git a/pages/index.tsx b/pages/index.tsx index c4fb68252..3a84112e5 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -8,7 +8,6 @@ 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' -import Features from '@commerce/utils/features' export async function getStaticProps({ preview, @@ -24,7 +23,6 @@ export async function getStaticProps({ const { categories, brands } = await getSiteInfo({ config, preview }) const { pages } = await getAllPages({ config, preview }) - const isWishlistEnabled = Features.isEnabled('wishlist') return { props: { @@ -32,9 +30,6 @@ export async function getStaticProps({ categories, brands, pages, - commerceFeatures: { - wishlist: isWishlistEnabled, - }, }, revalidate: 14400, } @@ -44,7 +39,6 @@ export default function Home({ products, brands, categories, - commerceFeatures, }: InferGetStaticPropsType) { return ( <> @@ -57,7 +51,6 @@ export default function Home({ width: i === 0 ? 1080 : 540, height: i === 0 ? 1080 : 540, }} - wishlist={!!process.env.WISHLIST_ENABLED} /> ))} @@ -71,7 +64,6 @@ export default function Home({ width: 320, height: 320, }} - wishlist={!!process.env.WISHLIST_ENABLED} /> ))} @@ -94,7 +86,6 @@ export default function Home({ width: i === 0 ? 1080 : 540, height: i === 0 ? 1080 : 540, }} - wishlist={!!process.env.WISHLIST_ENABLED} /> ))} @@ -108,7 +99,6 @@ export default function Home({ width: 320, height: 320, }} - wishlist={!!process.env.WISHLIST_ENABLED} /> ))} diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 90da202b2..61420a8d9 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -11,14 +11,12 @@ 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' -import Features from '@commerce/utils/features' export async function getStaticProps({ params, locale, preview, }: GetStaticPropsContext<{ slug: string }>) { - const isWishlistEnabled = Features.isEnabled('wishlist') const config = getConfig({ locale }) const { pages } = await getAllPages({ config, preview }) const { product } = await getProduct({ @@ -35,9 +33,6 @@ export async function getStaticProps({ props: { pages, product, - commerceFeatures: { - wishlist: isWishlistEnabled, - }, }, revalidate: 200, } @@ -62,17 +57,13 @@ export async function getStaticPaths({ locales }: GetStaticPathsContext) { export default function Slug({ product, - commerceFeatures, }: InferGetStaticPropsType) { const router = useRouter() return router.isFallback ? (

Loading...

// TODO (BC) Add Skeleton Views ) : ( - + ) } diff --git a/pages/search.tsx b/pages/search.tsx index d62ce22d4..a05203892 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -26,8 +26,6 @@ const SORT = Object.entries({ 'price-desc': 'Price: High to low', }) -import Features from '@commerce/utils/features' - import { filterQuery, getCategoryPath, @@ -43,15 +41,11 @@ export async function getStaticProps({ const config = getConfig({ locale }) const { pages } = await getAllPages({ config, preview }) const { categories, brands } = await getSiteInfo({ config, preview }) - const isWishlistEnabled = Features.isEnabled('wishlist') return { props: { pages, categories, brands, - commerceFeatures: { - wishlist: isWishlistEnabled, - }, }, } } @@ -59,7 +53,6 @@ export async function getStaticProps({ export default function Search({ categories, brands, - commerceFeatures: { wishlist }, }: InferGetStaticPropsType) { const [activeFilter, setActiveFilter] = useState('') const [toggleFilter, setToggleFilter] = useState(false) @@ -359,7 +352,6 @@ export default function Search({ width: 480, height: 480, }} - wishlist={wishlist} /> ))} diff --git a/pages/wishlist.tsx b/pages/wishlist.tsx index ca11152f4..dcda912c6 100644 --- a/pages/wishlist.tsx +++ b/pages/wishlist.tsx @@ -11,14 +11,13 @@ 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' -import Features from '@commerce/utils/features' export async function getStaticProps({ preview, locale, }: GetStaticPropsContext) { // Disabling page if Feature is not available - if (Features.isEnabled('wishlist')) { + if (!process.env.WISHLIST_ENABLED) { return { notFound: true, }