diff --git a/app/assets/images/cross.svg b/app/assets/images/cross.svg new file mode 100644 index 0000000..ca4e57c --- /dev/null +++ b/app/assets/images/cross.svg @@ -0,0 +1,4 @@ + diff --git a/app/assets/images/tic.svg b/app/assets/images/tic.svg new file mode 100644 index 0000000..9346c14 --- /dev/null +++ b/app/assets/images/tic.svg @@ -0,0 +1,3 @@ + diff --git a/app/assets/stylesheets/application.bootstrap.scss b/app/assets/stylesheets/application.bootstrap.scss index 33233e1..09d7aa1 100644 --- a/app/assets/stylesheets/application.bootstrap.scss +++ b/app/assets/stylesheets/application.bootstrap.scss @@ -200,6 +200,7 @@ $utilities: map-merge( ) ); + .border-solid { border-style: solid; border-color: black; @@ -210,6 +211,11 @@ $utilities: map-merge( transform: translate(-50%, -50%); } +.finish-purchase-logo{ + width: 105px; + height: 129px; +} + .img-highlight{ width: 325px; height: 275px; diff --git a/app/controllers/purchases_controller.rb b/app/controllers/purchases_controller.rb index 530a9e6..2258afe 100644 --- a/app/controllers/purchases_controller.rb +++ b/app/controllers/purchases_controller.rb @@ -7,13 +7,23 @@ def new def create @purchase = Purchase.new(purchase_params) if @purchase.save - redirect_to root_path + redirect_to confirmation_purchases_path else flash.now[:alert] = 'No se pudo realizar la compra, revise el formulario.' render 'new', status: :unprocessable_entity end end + def index + @purchases = Purchase.joins(:payment_method).where(payment_methods: { user: current_user }) + .includes(:gift) + .page(params[:page]) + end + + def show + @purchase = Purchase.find(params[:id]) + end + private def selected_amount diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index a666cb5..ae81d80 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -28,5 +28,8 @@ application.register("notification", NotificationController) import PurchaseProcessController from "./purchase_process_controller" application.register("purchase-process", PurchaseProcessController) +import ShowDestinationsController from "./show_destinations_controller" +application.register("show-destinations", ShowDestinationsController) + import StyleLabelsController from "./style_labels_controller" application.register("style-labels", StyleLabelsController) diff --git a/app/javascript/controllers/show_destinations_controller.js b/app/javascript/controllers/show_destinations_controller.js new file mode 100644 index 0000000..4dbe01a --- /dev/null +++ b/app/javascript/controllers/show_destinations_controller.js @@ -0,0 +1,39 @@ +import { Controller } from "@hotwired/stimulus" + +// Connects to data-controller="show-destinations" +export default class extends Controller { + static classes = ['hide'] + static targets = ['destinationCount', 'rightButton', 'leftButton', 'destinations', 'index'] + + connect() { + if (this.destinationCountTarget.innerHTML == 1) { + this.rightButtonTarget.disabled = true + } + } + + left() { + let actualIndex = parseInt(this.indexTarget.innerHTML) + this.destinationsTarget.children[actualIndex].classList.add(this.hideClass) + this.destinationsTarget.children[actualIndex - 1].classList.remove(this.hideClass) + actualIndex-- + if (actualIndex == 0) { + this.leftButtonTarget.disabled = true + } + this.indexTarget.innerHTML = actualIndex + + this.rightButtonTarget.disabled = false + } + + right() { + let actualIndex = parseInt(this.indexTarget.innerHTML) + this.destinationsTarget.children[actualIndex].classList.add(this.hideClass) + this.destinationsTarget.children[actualIndex + 1].classList.remove(this.hideClass) + actualIndex++ + if (actualIndex + 1 == parseInt(this.destinationCountTarget.innerHTML)) { + this.rightButtonTarget.disabled = true + } + this.indexTarget.innerHTML = actualIndex + + this.leftButtonTarget.disabled = false + } +} diff --git a/app/models/purchase.rb b/app/models/purchase.rb index 0129b63..5ff887e 100644 --- a/app/models/purchase.rb +++ b/app/models/purchase.rb @@ -11,4 +11,8 @@ class Purchase < ApplicationRecord delegate :name, to: :payment_method, prefix: true validates :destinations, length: { minimum: 1 } validates :personalization, :social_reason, :RUT, :destinations, presence: true + + def logo_resized + company_logo.variant(resize_to_limit: [50, 25]).processed + end end diff --git a/app/views/application/_header.html.erb b/app/views/application/_header.html.erb index ff5ac8f..7ea85eb 100644 --- a/app/views/application/_header.html.erb +++ b/app/views/application/_header.html.erb @@ -65,7 +65,7 @@
Te enviaremos una notificación una vez que el servicio esté confirmado.
+ <%= link_to 'VOLVER AL INICIO', root_path, class: 'w-100 btn btn-outline-dark px-5 py-1 fs-sm-5 d-md-none'%> + <%= link_to 'VOLVER AL INICIO', root_path, class: 'd-none d-md-flex btn btn-outline-dark px-5 py-1 fs-5'%> +<%= purchase.gift_name.truncate(12, separator: ' ') %>
+<%= I18n.l(purchase.created_at, format: "%B %d, %Y") %>
+$<%= purchase.gift_price %>
+Subtotal
- <%= form.text_field :subtotal, readonly:true, class: 'fs-2 fs-sm-4 fw-light mb-0 fs-lg-1 border-0 pointer-events-none text-end' %> + <%= form.text_field :subtotal, readonly:true, class: 'fs-2 fs-sm-4 fw-light mb-0 fs-lg-1 border-0 pointer-events-none text-end bg-transparent' %>Costo de envío
diff --git a/app/views/purchases/show.html.erb b/app/views/purchases/show.html.erb new file mode 100644 index 0000000..298b0af --- /dev/null +++ b/app/views/purchases/show.html.erb @@ -0,0 +1,111 @@ +<% content_for :header do %> + <% render 'header', show_mobile: false, categories: @categories, filters: @filters, selected_tab: :none %> +<% end %> +<%= destination.receiver %>
+<%= destination.day %>
+<%= destination.address %>
+<%= destination.number %>
+<%= destination.schedules %>
+<%= destination.cost %>
++ <%= image_tag(@purchase.suprise_delivery ? 'tic.svg' : 'cross.svg', width: '24px', height: '24px', class:'vertical-align-middle') %> + Entrega Sopresa +
++ <%= image_tag(@purchase.resend_delivery ? 'tic.svg' : 'cross.svg', width: '24px', height: '24px', class:'vertical-align-middle') %> + Intentar Reenvíos +
++ Logo Adjuntado: <%= image_tag(@purchase.company_logo.present? ? @purchase.logo_resized : 'cross.svg', class:'vertical-align-middle') %> +
+<%= @purchase.personalization %>
+ +Pagado a través de <%= @purchase.payment_method_name %>
+<%= @purchase.RUT %>
+<%= @purchase.social_reason %>
+TOTAL
+$ <%= @purchase.price %> +