-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from vtex-apps/fix/legacy-attachment
Fix Attachment List on legacy
- Loading branch information
Showing
7 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters