import dayjs from "dayjs";
import { BrickWallIcon, CircleCheckIcon, PlusCircleIcon } from "lucide-react";
import { FormattedBitcoinAmount } from "src/components/FormattedBitcoinAmount";
import { LinkButton } from "src/components/ui/custom/link-button";
import { Progress } from "src/components/ui/progress";
import { SUBWALLET_APPSTORE_APP_ID } from "src/constants";
import { getBudgetRenewalLabel } from "src/lib/utils";
import { App } from "src/types";
type AppCardConnectionInfoProps = {
connection: App;
budgetRemainingText?: string | React.ReactNode;
readonly?: boolean;
};
export function AppCardConnectionInfo({
connection,
budgetRemainingText = "Left in budget",
readonly = false,
}: AppCardConnectionInfoProps) {
return (
<>
{connection.isolated ? (
<>
{connection.metadata?.app_store_app_id ===
SUBWALLET_APPSTORE_APP_ID
? "Sub-wallet"
: "Isolated App"}
Last used:{" "}
{connection.lastUsedAt
? dayjs(connection.lastUsedAt).fromNow()
: "Never"}
>
) : connection.maxAmountSat > 0 ? (
<>
Last used:{" "}
{connection.lastUsedAt
? dayjs(connection.lastUsedAt).fromNow()
: "Never"}
{connection.maxAmountSat && (
<>
{connection.budgetRenewal !== "never" && (
<> / {getBudgetRenewalLabel(connection.budgetRenewal)}>
)}
>
)}
>
) : connection.scopes.indexOf("pay_invoice") > -1 ? (
<>
Last used:{" "}
{connection.lastUsedAt
? dayjs(connection.lastUsedAt).fromNow()
: "Never"}
{!readonly && (
Set Budget
)}
>
) : (
<>
Share wallet information
{connection.scopes.indexOf("make_invoice") > -1 && (
Receive payments
)}
{connection.scopes.indexOf("list_transactions") > -1 && (
Read transaction history
)}
Last used:{" "}
{connection.lastUsedAt
? dayjs(connection.lastUsedAt).fromNow()
: "Never"}
{!readonly && (
Enable Payments
)}
>
)}
>
);
}