This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
forked from getAlby/nostr-wallet-connect
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into task-payment-sent
- Loading branch information
Showing
13 changed files
with
214 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import dayjs from "dayjs"; | ||
import relativeTime from "dayjs/plugin/relativeTime"; | ||
import { Link } from "react-router-dom"; | ||
import AppAvatar from "src/components/AppAvatar"; | ||
import { AppCardConnectionInfo } from "src/components/connections/AppCardConnectionInfo"; | ||
import { AppCardNotice } from "src/components/connections/AppCardNotice"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardHeader, | ||
CardTitle, | ||
} from "src/components/ui/card"; | ||
import { App } from "src/types"; | ||
|
||
dayjs.extend(relativeTime); | ||
|
||
type Props = { | ||
app: App; | ||
csrf?: string; | ||
}; | ||
|
||
export default function AppCard({ app }: Props) { | ||
return ( | ||
<> | ||
<Link className="h-full" to={`/apps/${app.nostrPubkey}`}> | ||
<Card className="h-full flex flex-col group"> | ||
<CardHeader> | ||
<CardTitle className="relative"> | ||
<AppCardNotice app={app} /> | ||
<div className="flex flex-row items-center"> | ||
<AppAvatar className="w-10 h-10" appName={app.name} /> | ||
<div className="flex-1 font-semibold text-xl whitespace-nowrap text-ellipsis overflow-hidden ml-4"> | ||
{app.name} | ||
</div> | ||
</div> | ||
</CardTitle> | ||
</CardHeader> | ||
<CardContent className="flex-1 flex flex-col"> | ||
<AppCardConnectionInfo connection={app} /> | ||
</CardContent> | ||
</Card> | ||
</Link> | ||
</> | ||
); | ||
} |
59 changes: 59 additions & 0 deletions
59
frontend/src/components/connections/AppCardConnectionInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import dayjs from "dayjs"; | ||
import { Progress } from "src/components/ui/progress"; | ||
import { formatAmount } from "src/lib/utils"; | ||
import { App } from "src/types"; | ||
|
||
type AppCardConnectionInfoProps = { | ||
connection: App; | ||
}; | ||
|
||
export function AppCardConnectionInfo({ | ||
connection, | ||
}: AppCardConnectionInfoProps) { | ||
return ( | ||
<> | ||
{connection.maxAmount > 0 && ( | ||
<> | ||
<div className="flex flex-row justify-between"> | ||
<div className="mb-2"> | ||
<p className="text-xs text-secondary-foreground font-medium"> | ||
Left in budget | ||
</p> | ||
<p className="text-xl font-medium"> | ||
{new Intl.NumberFormat().format( | ||
connection.maxAmount - connection.budgetUsage | ||
)}{" "} | ||
sats | ||
</p> | ||
</div> | ||
</div> | ||
<Progress | ||
className="h-4" | ||
value={(connection.budgetUsage * 100) / connection.maxAmount} | ||
/> | ||
<div className="flex flex-row justify-between text-xs items-center text-muted-foreground mt-2"> | ||
<div> | ||
{connection.maxAmount && ( | ||
<>{formatAmount(connection.maxAmount * 1000)} sats</> | ||
)} | ||
</div> | ||
<div> | ||
{connection.maxAmount > 0 && | ||
connection.budgetRenewal !== "never" && ( | ||
<>Renews {connection.budgetRenewal}</> | ||
)} | ||
</div> | ||
</div> | ||
{connection.lastEventAt && ( | ||
<div className="flex flex-row justify-between text-xs items-center text-muted-foreground"> | ||
<div className="flex flex-row justify-between"> | ||
<div>Last used: </div> | ||
<div>{dayjs(connection.lastEventAt).fromNow()}</div> | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
)} | ||
</> | ||
); | ||
} |
Oops, something went wrong.