-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🌸
Marketplace
: Distinguish the Cart
from the Menu
- #2043 - #1326 While we definitely need a `Cart`; treating the `Cart` as the `Menu` is a clunky ducky way of operating.
- Loading branch information
Showing
18 changed files
with
147 additions
and
201 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Marketplace | ||
class CartProduct::QuantityPicker < Model | ||
attr_accessor :cart_product | ||
delegate :location, :quantity, to: :cart_product | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
app/furniture/marketplace/cart_product/quantity_pickers/_quantity_picker.html.erb
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,13 @@ | ||
<div class="flex flex-row justify-between items-center"> | ||
<%- if quantity_picker.quantity < 1%> | ||
<span></span> | ||
<%- elsif quantity_picker.quantity == 1 %> | ||
<%= button_to("🗑️", quantity_picker.location, method: :delete) %> | ||
<%- else %> | ||
<%= button_to("➖", quantity_picker.location, method: :put, params: { cart_product: { quantity: quantity_picker.quantity - 1 } }) %> | ||
<%- end %> | ||
|
||
<span class="py-2 px-2 my-1 text-lg"><%= quantity_picker.quantity %></span> | ||
|
||
<%= button_to("➕", quantity_picker.location, method: :put, params: { cart_product: { quantity: quantity_picker.quantity + 1 } }) %> | ||
</div> |
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
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
<div class="grid grid-cols-1 gap-6"> | ||
|
||
|
||
<%= render delivery_area_component %> | ||
<%= render Marketplace::MenuComponent.new(marketplace:, cart:) %> | ||
<%= render cart %> | ||
</div> |
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,34 @@ | ||
<%= render CardComponent.new(dom_id: dom_id(product)) do |card| %> | ||
<%- card.with_header do %> | ||
<% if product.photo.present? %> | ||
<figure> | ||
<%= image_tag hero_image, class: "w-full" %> | ||
<figcaption class="px-4"> | ||
<h3><%= name %></h3> | ||
<%- if product.archived? %> | ||
<span class="italic">(archived)</span> | ||
<%- end %> | ||
</figcaption> | ||
</figure> | ||
<%- else %> | ||
<h3 class="px-4"><%= name %></h3> | ||
<% end %> | ||
<%- end %> | ||
<div class="text-sm italic"> | ||
<%= description %> | ||
</div> | ||
|
||
<div class="text-right mt-3"> | ||
<p><%= price %></p> | ||
</div> | ||
|
||
<%- card.with_footer do %> | ||
<%- cart_product = cart.cart_products.find_by(product:) %> | ||
<%- if !cart_product %> | ||
<%= button_to("Add to Cart", cart.location(child: :cart_products), method: :post, params: { cart_product: { product_id: product.id, quantity: 1 } }) %> | ||
<%- else %> | ||
<%= render cart_product.quantity_picker %> | ||
<%- end %> | ||
<%- end %> | ||
<%- end %> |
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,9 @@ | ||
class Marketplace | ||
class Menu::ProductComponent < ProductComponent | ||
attr_accessor :cart | ||
def initialize(product:, cart:, **kwargs) | ||
super(product:, **kwargs) | ||
self.cart = cart | ||
end | ||
end | ||
end |
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,5 @@ | ||
<div class="grid sm:grid-cols-2 lg:grid-cols-3 gap-3"> | ||
<%- marketplace.products.unarchived.each do |product| %> | ||
<%= render Marketplace::Menu::ProductComponent.new(product:, cart:)%> | ||
<%- end %> | ||
</div> |
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,11 @@ | ||
class Marketplace | ||
class MenuComponent < ApplicationComponent | ||
attr_accessor :marketplace, :cart | ||
|
||
def initialize(marketplace:, cart:, **kwargs) | ||
super(**kwargs) | ||
self.marketplace = marketplace | ||
self.cart = cart | ||
end | ||
end | ||
end |
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,3 @@ | ||
<%- breadcrumb :marketplace_product, product %> | ||
<h3><%= product.name %></h3> | ||
<p><%= product.description %></p> |
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 |
---|---|---|
|
@@ -31,6 +31,10 @@ def index | |
skip_authorization | ||
end | ||
|
||
def show | ||
authorize(product) | ||
end | ||
|
||
def edit | ||
authorize(product) | ||
end | ||
|
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
Oops, something went wrong.