Skip to content

Commit 062519a

Browse files
authored
Add "Show more" link to browse more than 12 invoices (plausible#4211)
* Allow browsing more than 12 invoices * Remove paddle/get_invoices limit
1 parent 9f1f826 commit 062519a

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/plausible/billing/paddle_api.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ defmodule Plausible.Billing.PaddleApi do
108108
Enum.sort(response, fn %{"payout_date" => d1}, %{"payout_date" => d2} ->
109109
Date.compare(Date.from_iso8601!(d1), Date.from_iso8601!(d2)) == :gt
110110
end)
111-
|> Enum.take(12)
112111
|> then(&{:ok, &1})
113112
else
114113
error ->

lib/plausible_web/templates/auth/user_settings.html.heex

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@
121121
</p>
122122
</div>
123123
<% {:ok, invoice_list} when is_list(invoice_list) -> %>
124-
<div class="max-w-2xl px-8 pt-6 pb-8 mx-auto mt-16 bg-white border-t-2 border-orange-200 rounded rounded-t-none shadow-md dark:bg-gray-800">
124+
<div
125+
class="max-w-2xl px-8 pt-6 pb-8 mx-auto mt-16 bg-white border-t-2 border-orange-200 rounded rounded-t-none shadow-md dark:bg-gray-800"
126+
x-data="{showAll: false}"
127+
>
125128
<h2 class="text-xl font-black dark:text-gray-100">Invoices</h2>
126129
<div class="my-4 border-b border-gray-300 dark:border-gray-500"></div>
127130
<table class="min-w-full divide-y divide-gray-200">
@@ -147,9 +150,9 @@
147150
</th>
148151
</tr>
149152
</thead>
150-
<%= for invoice <- format_invoices(invoice_list) do %>
151-
<tbody class="divide-y divide-gray-200">
152-
<tr>
153+
<%= for {invoice, idx} <- Enum.with_index(format_invoices(invoice_list)) do %>
154+
<tbody class={["divide-y divide-gray-200"]}>
155+
<tr x-show={"showAll || #{idx} < 12"}>
153156
<td class="py-4 text-sm text-gray-800 dark:text-gray-200 font-medium">
154157
<%= invoice.date %>
155158
</td>
@@ -160,6 +163,17 @@
160163
<%= link("Link", to: invoice.url, target: "_blank") %>
161164
</td>
162165
</tr>
166+
<tr :if={idx == 12 && length(invoice_list) > 12} x-show="!showAll">
167+
<td colspan="3" class="text-center">
168+
<button
169+
x-on:click="showAll = true"
170+
x-show="!showAll"
171+
class="mt-4 text-indigo-500 hover:text-indigo-600"
172+
>
173+
Show More
174+
</button>
175+
</td>
176+
</tr>
163177
</tbody>
164178
<% end %>
165179
</table>

0 commit comments

Comments
 (0)