1
0
forked from Kieran/snort

Zap split goals

This commit is contained in:
Kieran 2023-09-14 13:34:45 +01:00
parent dd4d73e81c
commit 0fa51dd7e5
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
5 changed files with 18 additions and 10 deletions

View File

@ -271,7 +271,6 @@ export default function NoteFooter(props: NoteFooterProps) {
targets={getZapTarget()} targets={getZapTarget()}
onClose={() => setTip(false)} onClose={() => setTip(false)}
show={tip} show={tip}
author={author?.pubkey}
note={ev.id} note={ev.id}
allocatePool={true} allocatePool={true}
/> />

View File

@ -36,7 +36,6 @@ export interface SendSatsProps {
title?: ReactNode; title?: ReactNode;
notice?: string; notice?: string;
note?: HexKey; note?: HexKey;
author?: HexKey;
allocatePool?: boolean; allocatePool?: boolean;
} }

View File

@ -5,6 +5,7 @@ import { useUserProfile } from "@snort/system-react";
import SendSats from "Element/SendSats"; import SendSats from "Element/SendSats";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import { ZapTarget } from "Zapper";
const ZapButton = ({ const ZapButton = ({
pubkey, pubkey,
@ -29,10 +30,9 @@ const ZapButton = ({
{children} {children}
</div> </div>
<SendSats <SendSats
targets={[{ type: "lnurl", value: service, weight: 1, name: profile?.display_name || profile?.name }]} targets={[{ type: "lnurl", value: service, weight: 1, name: profile?.display_name || profile?.name, zap: { pubkey: pubkey } } as ZapTarget]}
show={zap} show={zap}
onClose={() => setZap(false)} onClose={() => setZap(false)}
author={pubkey}
note={event} note={event}
/> />
</> </>

View File

@ -1,12 +1,15 @@
import "./ZapGoal.css"; import "./ZapGoal.css";
import { CSSProperties, useState } from "react";
import { NostrEvent, NostrPrefix, createNostrLink } from "@snort/system"; import { NostrEvent, NostrPrefix, createNostrLink } from "@snort/system";
import useZapsFeed from "Feed/ZapsFeed"; import useZapsFeed from "Feed/ZapsFeed";
import { formatShort } from "Number"; import { formatShort } from "Number";
import { findTag } from "SnortUtils"; import { findTag } from "SnortUtils";
import { CSSProperties } from "react"; import Icon from "Icons/Icon";
import ZapButton from "./ZapButton"; import SendSats from "./SendSats";
import { Zapper } from "Zapper";
export function ZapGoal({ ev }: { ev: NostrEvent }) { export function ZapGoal({ ev }: { ev: NostrEvent }) {
const [zap, setZap] = useState(false);
const zaps = useZapsFeed(createNostrLink(NostrPrefix.Note, ev.id)); const zaps = useZapsFeed(createNostrLink(NostrPrefix.Note, ev.id));
const target = Number(findTag(ev, "amount")); const target = Number(findTag(ev, "amount"));
const amount = zaps.reduce((acc, v) => (acc += v.amount * 1000), 0); const amount = zaps.reduce((acc, v) => (acc += v.amount * 1000), 0);
@ -16,7 +19,14 @@ export function ZapGoal({ ev }: { ev: NostrEvent }) {
<div className="zap-goal card"> <div className="zap-goal card">
<div className="flex f-space"> <div className="flex f-space">
<h2>{ev.content}</h2> <h2>{ev.content}</h2>
<ZapButton pubkey={ev.pubkey} event={ev.id} /> <div className="zap-button flex" onClick={() => setZap(true)}>
<Icon name="zap" size={15} />
</div>
<SendSats
targets={Zapper.fromEvent(ev)}
show={zap}
onClose={() => setZap(false)}
/>
</div> </div>
<div className="flex f-space"> <div className="flex f-space">

View File

@ -54,6 +54,7 @@ import useHorizontalScroll from "Hooks/useHorizontalScroll";
import { EmailRegex } from "Const"; import { EmailRegex } from "Const";
import { getNip05PubKey } from "Pages/LoginPage"; import { getNip05PubKey } from "Pages/LoginPage";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
import { ZapTarget } from "Zapper";
import messages from "./messages"; import messages from "./messages";
@ -292,13 +293,12 @@ export default function ProfilePage() {
<SendSats <SendSats
targets={ targets={
lnurl?.lnurl lnurl?.lnurl && id
? [{ type: "lnurl", value: lnurl?.lnurl, weight: 1, name: user?.display_name || user?.name }] ? [{ type: "lnurl", value: lnurl?.lnurl, weight: 1, name: user?.display_name || user?.name, zap: { pubkey: id } } as ZapTarget]
: undefined : undefined
} }
show={showLnQr} show={showLnQr}
onClose={() => setShowLnQr(false)} onClose={() => setShowLnQr(false)}
author={id}
/> />
</> </>
); );