Skip to content
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

🌸✨ Marketplace: Checkout includes Products, Taxes, and DeliveryFee #1997

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions app/furniture/marketplace/cart/deliveries/_delivery.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<%- if delivery.delivery_area.present? %>
<p class="text-lg font-bold"><%= render(delivery.delivery_area) %></p>
<%- end %>
<p class="text-left py-1 text-sm">
<%= render(Marketplace::Cart::DeliveryExpectationsComponent.new(cart: delivery.cart)) %>
</p>

<%= turbo_frame_tag(delivery) do %>
<% if delivery.details_filled_in? %>
<p class="font-bold">Delivering to:</p>
<div class="rounded p-2 bg-orange-50">
<h3 class="font-bold">Delivering to:</h3>
<p>
<%= render(delivery.delivery_area) %><br />
<span class="text-sm font-light italic"><%= render(Marketplace::Cart::DeliveryExpectationsComponent.new(cart: delivery.cart)) %></span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this text styling become part of the component? Layout styling makes sense for wrapper tags but if these seem like inherent styling attributes of the component itself not of this "area" of the page.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I think pushing this responsibility down is a good idea

Copy link
Member Author

Choose a reason for hiding this comment

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

Ehh, actually let's not do that just yet. DeliveryExpectationsComponent is rendered in a number of places, with a substantially different information hierarchy.

Presuming it should always be small, light, and italic does not seem to be valid.

</p>

<div class="rounded p-2 bg-orange-50 mb-3">
<p>
<%= delivery.contact_email %><br />
<%= number_to_phone(delivery.contact_phone_number) %><br />
Expand All @@ -20,8 +20,7 @@
</p>
</div>

<h2>Payment Details</h2>
<%= button_to("Make Payment", delivery.cart.location(child: :checkout), data: { turbo: false }) %>
<%= button_to("Place Order", delivery.cart.location(child: :checkout), data: { turbo: false }) %>
<%- else %>
<%= render "marketplace/cart/deliveries/form", delivery: delivery %>
<%- end %>
Expand Down
2 changes: 1 addition & 1 deletion app/furniture/marketplace/cart/deliveries/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

<%= render "text_area", attribute: :delivery_notes, form: delivery_form %>

<%= delivery_form.submit %>
<%= delivery_form.submit "Save" %>
<%- end %>
<%- end %>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
choices: cart.marketplace.delivery_areas.pluck(:label, :id), attribute: :delivery_area_id,
form: form,
}) %>
<%= form.submit %>
<%= form.submit "Save" %>
<%- end %>
</div>
29 changes: 25 additions & 4 deletions app/furniture/marketplace/checkouts/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
<%= turbo_frame_tag(checkout.marketplace, data: { turbo_action: :advance }) do %>
<%= link_to(t("marketplace.marketplaces.show.link_to"), marketplace.location) %>
<h1>Checkout</h2>
<%= render CardComponent.new do %>
<%= render cart.delivery %>
<%- end %>
<h2>Checkout</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
<%= render CardComponent.new do %>
<h3>Receipt</h3>
<dl class="grid grid-cols-2 gap-3 w-96">
<%- cart.cart_products.each do |cart_product| %>
<dt class="text-right"><%= cart_product.name %><br />
(<%=cart_product.quantity%>) x <%= humanized_money_with_symbol(cart_product.price) %></dt>
<dd><%= humanized_money_with_symbol(cart_product.price_total) %></dd>
<%- end %>
<dt class="font-bold text-right">Sub Total</dt>
<dd><%= humanized_money_with_symbol(cart.product_total) %></dd>
<dt class="text-right">Delivery Fee <br /> (<%= cart.delivery_area.label %>)</dt>
<dd><%= humanized_money_with_symbol(cart.delivery_fee) %></dd>
<dt class="text-right">Taxes</dt>
<dd><%= humanized_money_with_symbol(cart.tax_total) %></dd>
<dt class="text-right font-bold">Total</dt>
<dd><%= humanized_money_with_symbol(cart.price_total) %></dd>
</dl>
<%- end %>

<%= render CardComponent.new(classes: "mt-3") do %>
<%= render cart.delivery %>
<%- end %>
</div>
<%- end %>
4 changes: 2 additions & 2 deletions spec/furniture/marketplace/buying_products_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ def set_delivery_details(delivery_address:, contact_phone_number:, contact_email
fill_in("Delivery address", with: delivery_address)
fill_in("Contact phone number", with: contact_phone_number)
fill_in("Contact email", with: contact_email)
click_button("Save changes")
click_button("Save")
end

def pay(card_number:, card_expiry:, card_cvc:, billing_name:, email:, billing_postal_code:)
click_button("Make Payment")
click_button("Place Order")
fill_in("cardNumber", with: card_number)
fill_in("cardExpiry", with: card_expiry)
fill_in("cardCvc", with: card_cvc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,5 @@
)
end
end

context "when the Cart is empty" do
let(:cart) { create(:marketplace_cart, marketplace: marketplace) }

it { is_expected.to render_template(:show) }
end
end
end