11import { Billing } from "@opencode-ai/console-core/billing.js"
22import { query , action , useParams , createAsync , useAction } from "@solidjs/router"
3- import { For , Show } from "solid-js"
3+ import { For , Match , Show , Switch } from "solid-js"
44import { withActor } from "~/context/auth.withActor"
55import { formatDateUTC , formatDateForTable } from "../../common"
66import styles from "./payment-section.module.css"
@@ -77,21 +77,23 @@ export function PaymentSection() {
7777 < For each = { payments ( ) ! } >
7878 { ( payment ) => {
7979 const date = new Date ( payment . timeCreated )
80- const isCredit = ! payment . paymentID
80+ const amount =
81+ payment . enrichment ?. type === "subscription" && payment . enrichment . couponID ? 0 : payment . amount
8182 return (
8283 < tr >
8384 < td data-slot = "payment-date" title = { formatDateUTC ( date ) } >
8485 { formatDateForTable ( date ) }
8586 </ td >
8687 < td data-slot = "payment-id" > { payment . id } </ td >
8788 < td data-slot = "payment-amount" data-refunded = { ! ! payment . timeRefunded } >
88- ${ ( ( payment . amount ?? 0 ) / 100000000 ) . toFixed ( 2 ) }
89- { isCredit ? " (credit)" : "" }
89+ ${ ( ( amount ?? 0 ) / 100000000 ) . toFixed ( 2 ) }
90+ < Switch >
91+ < Match when = { payment . enrichment ?. type === "credit" } > (credit)</ Match >
92+ < Match when = { payment . enrichment ?. type === "subscription" } > (subscription)</ Match >
93+ </ Switch >
9094 </ td >
9195 < td data-slot = "payment-receipt" >
92- { isCredit ? (
93- < span > -</ span >
94- ) : (
96+ { payment . paymentID ? (
9597 < button
9698 onClick = { async ( ) => {
9799 const receiptUrl = await downloadReceiptAction ( params . id ! , payment . paymentID ! )
@@ -103,6 +105,8 @@ export function PaymentSection() {
103105 >
104106 View
105107 </ button >
108+ ) : (
109+ < span > -</ span >
106110 ) }
107111 </ td >
108112 </ tr >
0 commit comments