Buckets:
| 'use client'; | |
| import { useState } from 'react'; | |
| import { Wallet } from 'lucide-react'; | |
| import { apiClient } from '@/utils/api'; | |
| import usePollLoop from '@/hooks/usePollLoop'; | |
| interface BalanceResponse { | |
| enabled: boolean; | |
| appUrl?: string; | |
| balance?: { | |
| units: string; | |
| usd: number; | |
| } | null; | |
| error?: string; | |
| } | |
| export default function OstrisCloudBalance() { | |
| const [data, setData] = useState<BalanceResponse | null>(null); | |
| usePollLoop(async () => { | |
| try { | |
| const res = await apiClient.get<BalanceResponse>('/api/ostris_cloud'); | |
| setData(res.data); | |
| } catch { | |
| // ignore — keep last known value | |
| } | |
| }, 60_000); | |
| if (!data || !data.enabled || !data.appUrl) return null; | |
| const usd = data.balance?.usd; | |
| const hasAmount = typeof usd === 'number'; | |
| const display = hasAmount | |
| ? usd.toLocaleString(undefined, { | |
| style: 'currency', | |
| currency: 'USD', | |
| minimumFractionDigits: 2, | |
| maximumFractionDigits: 2, | |
| }) | |
| : null; | |
| return ( | |
| <a | |
| href={`${data.appUrl}/billing`} | |
| target="_blank" | |
| rel="noreferrer" | |
| className="block px-4 py-2 hover:bg-gray-800 transition-colors" | |
| > | |
| <div className="flex items-center justify-between"> | |
| <div className="flex items-center gap-2"> | |
| <Wallet className="w-4 h-4 text-blue-400" /> | |
| <span className="text-[11px] uppercase tracking-wide text-gray-400"> | |
| <span className="font-extrabold">Ostris</span> <span className="font-thin">Cloud</span> | |
| </span> | |
| </div> | |
| {display ? ( | |
| <span className="text-xs font-medium text-gray-100 tabular-nums">{display}</span> | |
| ) : ( | |
| <span className="inline-block h-3 w-10 rounded bg-gray-700 animate-pulse" aria-label="Loading balance" /> | |
| )} | |
| </div> | |
| </a> | |
| ); | |
| } | |
Xet Storage Details
- Size:
- 1.84 kB
- Xet hash:
- 3a6d60d459ebd7a8e504441732857ed2957f9d55a978d435d0f4d1b5af050d32
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.