Skip to content

Commit a59772f

Browse files
committed
Tabs on Billing
1 parent 983a3fc commit a59772f

3 files changed

Lines changed: 37 additions & 10 deletions

File tree

public/assets/css/site.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,19 +1590,19 @@ input[type="file"]::-webkit-file-upload-button:hover {
15901590

15911591
.site-header .content-inner,
15921592
.site-footer .content-inner {
1593-
flex-direction: column;
1594-
align-items: flex-start;
1593+
flex-direction: row;
1594+
align-items: center;
15951595
gap: 12px;
15961596
height: auto;
1597-
padding: 18px 0;
1597+
padding: 12px 0;
15981598
}
15991599

16001600
.nav {
1601-
width: 100%;
16021601
display: flex;
16031602
justify-content: flex-end;
16041603
gap: 12px;
16051604
padding-right: 8px;
1605+
margin-left: auto;
16061606
}
16071607

16081608
.nav a,

public/assets/js/ui.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,15 @@
641641
preferredTab = 'workspaces';
642642
}
643643

644+
const updateQuery = (tabName) => {
645+
if (!tabName) {
646+
return;
647+
}
648+
const url = new URL(window.location.href);
649+
url.searchParams.set('tab', tabName);
650+
window.history.replaceState({}, '', url.toString());
651+
};
652+
644653
containers.forEach((container) => {
645654
const buttons = Array.from(container.querySelectorAll('[data-tab-button]'));
646655
if (buttons.length === 0) {
@@ -673,7 +682,11 @@
673682
};
674683

675684
buttons.forEach((button) => {
676-
button.addEventListener('click', () => activate(button));
685+
button.addEventListener('click', () => {
686+
activate(button);
687+
const name = button.getAttribute('data-tab-button');
688+
updateQuery(name);
689+
});
677690
});
678691

679692
if (preferredTab) {

views/billing/index.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
</div>
1919
<?php else : ?>
2020
<div class="card">
21+
<div class="tabs" data-tabs>
22+
<button type="button" class="tab-button is-active" data-tab-button="current"
23+
aria-selected="true" aria-controls="tab-current">Current</button>
24+
<button type="button" class="tab-button" data-tab-button="history"
25+
aria-selected="false" aria-controls="tab-history">History</button>
26+
</div>
27+
<div class="tab-panels">
28+
<div class="tab-panel is-active" data-tab-panel="current" id="tab-current" role="tabpanel">
29+
<div class="card-muted">
2130
<h2>Current subscription</h2>
2231
<?php if (!empty($subscription)) : ?>
2332
<p><strong><?= e($subscription['plan_name'] ?? '') ?></strong> — <?= e(ucfirst((string)($subscription['status'] ?? ''))) ?></p>
@@ -35,14 +44,14 @@
3544
<?php endif; ?>
3645
</div>
3746

38-
<div class="card">
47+
<div class="card-muted">
3948
<h2>AI credit balance</h2>
4049
<p class="muted">Available credits for this workspace.</p>
4150
<p class="plan-price"><?= number_format((int)($workspace['ai_credit_balance'] ?? 0)) ?> credits</p>
4251
</div>
4352

4453
<?php if (!empty($pendingChanges)) : ?>
45-
<div class="card">
54+
<div class="card-muted">
4655
<h2>Pending changes</h2>
4756
<table class="table">
4857
<thead>
@@ -72,7 +81,7 @@
7281
</div>
7382
<?php endif; ?>
7483

75-
<div class="card">
84+
<div class="card-muted">
7685
<h2>Plans</h2>
7786
<?php if (empty($plans)) : ?>
7887
<p>No plans configured yet.</p>
@@ -186,7 +195,7 @@
186195
<?php endif; ?>
187196
</div>
188197

189-
<div class="card">
198+
<div class="card-muted">
190199
<h2>AI credit top-ups</h2>
191200
<p class="muted">Purchase extra AI actions as needed.</p>
192201
<?php if (empty($topupPlans)) : ?>
@@ -238,7 +247,9 @@
238247
<?php endif; ?>
239248
</div>
240249

241-
<div class="card">
250+
</div>
251+
<div class="tab-panel" data-tab-panel="history" id="tab-history" role="tabpanel" hidden>
252+
<div class="card-muted">
242253
<h2>Invoices</h2>
243254
<?php if (empty($invoices)) : ?>
244255
<p>No invoices yet.</p>
@@ -266,6 +277,9 @@
266277
</tbody>
267278
</table>
268279
<?php endif; ?>
280+
</div>
281+
</div>
282+
</div>
269283
</div>
270284

271285
<?php endif; ?>

0 commit comments

Comments
 (0)