|
20 | 20 | </div> |
21 | 21 | </div> |
22 | 22 |
|
23 | | - <%= admin_show_attributes( |
24 | | - @student, |
25 | | - attributes: %i[id username classroom created_at updated_at] |
26 | | - ) %> |
| 23 | + <div class="bg-white shadow-sm ring-1 ring-gray-900/5 rounded-lg overflow-hidden"> |
| 24 | + <div class="px-4 py-5 sm:px-6"> |
| 25 | + <dl class="divide-y divide-gray-200"> |
| 26 | + <div class="py-4 sm:grid sm:grid-cols-3 sm:gap-4"> |
| 27 | + <dt class="text-sm font-medium text-gray-500">Id</dt> |
| 28 | + <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"><%= @student.id %></dd> |
| 29 | + </div> |
| 30 | + <div class="py-4 sm:grid sm:grid-cols-3 sm:gap-4"> |
| 31 | + <dt class="text-sm font-medium text-gray-500">Username</dt> |
| 32 | + <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"><%= @student.username %></dd> |
| 33 | + </div> |
| 34 | + <div class="py-4 sm:grid sm:grid-cols-3 sm:gap-4"> |
| 35 | + <dt class="text-sm font-medium text-gray-500">Classroom</dt> |
| 36 | + <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"><%= @student.classroom.name %></dd> |
| 37 | + </div> |
| 38 | + <div class="py-4 sm:grid sm:grid-cols-3 sm:gap-4"> |
| 39 | + <dt class="text-sm font-medium text-gray-500">Created at</dt> |
| 40 | + <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"><%= @student.created_at.strftime("%B %d, %Y") %></dd> |
| 41 | + </div> |
| 42 | + <div class="py-4 sm:grid sm:grid-cols-3 sm:gap-4"> |
| 43 | + <dt class="text-sm font-medium text-gray-500">Updated at</dt> |
| 44 | + <dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0"><%= @student.updated_at.strftime("%B %d, %Y") %></dd> |
| 45 | + </div> |
| 46 | + </dl> |
| 47 | + </div> |
| 48 | + </div> |
27 | 49 |
|
28 | 50 | <!-- Associated Portfolio --> |
29 | 51 | <% if @student.portfolio.present? %> |
30 | 52 | <div class="mt-6 pt-6 border-t border-gray-200"> |
31 | | - <h3 class="text-sm font-medium text-gray-500 mb-3">Portfolio</h3> |
32 | | - <div class="text-sm text-gray-900"> |
33 | | - Portfolio ID: <%= @student.portfolio.id %> |
34 | | - <%= link_to "View Portfolio", user_portfolio_path(@student, @student.portfolio), class: "ml-2 text-blue-600 hover:text-blue-800" %> |
| 53 | + <h3 class="text-sm font-medium text-gray-500 mb-3">Portfolio Details</h3> |
| 54 | + <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6"> |
| 55 | + <div class="bg-blue-50 p-4 rounded-lg"> |
| 56 | + <div class="text-xs font-medium text-blue-600 mb-1">Cash Balance</div> |
| 57 | + <div class="text-2xl font-bold text-blue-900"><%= number_to_currency(@student.portfolio.cash_balance) %></div> |
| 58 | + </div> |
| 59 | + <div class="bg-green-50 p-4 rounded-lg"> |
| 60 | + <div class="text-xs font-medium text-green-600 mb-1">Total Portfolio Worth</div> |
| 61 | + <div class="text-2xl font-bold text-green-900"><%= number_to_currency(@student.portfolio.total_portfolio_worth) %></div> |
| 62 | + </div> |
| 63 | + <div class="bg-gray-50 p-4 rounded-lg"> |
| 64 | + <div class="text-xs font-medium text-gray-600 mb-1">Portfolio ID</div> |
| 65 | + <div class="text-2xl font-bold text-gray-900">#<%= @student.portfolio.id %></div> |
| 66 | + </div> |
35 | 67 | </div> |
| 68 | + |
| 69 | + <!-- Transactions --> |
| 70 | + <% transactions = @student.portfolio.portfolio_transactions.order(created_at: :desc) %> |
| 71 | + <% if transactions.any? %> |
| 72 | + <h4 class="text-sm font-medium text-gray-700 mb-3">All Transactions (<%= transactions.count %>)</h4> |
| 73 | + <div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 rounded-lg mb-4"> |
| 74 | + <table class="min-w-full divide-y divide-gray-300"> |
| 75 | + <thead class="bg-gray-50"> |
| 76 | + <tr> |
| 77 | + <th class="px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase">Date</th> |
| 78 | + <th class="px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase">Type</th> |
| 79 | + <th class="px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase">Reason</th> |
| 80 | + <th class="px-3 py-3 text-right text-xs font-medium text-gray-500 uppercase">Amount</th> |
| 81 | + </tr> |
| 82 | + </thead> |
| 83 | + <tbody class="divide-y divide-gray-200 bg-white"> |
| 84 | + <% transactions.each do |transaction| %> |
| 85 | + <tr> |
| 86 | + <td class="whitespace-nowrap px-3 py-2 text-sm text-gray-900"> |
| 87 | + <%= transaction.created_at.strftime("%m/%d/%Y") %> |
| 88 | + </td> |
| 89 | + <td class="whitespace-nowrap px-3 py-2 text-sm"> |
| 90 | + <span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium <%= transaction.transaction_type == 'deposit' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800' %>"> |
| 91 | + <%= transaction.transaction_type.capitalize %> |
| 92 | + </span> |
| 93 | + </td> |
| 94 | + <td class="px-3 py-2 text-sm text-gray-900"> |
| 95 | + <%= transaction.reason&.humanize || 'N/A' %> |
| 96 | + </td> |
| 97 | + <td class="whitespace-nowrap px-3 py-2 text-sm text-right font-medium text-gray-900"> |
| 98 | + <%= number_to_currency(transaction.amount_cents / 100.0) %> |
| 99 | + </td> |
| 100 | + </tr> |
| 101 | + <% end %> |
| 102 | + </tbody> |
| 103 | + </table> |
| 104 | + </div> |
| 105 | + <% else %> |
| 106 | + <p class="text-sm text-gray-500 mb-4">No transactions yet.</p> |
| 107 | + <% end %> |
36 | 108 | </div> |
37 | 109 | <% else %> |
38 | 110 | <div class="mt-6 pt-6 border-t border-gray-200"> |
|
0 commit comments