mirror of
https://github.com/System-End/theseus.git
synced 2026-04-19 19:55:10 +00:00
add tracking iframe!
This commit is contained in:
parent
5da418169d
commit
cba8017a6f
4 changed files with 277 additions and 1 deletions
|
|
@ -27,6 +27,16 @@ module Public
|
|||
redirect_to public_package_path(@package)
|
||||
end
|
||||
|
||||
def embed
|
||||
begin
|
||||
@package = Warehouse::Order.find_by!(hc_id: params[:id])
|
||||
@error = true if @package.draft?
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
@error = true
|
||||
end
|
||||
render :embed, layout: false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_package
|
||||
|
|
|
|||
178
app/frontend/entrypoints/tracking_embed.scss
Normal file
178
app/frontend/entrypoints/tracking_embed.scss
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0.5rem; // Reduce padding
|
||||
background-color: transparent; // Transparent for iframe
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.tracking-widget {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background: transparent; // Transparent
|
||||
// Remove border-radius and box-shadow
|
||||
padding: 1rem; // Reduce padding
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.timeline {
|
||||
display: flex;
|
||||
align-items: center; // Change to center for better arrow alignment
|
||||
position: relative;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.step {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.step .icon {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
border-radius: 50%;
|
||||
background: #ffffff;
|
||||
border: none; // Remove border
|
||||
color: #666;
|
||||
margin: 0 auto 0.5rem;
|
||||
font-size: 1.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.step.completed .icon {
|
||||
background: #4caf50;
|
||||
// Remove border-color
|
||||
color: white;
|
||||
}
|
||||
|
||||
.step.backorder .icon {
|
||||
background: #ff9800;
|
||||
// Remove border-color
|
||||
color: white;
|
||||
}
|
||||
|
||||
.step .label {
|
||||
font-weight: bold;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.step .date {
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
align-self: center; // Ensure vertical centering
|
||||
color: #888;
|
||||
font-size: 2rem;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 50px;
|
||||
height: 50px; // Match icon height
|
||||
line-height: 50px;
|
||||
margin: 0 0.5rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.backorder .details {
|
||||
font-size: 0.85rem;
|
||||
color: #ff9800;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.tracking-info {
|
||||
background: #f8f9fa;
|
||||
padding: 1rem;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.tracking-info p {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.contents {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.contents h3 {
|
||||
font-size: 1.2rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.contents ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.contents li {
|
||||
padding: 0.5rem 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.customs {
|
||||
margin-top: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.customs .btn {
|
||||
background: #2196f3;
|
||||
color: white;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
font-size: 1.5rem;
|
||||
color: #f44336;
|
||||
}
|
||||
|
||||
.in-stock {
|
||||
color: #4caf50;
|
||||
font-size: 0.9rem;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
// Responsive adjustments
|
||||
@media (max-width: 600px) {
|
||||
.timeline {
|
||||
align-items: flex-start; // Adjust for column layout
|
||||
}
|
||||
|
||||
.step {
|
||||
flex: none;
|
||||
width: 100%;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
// For vertical layout, center horizontally relative to icons
|
||||
justify-content: center;
|
||||
padding-left: 0;
|
||||
width: 50px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
margin: 0.5rem auto; // Center horizontally
|
||||
transform: rotate(90deg);
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
80
app/views/public/packages/embed.html.erb
Normal file
80
app/views/public/packages/embed.html.erb
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%= vite_client_tag %>
|
||||
<%= vite_stylesheet_tag 'tracking_embed.scss' %>
|
||||
</head>
|
||||
<body>
|
||||
<% if @error %>
|
||||
<div class="error-message">
|
||||
<p>Order not found or not ready yet :(</p>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="tracking-widget">
|
||||
<h2><%= @package.user_facing_title || "Your Order" %> <sup><small>(ID: <%= link_to @package.hc_id, public_package_path(@package), target: "_blank" %>)</small></sup></h2>
|
||||
<div class="timeline">
|
||||
<div class="step <%= 'completed' if @package.created_at %>">
|
||||
<div class="icon">📦</div>
|
||||
<div class="label">Order Placed</div>
|
||||
<div class="date"><%= @package.created_at.strftime("%b %d") %></div>
|
||||
</div>
|
||||
<div class="arrow">→</div>
|
||||
<div class="step <%= 'completed' if @package.dispatched_at %>">
|
||||
<div class="icon">🏭</div>
|
||||
<div class="label">Sent to Warehouse</div>
|
||||
<div class="date"><%= @package.dispatched_at&.strftime("%b %d") || "Pending" %></div>
|
||||
</div>
|
||||
<% if @package.line_items.any? { |li| li.sku.in_stock.to_i < 0 } %>
|
||||
<div class="arrow">→</div>
|
||||
<div class="step backorder">
|
||||
<div class="icon">⏳</div>
|
||||
<div class="label">Awaiting Stock</div>
|
||||
<div class="date">Pending</div>
|
||||
<div class="details">
|
||||
<% @package.line_items.select { |li| li.sku.in_stock.to_i < 0 }.each do |li| %>
|
||||
<p><%= li.sku.name %> is out of stock.
|
||||
<% if li.sku.inbound.to_i > 0 %>
|
||||
More on the way soon!
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="arrow">→</div>
|
||||
<div class="step <%= 'completed' if @package.mailed_at %>">
|
||||
<div class="icon">🚚</div>
|
||||
<div class="label">Shipped</div>
|
||||
<div class="date"><%= @package.mailed_at&.strftime("%b %d") || "Pending" %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% if @package.mailed_at %>
|
||||
<div class="tracking-info">
|
||||
<p><strong>Carrier:</strong> <%= @package.pretty_via %></p>
|
||||
<p><strong>Tracking Number:</strong> <%= link_to @package.tracking_number, @package.tracking_url, target: "_blank" %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless @package.surprise %>
|
||||
<div class="contents">
|
||||
<h3>Contents</h3>
|
||||
<ul>
|
||||
<% @package.line_items.each do |item| %>
|
||||
<li>
|
||||
<%= item.sku.name %> × <%= item.quantity %>
|
||||
<% if !@package.mailed? && item.sku.in_stock.to_i >= 0 %>
|
||||
<span class="in-stock">(in stock)</span>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if !@package.address.us? %>
|
||||
<div class="customs">
|
||||
<%= link_to "customs receipt?", package_generate_customs_receipt_path(@package), method: :post, class: "btn" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -608,8 +608,16 @@ Rails.application.routes.draw do
|
|||
get "/packages/:id/customs_receipt", to: "public/packages#customs_receipt", as: :package_customs_receipt
|
||||
post "/packages/:id/customs_receipt", to: "public/packages#generate_customs_receipt", as: :package_generate_customs_receipt
|
||||
|
||||
namespace :public do
|
||||
resources :packages, only: [:show] do
|
||||
member do
|
||||
get :embed
|
||||
post :generate_customs_receipt
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
get "/letters/:id", to: "public/letters#show", as: :public_letter
|
||||
get "/packages/:id", to: "public/packages#show", as: :public_package
|
||||
|
||||
get "/impersonate", to: "public/impersonations#new", as: :public_impersonate_form
|
||||
post "/impersonate", to: "public/impersonations#create", as: :public_impersonate
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue