Skip to content

Commit

Permalink
Reset
Browse files Browse the repository at this point in the history
  • Loading branch information
rosschapman committed Nov 13, 2023
1 parent 356ae95 commit fb4adc6
Show file tree
Hide file tree
Showing 26 changed files with 468 additions and 290 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ group :development, :test do

gem "rubocop-rails"
gem "rubocop-rspec"
gem "standard", "~> 1.31"
gem "standard", "~> 1.32"
end

group :development do
Expand Down
41 changes: 20 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ GEM
aws-sigv4 (~> 1.6)
aws-sigv4 (1.6.0)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.1.1)
base64 (0.2.0)
bcrypt (3.1.19)
better_errors (2.10.1)
erubi (>= 1.0.0)
Expand Down Expand Up @@ -169,15 +169,15 @@ GEM
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
railties (>= 3.2)
drb (2.1.1)
drb (2.2.0)
ruby2_keywords
erubi (1.12.0)
factory_bot (6.2.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faker (3.2.1)
faker (3.2.2)
i18n (>= 1.8.11, < 2)
faraday (2.7.11)
base64
Expand Down Expand Up @@ -259,7 +259,7 @@ GEM
method_source (1.0.0)
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.4)
mini_portile2 (2.8.5)
minitest (5.20.0)
monetize (1.12.0)
money (~> 6.12)
Expand All @@ -272,7 +272,7 @@ GEM
railties (>= 3.0)
msgpack (1.7.2)
multipart-post (2.3.0)
mutex_m (0.1.2)
mutex_m (0.2.0)
net-http-persistent (4.0.2)
connection_pool (~> 2.2)
net-imap (0.4.1)
Expand Down Expand Up @@ -307,7 +307,7 @@ GEM
nio4r (~> 2.0)
pundit (2.3.1)
activesupport (>= 3.0.0)
racc (1.7.1)
racc (1.7.3)
rack (2.2.8)
rack-session (1.0.1)
rack (< 3)
Expand Down Expand Up @@ -355,19 +355,19 @@ GEM
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.0.6)
rake (13.1.0)
ranked-model (0.4.9)
activerecord (>= 5.2)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (6.5.0)
rdoc (6.6.0)
psych (>= 4.0.0)
redcarpet (3.6.0)
redis-client (0.18.0)
connection_pool
regexp_parser (2.8.2)
reline (0.3.9)
reline (0.4.0)
io-console (~> 0.5)
rexml (3.2.6)
rotp (6.3.0)
Expand Down Expand Up @@ -399,12 +399,11 @@ GEM
rswag-ui (2.11.0)
actionpack (>= 3.1, < 7.2)
railties (>= 3.1, < 7.2)
rubocop (1.56.4)
base64 (~> 0.1.1)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
Expand Down Expand Up @@ -435,14 +434,14 @@ GEM
ffi (~> 1.12)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
selenium-webdriver (4.14.0)
selenium-webdriver (4.15.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sentry-rails (5.12.0)
sentry-rails (5.13.0)
railties (>= 5.0)
sentry-ruby (~> 5.12.0)
sentry-ruby (5.12.0)
sentry-ruby (~> 5.13.0)
sentry-ruby (5.13.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
shoulda-matchers (5.3.0)
activesupport (>= 5.2.0)
Expand All @@ -469,10 +468,10 @@ GEM
apimatic_core (~> 0.3.0)
apimatic_core_interfaces (~> 0.2.0)
apimatic_faraday_client_adapter (~> 0.1.0)
standard (1.31.2)
standard (1.32.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.56.4)
rubocop (~> 1.57.2)
standard-custom (~> 1.0.0)
standard-performance (~> 1.2)
standard-custom (1.0.2)
Expand All @@ -483,10 +482,10 @@ GEM
rubocop-performance (~> 1.19.1)
stimulus-rails (1.3.0)
railties (>= 6.0.0)
stringio (3.0.8)
stringio (3.0.9)
strip_attributes (1.13.0)
activemodel (>= 3.0, < 8.0)
stripe (10.0.0)
stripe (10.1.0)
strong_migrations (1.6.4)
activerecord (>= 5.2)
thor (1.3.0)
Expand Down Expand Up @@ -575,7 +574,7 @@ DEPENDENCIES
spring-watcher-listen!
sprockets-rails
square.rb
standard (~> 1.31)
standard (~> 1.32)
stimulus-rails
strip_attributes (~> 1.13)
stripe
Expand Down
7 changes: 7 additions & 0 deletions app/components/select_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div>
<% unless @skip_label %>
<%= @form.label @attribute %>
<% end %>
<%= @form.select @attribute, @choices, @options, @html_options %>
<%= render partial: "error", locals: { model: @form.object, attribute: @attribute } %>
</div>
12 changes: 12 additions & 0 deletions app/components/select_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class SelectComponent < ApplicationComponent
def initialize(config, **kwargs)
@form = config.fetch(:form)
@attribute = config.fetch(:attribute)
@choices = config.fetch(:choices, [])
@options = config.fetch(:options, {})
@html_options = config.fetch(:html_options, {})
@skip_label = config.fetch(:skip_label, true)

super(**kwargs)
end
end
13 changes: 10 additions & 3 deletions app/furniture/livestreams/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<%= form.fields_for(:gizmo) do |furniture_fields| %>
<%= render "text_field", form: furniture_fields, attribute: :channel %>
<%= render "select", form: furniture_fields, attribute: :layout, options: ['video', 'video_with_chat'], include_blank: false %>

<%= render "select", form: furniture_fields, attribute: :provider, options: ['twitch'], include_blank: false %>
<%= render SelectComponent.new({
choices: ['video', 'video_with_chat'],
attribute: :layout,
form: furniture_fields,
}) %>
<%= render SelectComponent.new({
choices: ['twitch'],
attribute: :provider,
form: furniture_fields,
}) %>
<%- end %>
18 changes: 13 additions & 5 deletions app/furniture/marketplace/cart/delivery_area_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@
<%- if delivery_area.present? %>
<div>
<%= delivery_area.label %>

<div class="text-sm text-gray-500">
<%= render(Marketplace::Cart::DeliveryExpectationsComponent.new(cart: cart)) %>
<%- if single_delivery_area? %>
<div><small>Orders outside of this location will be subject to cancellation.</small></div>
<% end %>
</div>

</div>

<div class="text-right">
<%= link_to(t('marketplace.cart.delivery_areas.edit.link_to'), cart.location(:edit, child: :delivery_area)) %>
<%- unless single_delivery_area? %>
<%= link_to(t('marketplace.cart.delivery_areas.edit.link_to'), cart.location(:edit, child: :delivery_area)) %>
<%- end %>
</div>
<%- else %>
<%= render "marketplace/cart/delivery_areas/form", cart: cart %>
<%- if single_delivery_area? %>
<div><%= single_delivery_area_label %></div>
<small>Orders outside of this location will be subject to cancellation.
</small>
<% else %>
<%= render "marketplace/cart/delivery_areas/form", cart: cart %>
<%- end %>
<%- end %>
<%- end %>
<%- end %>
8 changes: 8 additions & 0 deletions app/furniture/marketplace/cart/delivery_area_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@ def initialize(*args, cart:, **kwargs)
def dom_id
super(cart, :delivery_area)
end

def single_delivery_area?
cart.marketplace.delivery_areas.size == 1
end

def single_delivery_area_label
cart.marketplace.delivery_areas.first.label
end
end
end
6 changes: 4 additions & 2 deletions app/furniture/marketplace/cart/delivery_areas/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<%= render AlertComponent.new(title: "Where are you Ordering from?") do %>
<p>Delivery prices and times vary based upon your location</p>
<%- end %>

<div class="mt-2 w-full">
<%= form_with model: cart.location, url: cart.location(child: :delivery_area) do |form| %>
<%= render "select", options: cart.marketplace.delivery_areas.pluck(:label, :id), include_blank: true, attribute: :delivery_area_id, form: form, skip_label: true %>
<%= render SelectComponent.new({
choices: cart.marketplace.delivery_areas.pluck(:label, :id), attribute: :delivery_area_id,
form: form,
}) %>
<%= form.submit %>
<%- end %>
</div>
13 changes: 8 additions & 5 deletions app/furniture/marketplace/marketplace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,16 @@ def self.model_name
@_model_name ||= ActiveModel::Name.new(self, ::Marketplace)
end

def square_order_notifications_enabled?
square_location_id.present?
def square_connection
if square_order_notifications_enabled?
@square_client ||= Square::Client.new(access_token: square_access_token, environment: square_environment)
end
end

# TODO: Add `square_environment` attribute to database/model
def square_client
@square_client ||= Square::Client.new(access_token: square_access_token, environment: square_environment)
private

def square_order_notifications_enabled?
square_location_id.present?
end
end
end
3 changes: 2 additions & 1 deletion app/furniture/marketplace/marketplace_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def render?
end

def cart
@cart ||= carts.create_with(contact_email: shopper.person&.email).find_or_create_by(shopper: shopper, status: :pre_checkout)
delivery_area = marketplace.delivery_areas.first if marketplace.delivery_areas.size == 1
@cart ||= carts.create_with(contact_email: shopper.person&.email).find_or_create_by(delivery_area: delivery_area, shopper: shopper, status: :pre_checkout)
end

def delivery_area_component
Expand Down
Loading

0 comments on commit fb4adc6

Please sign in to comment.