forked from crowetic/commerce
Moved the features to be environment variable only
This commit is contained in:
parent
a8607f24cd
commit
67d05ea165
@ -11,7 +11,6 @@ interface Props {
|
|||||||
product: Product
|
product: Product
|
||||||
variant?: 'slim' | 'simple'
|
variant?: 'slim' | 'simple'
|
||||||
imgProps?: Omit<ImageProps, 'src'>
|
imgProps?: Omit<ImageProps, 'src'>
|
||||||
wishlist?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const placeholderImg = '/product-img-placeholder.svg'
|
const placeholderImg = '/product-img-placeholder.svg'
|
||||||
@ -21,7 +20,6 @@ const ProductCard: FC<Props> = ({
|
|||||||
product,
|
product,
|
||||||
variant,
|
variant,
|
||||||
imgProps,
|
imgProps,
|
||||||
wishlist = false,
|
|
||||||
...props
|
...props
|
||||||
}) => (
|
}) => (
|
||||||
<Link href={`/product/${product.slug}`} {...props}>
|
<Link href={`/product/${product.slug}`} {...props}>
|
||||||
|
@ -19,10 +19,9 @@ interface Props {
|
|||||||
className?: string
|
className?: string
|
||||||
children?: any
|
children?: any
|
||||||
product: Product
|
product: Product
|
||||||
wishlist?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProductView: FC<Props> = ({ product, wishlist = false }) => {
|
const ProductView: FC<Props> = ({ product }) => {
|
||||||
const addItem = useAddItem()
|
const addItem = useAddItem()
|
||||||
const { price } = usePrice({
|
const { price } = usePrice({
|
||||||
amount: product.price.value,
|
amount: product.price.value,
|
||||||
|
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
defaultLocale: 'en-US',
|
defaultLocale: 'en-US',
|
||||||
},
|
},
|
||||||
env: {
|
env: {
|
||||||
WISHLIST_ENABLED: false,
|
WISHLIST_ENABLED: true,
|
||||||
},
|
},
|
||||||
rewrites() {
|
rewrites() {
|
||||||
return [
|
return [
|
||||||
|
@ -8,7 +8,6 @@ import { getConfig } from '@framework/api'
|
|||||||
import getAllProducts from '@framework/product/get-all-products'
|
import getAllProducts from '@framework/product/get-all-products'
|
||||||
import getSiteInfo from '@framework/common/get-site-info'
|
import getSiteInfo from '@framework/common/get-site-info'
|
||||||
import getAllPages from '@framework/common/get-all-pages'
|
import getAllPages from '@framework/common/get-all-pages'
|
||||||
import Features from '@commerce/utils/features'
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
export async function getStaticProps({
|
||||||
preview,
|
preview,
|
||||||
@ -24,7 +23,6 @@ export async function getStaticProps({
|
|||||||
|
|
||||||
const { categories, brands } = await getSiteInfo({ config, preview })
|
const { categories, brands } = await getSiteInfo({ config, preview })
|
||||||
const { pages } = await getAllPages({ config, preview })
|
const { pages } = await getAllPages({ config, preview })
|
||||||
const isWishlistEnabled = Features.isEnabled('wishlist')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
@ -32,9 +30,6 @@ export async function getStaticProps({
|
|||||||
categories,
|
categories,
|
||||||
brands,
|
brands,
|
||||||
pages,
|
pages,
|
||||||
commerceFeatures: {
|
|
||||||
wishlist: isWishlistEnabled,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
revalidate: 14400,
|
revalidate: 14400,
|
||||||
}
|
}
|
||||||
@ -44,7 +39,6 @@ export default function Home({
|
|||||||
products,
|
products,
|
||||||
brands,
|
brands,
|
||||||
categories,
|
categories,
|
||||||
commerceFeatures,
|
|
||||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -57,7 +51,6 @@ export default function Home({
|
|||||||
width: i === 0 ? 1080 : 540,
|
width: i === 0 ? 1080 : 540,
|
||||||
height: i === 0 ? 1080 : 540,
|
height: i === 0 ? 1080 : 540,
|
||||||
}}
|
}}
|
||||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -71,7 +64,6 @@ export default function Home({
|
|||||||
width: 320,
|
width: 320,
|
||||||
height: 320,
|
height: 320,
|
||||||
}}
|
}}
|
||||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Marquee>
|
</Marquee>
|
||||||
@ -94,7 +86,6 @@ export default function Home({
|
|||||||
width: i === 0 ? 1080 : 540,
|
width: i === 0 ? 1080 : 540,
|
||||||
height: i === 0 ? 1080 : 540,
|
height: i === 0 ? 1080 : 540,
|
||||||
}}
|
}}
|
||||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -108,7 +99,6 @@ export default function Home({
|
|||||||
width: 320,
|
width: 320,
|
||||||
height: 320,
|
height: 320,
|
||||||
}}
|
}}
|
||||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Marquee>
|
</Marquee>
|
||||||
|
@ -11,14 +11,12 @@ import { getConfig } from '@framework/api'
|
|||||||
import getProduct from '@framework/product/get-product'
|
import getProduct from '@framework/product/get-product'
|
||||||
import getAllPages from '@framework/common/get-all-pages'
|
import getAllPages from '@framework/common/get-all-pages'
|
||||||
import getAllProductPaths from '@framework/product/get-all-product-paths'
|
import getAllProductPaths from '@framework/product/get-all-product-paths'
|
||||||
import Features from '@commerce/utils/features'
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
export async function getStaticProps({
|
||||||
params,
|
params,
|
||||||
locale,
|
locale,
|
||||||
preview,
|
preview,
|
||||||
}: GetStaticPropsContext<{ slug: string }>) {
|
}: GetStaticPropsContext<{ slug: string }>) {
|
||||||
const isWishlistEnabled = Features.isEnabled('wishlist')
|
|
||||||
const config = getConfig({ locale })
|
const config = getConfig({ locale })
|
||||||
const { pages } = await getAllPages({ config, preview })
|
const { pages } = await getAllPages({ config, preview })
|
||||||
const { product } = await getProduct({
|
const { product } = await getProduct({
|
||||||
@ -35,9 +33,6 @@ export async function getStaticProps({
|
|||||||
props: {
|
props: {
|
||||||
pages,
|
pages,
|
||||||
product,
|
product,
|
||||||
commerceFeatures: {
|
|
||||||
wishlist: isWishlistEnabled,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
revalidate: 200,
|
revalidate: 200,
|
||||||
}
|
}
|
||||||
@ -62,17 +57,13 @@ export async function getStaticPaths({ locales }: GetStaticPathsContext) {
|
|||||||
|
|
||||||
export default function Slug({
|
export default function Slug({
|
||||||
product,
|
product,
|
||||||
commerceFeatures,
|
|
||||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
return router.isFallback ? (
|
return router.isFallback ? (
|
||||||
<h1>Loading...</h1> // TODO (BC) Add Skeleton Views
|
<h1>Loading...</h1> // TODO (BC) Add Skeleton Views
|
||||||
) : (
|
) : (
|
||||||
<ProductView
|
<ProductView product={product as any} />
|
||||||
product={product as any}
|
|
||||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
|
||||||
/>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ const SORT = Object.entries({
|
|||||||
'price-desc': 'Price: High to low',
|
'price-desc': 'Price: High to low',
|
||||||
})
|
})
|
||||||
|
|
||||||
import Features from '@commerce/utils/features'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
filterQuery,
|
filterQuery,
|
||||||
getCategoryPath,
|
getCategoryPath,
|
||||||
@ -43,15 +41,11 @@ export async function getStaticProps({
|
|||||||
const config = getConfig({ locale })
|
const config = getConfig({ locale })
|
||||||
const { pages } = await getAllPages({ config, preview })
|
const { pages } = await getAllPages({ config, preview })
|
||||||
const { categories, brands } = await getSiteInfo({ config, preview })
|
const { categories, brands } = await getSiteInfo({ config, preview })
|
||||||
const isWishlistEnabled = Features.isEnabled('wishlist')
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
pages,
|
pages,
|
||||||
categories,
|
categories,
|
||||||
brands,
|
brands,
|
||||||
commerceFeatures: {
|
|
||||||
wishlist: isWishlistEnabled,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,7 +53,6 @@ export async function getStaticProps({
|
|||||||
export default function Search({
|
export default function Search({
|
||||||
categories,
|
categories,
|
||||||
brands,
|
brands,
|
||||||
commerceFeatures: { wishlist },
|
|
||||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||||
const [activeFilter, setActiveFilter] = useState('')
|
const [activeFilter, setActiveFilter] = useState('')
|
||||||
const [toggleFilter, setToggleFilter] = useState(false)
|
const [toggleFilter, setToggleFilter] = useState(false)
|
||||||
@ -359,7 +352,6 @@ export default function Search({
|
|||||||
width: 480,
|
width: 480,
|
||||||
height: 480,
|
height: 480,
|
||||||
}}
|
}}
|
||||||
wishlist={wishlist}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -11,14 +11,13 @@ import { useCustomer } from '@framework/customer'
|
|||||||
import { WishlistCard } from '@components/wishlist'
|
import { WishlistCard } from '@components/wishlist'
|
||||||
import useWishlist from '@framework/wishlist/use-wishlist'
|
import useWishlist from '@framework/wishlist/use-wishlist'
|
||||||
import getAllPages from '@framework/common/get-all-pages'
|
import getAllPages from '@framework/common/get-all-pages'
|
||||||
import Features from '@commerce/utils/features'
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
export async function getStaticProps({
|
||||||
preview,
|
preview,
|
||||||
locale,
|
locale,
|
||||||
}: GetStaticPropsContext) {
|
}: GetStaticPropsContext) {
|
||||||
// Disabling page if Feature is not available
|
// Disabling page if Feature is not available
|
||||||
if (Features.isEnabled('wishlist')) {
|
if (!process.env.WISHLIST_ENABLED) {
|
||||||
return {
|
return {
|
||||||
notFound: true,
|
notFound: true,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user