Skip to content

Commit

Permalink
Merge pull request #141 from vtex-apps/fix/legacy-attachment
Browse files Browse the repository at this point in the history
Fix Attachment List on legacy
  • Loading branch information
gustavorosolem committed Apr 8, 2019
2 parents cff60ba + a48b88f commit a41507e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [2.15.2] - 2019-04-08
### Fixed
- Legacy should use attachment list component from legacy.

## [2.15.1] - 2019-04-08
### Fixed
- Rename interface `_` to `product-summary-space` to prevent conflict.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"vendor": "vtex",
"name": "product-summary",
"version": "2.15.1",
"version": "2.15.2",
"title": "Product Summary",
"description": "Product summary component",
"defaultLocale": "pt-BR",
Expand Down
35 changes: 35 additions & 0 deletions react/legacy/components/AttachmentList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'
import { productShape } from '../../utils/propTypes'
import { pathOr } from 'ramda'

import RemovedAttachmentsList from '../../components/ProductSummaryAttachmentList/RemovedAttachmentsList'
import AddedAttachmentsList from '../../components/ProductSummaryAttachmentList/AddedAttachmentsList'

import styles from '../../productSummary.css'

const shouldShowOption = option => option.extraQuantity > 0 || option.item.sellingPrice !== 0

const AttachmentList = ({ product }) => {
const addedOptions = pathOr([], ['assemblyOptions', 'added'], product)
const removedOptions = pathOr([], ['assemblyOptions', 'removed'], product)
const parentPrice = pathOr(0, ['assemblyOptions', 'parentPrice'], product)

const filteredOption = addedOptions.filter(shouldShowOption)

if (filteredOption.length === 0 && removedOptions.length === 0) {
return null
}

return (
<div className={`${styles.attachmentListContainer} pv2`}>
<AddedAttachmentsList addedOptions={filteredOption} parentPrice={parentPrice} />
<RemovedAttachmentsList removedOptions={removedOptions} />
</div>
)
}

AttachmentList.propTypes = {
product: productShape,
}

export default AttachmentList
2 changes: 1 addition & 1 deletion react/legacy/components/ProductSummaryInline.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { path } from 'ramda'
import classNames from 'classnames'
import { Link } from 'vtex.render-runtime'

import AttachmentList from '../../components/ProductSummaryAttachmentList/AttachmentList'
import AttachmentList from './AttachmentList'
import ImageLoader from '../../components/ProductSummaryImage/ImageLoader'
import ProductImage from './ProductImage'
import ProductSummaryBuyButton from './ProductSummaryBuyButton'
Expand Down
2 changes: 1 addition & 1 deletion react/legacy/components/ProductSummaryInlinePrice.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { path } from 'ramda'
import classNames from 'classnames'
import { Link } from 'vtex.render-runtime'

import AttachmentList from '../../components/ProductSummaryAttachmentList/AttachmentList'
import AttachmentList from './AttachmentList'
import ImageLoader from '../../components/ProductSummaryImage/ImageLoader'
import ProductImage from './ProductImage'
import ProductQuantityStepper from './ProductQuantityStepper'
Expand Down
2 changes: 1 addition & 1 deletion react/legacy/components/ProductSummaryNormal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { path } from 'ramda'
import classNames from 'classnames'
import { Link } from 'vtex.render-runtime'

import AttachmentList from '../../components/ProductSummaryAttachmentList/AttachmentList'
import AttachmentList from './AttachmentList'
import ImageLoader from '../../components/ProductSummaryImage/ImageLoader'
import ProductImage from './ProductImage'
import ProductSummaryBuyButton from './ProductSummaryBuyButton'
Expand Down
2 changes: 1 addition & 1 deletion react/legacy/components/ProductSummarySmall.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { path } from 'ramda'
import classNames from 'classnames'
import { Link } from 'vtex.render-runtime'

import AttachmentList from '../../components/ProductSummaryAttachmentList/AttachmentList'
import AttachmentList from './AttachmentList'
import ImageLoader from '../../components/ProductSummaryImage/ImageLoader'
import ProductImage from './ProductImage'
import ProductSummaryBuyButton from './ProductSummaryBuyButton'
Expand Down

0 comments on commit a41507e

Please sign in to comment.