Skip to content

Conversation

@JoaoPinhoMinder
Copy link
Contributor

@JoaoPinhoMinder JoaoPinhoMinder commented Mar 11, 2025

Ticket

https://mindera.atlassian.net/browse/ALFMOB-162

Depends on: #41

Description

  • Created WishlistProduct and BagProduct inheriting from SelectedProduct.
  • Made WishlistProduct unique by product ID and color ID.
  • Made BagProduct unique by product ID and variant SKU.
  • Removed size information from WishlistView and ProductListingView.
  • Updated "Add to Bag" action in WishlistView to redirect users to PDP for size selection instead of adding directly to the bag.
  • Disabled "Add to Bag" button on PDP until both color (pre-selected) and size have been selected.

Evidences

Screen.Recording.2025-03-12.at.09.40.43.mov

@JoaoPinhoMinder JoaoPinhoMinder force-pushed the task/ALFMOB-162-improve-wishlist-functionality-on-plp-and-wishlist branch 4 times, most recently from 37c5029 to 399378d Compare March 12, 2025 09:20
@JoaoPinhoMinder JoaoPinhoMinder marked this pull request as ready for review March 12, 2025 09:52
@JoaoPinhoMinder JoaoPinhoMinder marked this pull request as draft March 12, 2025 10:16
@JoaoPinhoMinder JoaoPinhoMinder force-pushed the task/ALFMOB-162-improve-wishlist-functionality-on-plp-and-wishlist branch from 399378d to b07538a Compare March 12, 2025 10:38
@JoaoPinhoMinder JoaoPinhoMinder marked this pull request as ready for review March 12, 2025 10:38
@JoaoPinhoMinder JoaoPinhoMinder force-pushed the task/ALFMOB-162-improve-wishlist-functionality-on-plp-and-wishlist branch from b07538a to f5fc889 Compare March 12, 2025 16:47
Copy link
Member

@reisdev reisdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great additions! Just a couple comments for improvements 🤌🏼


init(productId: String, product: Product?, dependencies: ProductDetailsDependencyContainer) {
var isAddToBagEnabled: Bool {
productHasStock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could probably be inlined? 💅🏼


if let baseProduct {
switch (product, selectedProduct) {
case (.some(let product), .none):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid explicit pattern matching to Optional's .some / .none, and use let foo, let bar? or nil instead

init(
productId: String,
product: Product?,
selectedProduct: SelectedProduct? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this API seems a bit overly complex, do we always need these 3 parameters, or could we have N different init overloads?

return SelectedProduct(product: product, selectedVariant: selectedVariant)
}
}
} // swiftlint:disable:this file_length
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add this at the top of the file via a single // swiftlint:disable file_length

however, would it be possible to modularize this logic so we keep file length under control? 🤓

#endif

struct WishlistView<ViewModel: WishlistViewModelProtocol>: View {
@EnvironmentObject var coordinador: Coordinator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coordinador -> coordinator 😆

@@ -0,0 +1,61 @@
import Foundation

public class SelectedProduct: Identifiable, Equatable, Hashable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hashable: Equatable, so the Equatable conformance is redundant

public let product: Product
public let selectedVariant: Product.Variant

public var name: String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please inline these computed properties for a more compact implementation 💄
(same thing for the other types)


// MARK: Equatable

public static func == (lhs: SelectedProduct, rhs: SelectedProduct) -> Bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is usually a bad™ idea (same thing for the custom Hashable conformance). Why do we need this?
(same thing for the other types)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since i had opened this PR in a wrong way, some discussions can also be threaten in this PR #41. Now i have changed the target branch to point to the branch of whoich this one depends on.

@@ -0,0 +1,9 @@
import Foundation

public class BagProduct: SelectedProduct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a big fan of having models as classes... why do we need this? (same thing for the other Product types)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, did this only because for this use case, i needed to support in wishlist to have the "same" item multiple times if it is added in multiple color variants. Also, i require the Product.Variant to never have a size associated. So i end up with this strategy so i can override the id and also have specific initializations to omit size without polluting the VM with that specific logic.

But i'm open to ideas in this topic, i feel we are fighting the models we are receiving at the moment and exposed that situation which the solution was to mention that in the ticket 😅

.foregroundStyle(Colors.primary.mono400)
Text.build(theme.font.paragraph.normal(configuration.selectedItem?.name ?? ""))
.foregroundStyle(Colors.primary.mono900)
Text.build(theme.font.paragraph.normal(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation is not right™, should probably be:

 Text.build(
    theme.font.paragraph.normal(
        configuration.selectedItem?.name ?? configuration.noItemSelectedTitle
    ) 
)

@JoaoPinhoMinder JoaoPinhoMinder marked this pull request as draft March 26, 2025 12:26
@JoaoPinhoMinder JoaoPinhoMinder force-pushed the task/ALFMOB-162-improve-wishlist-functionality-on-plp-and-wishlist branch from f5fc889 to 50f05b4 Compare March 31, 2025 16:11
@JoaoPinhoMinder JoaoPinhoMinder changed the base branch from main to task/ALFMOB-149-bag-and-wishlist-redirect-to-pdp March 31, 2025 16:11
@JoaoPinhoMinder JoaoPinhoMinder force-pushed the task/ALFMOB-162-improve-wishlist-functionality-on-plp-and-wishlist branch 2 times, most recently from 02e96df to f69d424 Compare April 1, 2025 16:06
@JoaoPinhoMinder JoaoPinhoMinder force-pushed the task/ALFMOB-149-bag-and-wishlist-redirect-to-pdp branch from 46f9f58 to 17c4347 Compare May 5, 2025 15:57
Base automatically changed from task/ALFMOB-149-bag-and-wishlist-redirect-to-pdp to main May 5, 2025 16:05
- Created `WishlistProduct` and `BagProduct` inheriting from `SelectedProduct`.
- Made `WishlistProduct` unique by **product ID and color ID**.
- Made `BagProduct` unique by **product ID and variant SKU**.
- Removed size information from `WishlistView` and `ProductListingView`.
- Updated **"Add to Bag"** action in `WishlistView` to redirect users to **PDP** for size selection instead of adding directly to the bag.
- Disabled **"Add to Bag"** button on **PDP** until both **color** (pre-selected) and **size** have been selected.
@JoaoPinhoMinder JoaoPinhoMinder force-pushed the task/ALFMOB-162-improve-wishlist-functionality-on-plp-and-wishlist branch from ae00fcf to 18bc8b0 Compare May 5, 2025 16:16
@JoaoPinhoMinder JoaoPinhoMinder marked this pull request as ready for review May 5, 2025 16:42
@JoaoPinhoMinder JoaoPinhoMinder requested review from p4checo and reisdev May 5, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants