-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common useWishlist helper hook. #3141
Changes from all commits
b8e5e03
1aa9114
28a70d0
e36a09d
b922a3d
f2a53b5
9de4e64
1c9aed8
b6a24ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -390,10 +390,10 @@ export const useProductFullDetail = props => { | |
|
||
// Normalization object for product details we need for rendering. | ||
const productDetails = { | ||
description: product.description, | ||
name: product.name, | ||
...product, | ||
quantity: 1, | ||
price: productPrice, | ||
sku: product.sku | ||
selected_options: selectedOptionsArray | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment for this object implies it was specifically used as a container for display details. I'd prefer to separate the concerns here, and keep the It would also help to include jsdoc in the If we decide to keep your modifications to it we should at least remove the unused There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, all that is gonna change. This will be a helper hook and the consumer of this hook is required to send the data it needs to work in this case |
||
}; | ||
|
||
const derivedErrorMessage = useMemo( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should return correct shape 1`] = ` | ||
Object { | ||
"called": true, | ||
"error": null, | ||
"handleAddToWishlist": [Function], | ||
"isDisabled": true, | ||
"isItemAdded": false, | ||
"loading": true, | ||
} | ||
`; | ||
|
||
exports[`testing handleAddToWishlist should add the product to list 1`] = ` | ||
Array [ | ||
Object { | ||
"variables": Object { | ||
"itemOptions": Object { | ||
"quantity": "1", | ||
"selected_options": "selected options", | ||
"sku": "sku", | ||
}, | ||
"wishlistId": "0", | ||
}, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`testing handleAddToWishlist should call onWishlistUpdateError if there was an error calling the mutation 1`] = ` | ||
Array [ | ||
"Something went wrong", | ||
] | ||
`; | ||
|
||
exports[`testing handleAddToWishlist should call updateWishlistToastProps 1`] = ` | ||
Array [ | ||
Object { | ||
"message": "Item successfully added to your favorites list.", | ||
"timeout": 5000, | ||
"type": "info", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`testing handleAddToWishlist should use necessary translations 1`] = ` | ||
Array [ | ||
Array [ | ||
Object { | ||
"defaultMessage": "Item successfully added to your favorites list.", | ||
"id": "cartPage.wishlist.ce.successMessage", | ||
}, | ||
], | ||
] | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should return correct shape 1`] = ` | ||
Object { | ||
"called": true, | ||
"error": null, | ||
"handleAddToWishlist": [Function], | ||
"handleModalClose": [Function], | ||
"handleModalOpen": [Function], | ||
"isDisabled": true, | ||
"isItemAdded": false, | ||
"isModalOpen": false, | ||
"loading": true, | ||
} | ||
`; | ||
|
||
exports[`testing handleAddToWishlist should add the product to list 1`] = ` | ||
Array [ | ||
Object { | ||
"variables": Object { | ||
"itemOptions": Object { | ||
"quantity": "1", | ||
"selected_options": "selected options", | ||
"sku": "sku", | ||
}, | ||
"wishlistId": "0", | ||
}, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`testing handleAddToWishlist should call onWishlistUpdateError if there was an error calling the mutation 1`] = ` | ||
Array [ | ||
"Something went wrong", | ||
] | ||
`; | ||
|
||
exports[`testing handleAddToWishlist should call updateWishlistToastProps 1`] = ` | ||
Array [ | ||
Object { | ||
"message": "Item successfully added to Bday List.", | ||
"timeout": 5000, | ||
"type": "info", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`testing handleAddToWishlist should use necessary translations 1`] = ` | ||
Array [ | ||
Array [ | ||
Object { | ||
"defaultMessage": "Item successfully added to Bday List.", | ||
"id": "cartPage.wishlist.ee.successMessage", | ||
}, | ||
Object { | ||
"wishlistName": "Bday List", | ||
}, | ||
], | ||
] | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a talon or a hook? Does it need to have the
Wishlist/Wishlist
nesting? I don't really know where to put this file anymore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you are right, this isn't ideal but I dint delete or move code in this case. It was just for presentational purposes. I will move this hook to a different location once I get approval on the code.