diff --git a/app/console/page.tsx b/app/console/page.tsx index f394bf9..b87154d 100644 --- a/app/console/page.tsx +++ b/app/console/page.tsx @@ -26,10 +26,8 @@ async function toDelegation (car: Blob): Promise { export default function Console () { const agent = useAgent() const agentDID = agent?.did() - const [delegations, setDelegations] = useState[]>([]) - if (agent) { - setDelegations(agent.proofs()) - } + const [storedDelegations, setDelegations] = useState[]>([]) + const delegations = storedDelegations ?? agent?.proofs() const [configuredServiceSigner, setConfiguredServiceSigner] = useState() const [expiry, setExpiry] = useState(30) const { servicePrincipal } = useContext(ServiceContext) @@ -48,6 +46,7 @@ export default function Console () { { with: servicePrincipal.did(), can: 'subscription/get' }, { with: servicePrincipal.did(), can: 'rate-limit/*' }, { with: servicePrincipal.did(), can: 'admin/*' }, + { with: 'ucan:*', can: 'account/usage/get' }, ], expiration: Math.floor(Date.now() / 1000) + (60 * expiry) }) @@ -92,7 +91,10 @@ export default function Console () { { with: '${servicePrincipal?.did()}', can: 'consumer/get' }, { with: '${servicePrincipal?.did()}', can: 'subscription/get' }, { with: '${servicePrincipal?.did()}', can: 'rate-limit/*' }, + { with: '${servicePrincipal?.did()}', can: 'admin/*' }, + { with: 'ucan:*', can: 'account/usage/get' }, ]` + return (
{ diff --git a/app/customers/[did]/page.tsx b/app/customers/[did]/page.tsx index 14a12f2..529170a 100644 --- a/app/customers/[did]/page.tsx +++ b/app/customers/[did]/page.tsx @@ -4,7 +4,7 @@ import Link from "next/link"; import { notFound } from "next/navigation"; import * as DidMailto from "@storacha/did-mailto"; -import { useCustomer } from "@/hooks/customer"; +import { useCustomer, useCustomerUsage } from "@/hooks/customer"; import { useRateLimitActions } from "@/hooks/rate-limit"; import { SimpleError } from "@/components/error"; import { Loader } from "@/components/brand"; @@ -33,6 +33,7 @@ export default function Customer(props: { params: Promise<{ did: string }> }) { console.log(did) const { data: customer, error, isLoading } = useCustomer(did); + const {data: usage} = useCustomerUsage(did) const { addBlock: addEmailBlock, removeBlock: removeEmailBlock, @@ -105,6 +106,27 @@ export default function Customer(props: { params: Promise<{ did: string }> }) { ))} +

Usage

+

{usage?.total} bytes

+ + + {Object.entries(usage?.spaces || {}).map(([did, storage]) => ( + + + + + ))} + +
+ {did} + + + {storage.total}bytes + +
)} diff --git a/app/layout.tsx b/app/layout.tsx index b3cff76..ee9121f 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -22,7 +22,7 @@ export default function RootLayout({ - +