fix some option types and pass REACTION_API_DOMAIN to front-end

Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
Loan Laux 2021-05-10 14:58:45 +04:00
parent d5804d60a1
commit 6f0dfb78f3
No known key found for this signature in database
GPG Key ID: AF9E9BD6548AD52E
2 changed files with 4 additions and 4 deletions

View File

@ -53,7 +53,7 @@ const normalizeProductOption = ({ id, displayName, values }: ProductOption) => {
}
}
const normalizeProductVariants = (variants: Maybe<CatalogProductVariant>[]) => {
const normalizeProductVariants = (variants: CatalogProductVariant[]) => {
return variants.map((variant) => {
const { _id, options, sku, title, pricing = [], variantId } = variant ?? {}
const variantPrice = pricing[0]?.price ?? pricing[0]?.minPrice ?? 0
@ -79,7 +79,7 @@ const normalizeProductVariants = (variants: Maybe<CatalogProductVariant>[]) => {
}
export function groupProductOptionsByAttributeLabel(
options: Maybe<CatalogProductVariant>[]
options: CatalogProductVariant[]
) {
return options.reduce((groupedOptions, currentOption) => {
const attributeLabelIndex = groupedOptions.findIndex((option) => {
@ -101,7 +101,7 @@ export function groupProductOptionsByAttributeLabel(
groupedOptions = [
...groupedOptions,
normalizeProductOption({
id: currentOption?.variantId ?? '',
id: currentOption?._id ?? '',
displayName: currentOption?.attributeLabel ?? '',
values: [currentOption?.optionTitle ?? ''],
}),

View File

@ -11,7 +11,7 @@ const isRC = provider === 'reactioncommerce'
module.exports = withCommerceConfig({
env: {
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
REACTION_API_DOMAIN: process.env.REACTION_API_DOMAIN,
},
commerce,
i18n: {