Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions apps/browser-extension/src/components/LightningTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {
Autocomplete,
Box,
Button,
Checkbox,
CircularProgress,
FormControlLabel,
Tab,
Tabs,
TextField,
Expand Down Expand Up @@ -52,6 +54,7 @@ const LightningTab: React.FC = () => {
// Payments sub-tab
const [payments, setPayments] = useState<LightningPaymentRecord[]>([]);
const [loadingPayments, setLoadingPayments] = useState<boolean>(false);
const [statusFilter, setStatusFilter] = useState({ settled: true, pending: true, failed: true, expired: true });

// Publish state
const [isPublished, setIsPublished] = useState<boolean>(false);
Expand Down Expand Up @@ -311,33 +314,57 @@ const LightningTab: React.FC = () => {

{activeTab === "payments" && (
<Box sx={{ p: 1 }}>
<Box sx={{ display: "flex", gap: 1, mb: 2 }}>
<Box sx={{ display: "flex", alignItems: "center", gap: 2, mb: 2, flexWrap: "wrap" }}>
<Button variant="outlined" onClick={fetchPayments} disabled={loadingPayments}>
Refresh
</Button>
{(['settled', 'pending', 'failed', 'expired'] as const).map(s => (
<FormControlLabel key={s} label={s} sx={{ mr: 0 }}
control={<Checkbox size="small" checked={statusFilter[s]}
onChange={e => setStatusFilter(f => ({ ...f, [s]: e.target.checked }))} />} />
))}
</Box>
{loadingPayments && <CircularProgress size={24} />}
{!loadingPayments && payments.length === 0 && (
<Typography>No payments found.</Typography>
)}
{!loadingPayments && payments.length > 0 && (
<Box component="table" sx={{ width: "100%", borderCollapse: "collapse", "& th, & td": { p: 0.75, textAlign: "left", borderBottom: "1px solid", borderColor: "divider" }, "& th": { fontWeight: "bold" } }}>
<Box component="table" sx={{ width: "100%", borderCollapse: "collapse", tableLayout: "fixed", "& th, & td": { p: 0.75, borderBottom: "1px solid", borderColor: "divider", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, "& th": { fontWeight: "bold", textAlign: "left" }, "& td.num": { textAlign: "right" } }}>
<colgroup>
<col style={{ width: "190px" }} />
<col style={{ width: "120px" }} />
<col style={{ width: "60px" }} />
<col style={{ width: "80px" }} />
<col />
</colgroup>
<thead>
<tr>
<th>Date</th>
<th>Amount</th>
<th style={{ textAlign: "right" }}>Amount (sats)</th>
<th style={{ textAlign: "right" }}>Fee</th>
<th>Status</th>
<th>Memo</th>
</tr>
</thead>
<tbody>
{payments.map((p, i) => {
const d = p.time ? new Date(p.time) : null;
const date = d ? `${d.getFullYear()}/${String(d.getMonth() + 1).padStart(2, "0")}/${String(d.getDate()).padStart(2, "0")} ${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}:${String(d.getSeconds()).padStart(2, "0")}` : "—";
const displayStatus: 'settled' | 'pending' | 'failed' | 'expired' = p.status === 'success' ? 'settled'
: p.status === 'failed' ? 'failed'
: (p.expiry && new Date(p.expiry) < new Date()) ? 'expired'
: 'pending';
Comment thread
macterra marked this conversation as resolved.
if (!statusFilter[displayStatus]) return null;
const statusColor = displayStatus === 'settled' ? 'inherit'
: displayStatus === 'failed' ? 'error.main'
: 'text.secondary';
return (
<tr key={i}>
<td>{date}</td>
<td>{p.amount} sats{p.fee > 0 ? ` (fee: ${p.fee})` : ""}</td>
<td>{p.memo || "—"}{p.pending ? " [pending]" : ""}</td>
<td className="num">{p.amount}</td>
<td className="num">{p.fee > 0 ? p.fee : ""}</td>
<td><Box component="span" sx={{ color: statusColor }}>{displayStatus}</Box></td>
<td>{p.memo || "—"}</td>
</tr>
);
})}
Expand Down
42 changes: 34 additions & 8 deletions apps/gatekeeper-client/src/KeymasterUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ function KeymasterUI({ keymaster, title, challengeDID, onWalletUpload, hasLightn
const [zapResult, setZapResult] = useState(null);
const [lightningPayments, setLightningPayments] = useState([]);
const [loadingPayments, setLoadingPayments] = useState(false);
const [lightningStatusFilter, setLightningStatusFilter] = useState({ settled: true, pending: true, failed: true, expired: true });
const [isPublished, setIsPublished] = useState(false);
const [loadingPublishToggle, setLoadingPublishToggle] = useState(false);

Expand Down Expand Up @@ -6283,33 +6284,58 @@ function KeymasterUI({ keymaster, title, challengeDID, onWalletUpload, hasLightn

{lightningTab === 'payments' &&
<Box sx={{ mt: 2 }}>
<Button variant="outlined" onClick={fetchLightningPayments} disabled={loadingPayments}>
Refresh
</Button>
<p />
<Box sx={{ display: "flex", alignItems: "center", gap: 2, mb: 2, flexWrap: "wrap" }}>
<Button variant="outlined" onClick={fetchLightningPayments} disabled={loadingPayments}>
Refresh
</Button>
{['settled', 'pending', 'failed', 'expired'].map(s => (
<FormControlLabel key={s} label={s} sx={{ mr: 0 }}
control={<Checkbox size="small" checked={lightningStatusFilter[s]}
onChange={e => setLightningStatusFilter(f => ({ ...f, [s]: e.target.checked }))} />} />
))}
</Box>
{loadingPayments && <Typography>Loading...</Typography>}
{!loadingPayments && lightningPayments.length === 0 &&
<Typography>No payments found.</Typography>
}
{!loadingPayments && lightningPayments.length > 0 &&
<TableContainer component={Paper}>
<Table size="small">
<Table size="small" sx={{ tableLayout: "fixed" }}>
<colgroup>
<col style={{ width: "190px" }} />
<col style={{ width: "120px" }} />
<col style={{ width: "60px" }} />
<col style={{ width: "80px" }} />
<col />
</colgroup>
<TableHead>
<TableRow>
<TableCell>Date</TableCell>
<TableCell>Amount</TableCell>
<TableCell align="right">Amount (sats)</TableCell>
<TableCell align="right">Fee</TableCell>
<TableCell>Status</TableCell>
<TableCell>Memo</TableCell>
</TableRow>
</TableHead>
<TableBody>
{lightningPayments.map((p, i) => {
const d = p.time ? new Date(p.time) : null;
const date = d ? `${d.getFullYear()}/${String(d.getMonth() + 1).padStart(2, '0')}/${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}:${String(d.getSeconds()).padStart(2, '0')}` : '—';
const displayStatus = p.status === 'success' ? 'settled'
: p.status === 'failed' ? 'failed'
: (p.expiry && new Date(p.expiry) < new Date()) ? 'expired'
: 'pending';
Comment thread
macterra marked this conversation as resolved.
if (!lightningStatusFilter[displayStatus]) return null;
const statusColor = displayStatus === 'settled' ? 'inherit'
: displayStatus === 'failed' ? 'error.main'
: 'text.secondary';
return (
<TableRow key={i}>
<TableCell>{date}</TableCell>
<TableCell>{p.amount} sats{p.fee > 0 ? ` (fee: ${p.fee})` : ''}</TableCell>
<TableCell>{p.memo || '—'}{p.pending ? ' [pending]' : ''}</TableCell>
<TableCell align="right">{p.amount}</TableCell>
<TableCell align="right">{p.fee > 0 ? p.fee : ''}</TableCell>
<TableCell><Box component="span" sx={{ color: statusColor }}>{displayStatus}</Box></TableCell>
<TableCell>{p.memo || '—'}</TableCell>
</TableRow>
);
})}
Expand Down
42 changes: 34 additions & 8 deletions apps/keymaster-client/src/KeymasterUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ function KeymasterUI({ keymaster, title, challengeDID, onWalletUpload, hasLightn
const [zapResult, setZapResult] = useState(null);
const [lightningPayments, setLightningPayments] = useState([]);
const [loadingPayments, setLoadingPayments] = useState(false);
const [lightningStatusFilter, setLightningStatusFilter] = useState({ settled: true, pending: true, failed: true, expired: true });
const [isPublished, setIsPublished] = useState(false);
const [loadingPublishToggle, setLoadingPublishToggle] = useState(false);

Expand Down Expand Up @@ -6283,33 +6284,58 @@ function KeymasterUI({ keymaster, title, challengeDID, onWalletUpload, hasLightn

{lightningTab === 'payments' &&
<Box sx={{ mt: 2 }}>
<Button variant="outlined" onClick={fetchLightningPayments} disabled={loadingPayments}>
Refresh
</Button>
<p />
<Box sx={{ display: "flex", alignItems: "center", gap: 2, mb: 2, flexWrap: "wrap" }}>
<Button variant="outlined" onClick={fetchLightningPayments} disabled={loadingPayments}>
Refresh
</Button>
{['settled', 'pending', 'failed', 'expired'].map(s => (
<FormControlLabel key={s} label={s} sx={{ mr: 0 }}
control={<Checkbox size="small" checked={lightningStatusFilter[s]}
onChange={e => setLightningStatusFilter(f => ({ ...f, [s]: e.target.checked }))} />} />
))}
</Box>
{loadingPayments && <Typography>Loading...</Typography>}
{!loadingPayments && lightningPayments.length === 0 &&
<Typography>No payments found.</Typography>
}
{!loadingPayments && lightningPayments.length > 0 &&
<TableContainer component={Paper}>
<Table size="small">
<Table size="small" sx={{ tableLayout: "fixed" }}>
<colgroup>
<col style={{ width: "190px" }} />
<col style={{ width: "120px" }} />
<col style={{ width: "60px" }} />
<col style={{ width: "80px" }} />
<col />
</colgroup>
<TableHead>
<TableRow>
<TableCell>Date</TableCell>
<TableCell>Amount</TableCell>
<TableCell align="right">Amount (sats)</TableCell>
<TableCell align="right">Fee</TableCell>
<TableCell>Status</TableCell>
<TableCell>Memo</TableCell>
</TableRow>
</TableHead>
<TableBody>
{lightningPayments.map((p, i) => {
const d = p.time ? new Date(p.time) : null;
const date = d ? `${d.getFullYear()}/${String(d.getMonth() + 1).padStart(2, '0')}/${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}:${String(d.getSeconds()).padStart(2, '0')}` : '—';
const displayStatus = p.status === 'success' ? 'settled'
: p.status === 'failed' ? 'failed'
: (p.expiry && new Date(p.expiry) < new Date()) ? 'expired'
: 'pending';
Comment thread
macterra marked this conversation as resolved.
if (!lightningStatusFilter[displayStatus]) return null;
const statusColor = displayStatus === 'settled' ? 'inherit'
: displayStatus === 'failed' ? 'error.main'
: 'text.secondary';
return (
<TableRow key={i}>
<TableCell>{date}</TableCell>
<TableCell>{p.amount} sats{p.fee > 0 ? ` (fee: ${p.fee})` : ''}</TableCell>
<TableCell>{p.memo || '—'}{p.pending ? ' [pending]' : ''}</TableCell>
<TableCell align="right">{p.amount}</TableCell>
<TableCell align="right">{p.fee > 0 ? p.fee : ''}</TableCell>
<TableCell><Box component="span" sx={{ color: statusColor }}>{displayStatus}</Box></TableCell>
<TableCell>{p.memo || '—'}</TableCell>
</TableRow>
);
})}
Expand Down
Loading
Loading