feat: history stream link

This commit is contained in:
kieran 2024-07-19 15:03:38 +01:00
parent 875a5b9ed9
commit e2cac2f55d
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
3 changed files with 32 additions and 11 deletions

View File

@ -1,6 +1,9 @@
import { BalanceHistoryResult, NostrStreamProvider } from "@/providers/zsz"; import { BalanceHistoryResult, NostrStreamProvider } from "@/providers/zsz";
import { eventLink } from "@/utils";
import { NostrEvent } from "@snort/system";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage, FormattedNumber } from "react-intl";
import { Link } from "react-router-dom";
export default function BalanceHistory({ provider }: { provider?: NostrStreamProvider }) { export default function BalanceHistory({ provider }: { provider?: NostrStreamProvider }) {
const [page] = useState(0); const [page] = useState(0);
@ -22,16 +25,30 @@ export default function BalanceHistory({ provider }: { provider?: NostrStreamPro
<div> <div>
<FormattedMessage defaultMessage="Amount" /> <FormattedMessage defaultMessage="Amount" />
</div> </div>
{rows?.items.map(a => ( {rows?.items.map(a => {
<> let ev: NostrEvent | undefined;
<div>{new Date(a.created * 1000).toLocaleString()}</div> if (a.desc && a.desc.startsWith("{")) {
<div>{a.desc}</div> ev = JSON.parse(a.desc) as NostrEvent;
<div> }
{a.type === 0 ? "+" : "-"} return (
{a.amount} <>
</div> <div>{new Date(a.created * 1000).toLocaleString()}</div>
</> <div>
))} {ev ? (
<Link to={`/${eventLink(ev)}`} className="text-primary">
<FormattedMessage defaultMessage="Past Stream" />
</Link>
) : (
a.desc
)}
</div>
<div>
{a.type === 0 ? "+" : "-"}
<FormattedNumber value={a.amount} />
</div>
</>
);
})}
</div> </div>
); );
} }

View File

@ -140,6 +140,9 @@
"69hmpj": { "69hmpj": {
"defaultMessage": "Raid from {name}" "defaultMessage": "Raid from {name}"
}, },
"6PK5Jy": {
"defaultMessage": "Past Stream"
},
"6Z2pvJ": { "6Z2pvJ": {
"defaultMessage": "Stream Providers" "defaultMessage": "Stream Providers"
}, },

View File

@ -46,6 +46,7 @@
"5tM0VD": "Stream Started", "5tM0VD": "Stream Started",
"5vMmmR": "Usernames are not unique on Nostr. The nostr address is your unique human-readable address that is unique to you upon registration.", "5vMmmR": "Usernames are not unique on Nostr. The nostr address is your unique human-readable address that is unique to you upon registration.",
"69hmpj": "Raid from {name}", "69hmpj": "Raid from {name}",
"6PK5Jy": "Past Stream",
"6Z2pvJ": "Stream Providers", "6Z2pvJ": "Stream Providers",
"6pr6hJ": "Minimum amount for text to speech", "6pr6hJ": "Minimum amount for text to speech",
"7+bCC1": "Stream url must start with rtmp://", "7+bCC1": "Stream url must start with rtmp://",