Add views and navigation for HCB payment accounts

- Payment accounts index, new, show views
- Add HCB payment link to settings navigation
This commit is contained in:
24c02 2025-12-18 14:49:45 -05:00
parent b860c9d112
commit faa2c4644c
4 changed files with 92 additions and 2 deletions

View file

@ -0,0 +1,46 @@
<% content_for :title do %>
HCB Payment Accounts
<% end %>
<h1>HCB Payment Accounts</h1>
<% if current_user.hcb_connected? %>
<div class="notice success">
✓ HCB account linked
<%= link_to "Unlink", hcb_oauth_connection_path, method: :delete, data: { confirm: "Are you sure? This will remove all payment accounts." }, class: "btn btn-small danger" %>
</div>
<div class="actions">
<%= link_to "Add Payment Account", new_hcb_payment_account_path, class: "btn success btn-small" %>
</div>
<% if @payment_accounts.any? %>
<table>
<thead>
<tr>
<th>Organization</th>
<th>Created</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @payment_accounts.each do |account| %>
<tr>
<td><%= account.organization_name %></td>
<td><%= account.created_at.strftime("%Y-%m-%d") %></td>
<td>
<%= link_to "Remove", hcb_payment_account_path(account), method: :delete, data: { confirm: "Remove this payment account?" }, class: "btn btn-small danger" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p>No payment accounts yet. Add one to start paying for postage.</p>
<% end %>
<% else %>
<div class="notice">
<p>Link your HCB account to pay for postage from your organization.</p>
<%= link_to "Link HCB Account", new_hcb_oauth_connection_path, class: "btn success" %>
</div>
<% end %>

View file

@ -0,0 +1,23 @@
<% content_for :title do %>
Add HCB Payment Account
<% end %>
<h1>Add HCB Payment Account</h1>
<p>Select an organization to use for paying postage:</p>
<%= form_with url: hcb_payment_accounts_path, method: :post do |f| %>
<fieldset>
<%= f.label :organization_id, "Organization" %>
<%= f.select :organization_id, @organizations.map { |org| [org.name, org.id] }, { prompt: "Select an organization..." } %>
</fieldset>
<%= f.submit "Add Payment Account", class: "btn success btn-small" %>
<%= link_to "Cancel", hcb_payment_accounts_path, class: "btn btn-small" %>
<% end %>
<% if @organizations.empty? %>
<div class="notice warning">
<p>No organizations found. Make sure you have admin access to at least one HCB organization.</p>
</div>
<% end %>

View file

@ -0,0 +1,18 @@
<% content_for :title do %>
<%= @payment_account.organization_name %> - HCB Payment Account
<% end %>
<h1><%= @payment_account.organization_name %></h1>
<dl>
<dt>Organization ID</dt>
<dd><code><%= @payment_account.organization_id %></code></dd>
<dt>Created</dt>
<dd><%= @payment_account.created_at.strftime("%Y-%m-%d %H:%M") %></dd>
</dl>
<div class="actions">
<%= link_to "Back to Payment Accounts", hcb_payment_accounts_path, class: "btn btn-small" %>
<%= link_to "Remove", hcb_payment_account_path(@payment_account), method: :delete, data: { confirm: "Remove this payment account?" }, class: "btn btn-small danger" %>
</div>

View file

@ -68,9 +68,12 @@
</details>
</li>
<li>
<details <%= 'open' if [settings_qz_tray_path].include? request.path %>>
<details <%= 'open' if [settings_qz_tray_path].include?(request.path) || request.path.start_with?('/back_office/hcb') %>>
<summary>Settings</summary>
<%= nav_item settings_qz_tray_path, "print settings" %>
<ul>
<%= nav_item settings_qz_tray_path, "print settings" %>
<%= nav_item hcb_payment_accounts_path, "HCB payment" %>
</ul>
</details>
</li>
<% admin_tool do %>