mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-25 08:09:38 +02:00
Add conditional rendering for account links in transfers view
- Implemented checks for the existence of accounts before rendering links in the transfers partial. - Added error messaging for missing accounts to improve user feedback and prevent broken links.
This commit is contained in:
parent
aebbb9a3c1
commit
0946a1497a
1 changed files with 20 additions and 2 deletions
|
@ -1,7 +1,25 @@
|
|||
<%# locals: (transfer:, is_inflow: false) %>
|
||||
<div class="flex items-center gap-1">
|
||||
<% first_account, second_account = is_inflow ? [transfer.to_account, transfer.from_account] : [transfer.from_account, transfer.to_account] %>
|
||||
<%= link_to first_account.name, account_path(first_account, tab: "activity"), class: "hover:underline", data: { turbo_frame: "_top" } %>
|
||||
|
||||
<%# Check if first_account exists before creating link %>
|
||||
<% if first_account %>
|
||||
<%= link_to first_account.name, account_path(first_account, tab: "activity"), class: "hover:underline", data: { turbo_frame: "_top" } %>
|
||||
<% else %>
|
||||
<span class="text-warning text-xs italic" title="Transfer ID: <%= transfer.id %>">
|
||||
Data Error: Missing account
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<%# Use icon helper per conventions %>
|
||||
<%= icon(is_inflow ? "arrow-left" : "arrow-right", size: "sm") %>
|
||||
<%= link_to second_account.name, account_path(second_account, tab: "activity"), class: "hover:underline", data: { turbo_frame: "_top" } %>
|
||||
|
||||
<%# Check if second_account exists before creating link %>
|
||||
<% if second_account %>
|
||||
<%= link_to second_account.name, account_path(second_account, tab: "activity"), class: "hover:underline", data: { turbo_frame: "_top" } %>
|
||||
<% else %>
|
||||
<span class="text-warning text-xs italic" title="Transfer ID: <%= transfer.id %>">
|
||||
Data Error: Missing account
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue