snort/src/Pages/DonatePage.tsx

89 lines
3.1 KiB
TypeScript
Raw Normal View History

2023-02-03 18:20:17 +00:00
import { ApiHost, KieranPubKey } from "Const";
2023-01-20 11:11:50 +00:00
import ProfilePreview from "Element/ProfilePreview";
import ZapButton from "Element/ZapButton";
2023-01-24 12:26:14 +00:00
import { HexKey } from "Nostr";
import { useEffect, useState } from "react";
2023-01-20 17:07:14 +00:00
import { bech32ToHex } from "Util";
2023-01-19 00:03:24 +00:00
const Developers = [
2023-02-03 18:20:17 +00:00
bech32ToHex(KieranPubKey), // kieran
2023-01-24 12:26:14 +00:00
bech32ToHex("npub107jk7htfv243u0x5ynn43scq9wrxtaasmrwwa8lfu2ydwag6cx2quqncxg"), // verbiricha
bech32ToHex("npub1r0rs5q2gk0e3dk3nlc7gnu378ec6cnlenqp8a3cjhyzu6f8k5sgs4sq9ac"), // Karnage
2023-01-20 17:07:14 +00:00
];
const Contributors = [
bech32ToHex("npub10djxr5pvdu97rjkde7tgcsjxzpdzmdguwacfjwlchvj7t88dl7nsdl54nf"), // ivan
bech32ToHex("npub148jmlutaa49y5wl5mcll003ftj59v79vf7wuv3apcwpf75hx22vs7kk9ay"), // liran cohen
2023-01-28 16:07:07 +00:00
bech32ToHex("npub1xdtducdnjerex88gkg2qk2atsdlqsyxqaag4h05jmcpyspqt30wscmntxy"), // artur
2023-01-19 00:03:24 +00:00
];
2023-01-24 12:26:14 +00:00
interface Splits {
pubKey: string,
split: number
}
2023-01-26 15:41:10 +00:00
interface TotalToday {
donations: number,
nip5: number
}
2023-01-19 00:03:24 +00:00
const DonatePage = () => {
2023-01-24 12:26:14 +00:00
const [splits, setSplits] = useState<Splits[]>([]);
2023-01-26 15:41:10 +00:00
const [today, setSumToday] = useState<TotalToday>();
2023-01-24 12:26:14 +00:00
2023-01-26 15:41:10 +00:00
async function loadData() {
2023-01-25 11:49:56 +00:00
let rsp = await fetch(`${ApiHost}/api/v1/revenue/splits`);
2023-01-24 12:26:14 +00:00
if(rsp.ok) {
setSplits(await rsp.json());
}
2023-01-26 15:41:10 +00:00
let rsp2 = await fetch(`${ApiHost}/api/v1/revenue/today`);
if(rsp2.ok) {
setSumToday(await rsp2.json());
}
2023-01-24 12:26:14 +00:00
}
useEffect(() => {
2023-01-26 15:41:10 +00:00
loadData().catch(console.warn);
2023-01-24 12:26:14 +00:00
}, []);
function actions(pk: HexKey) {
let split = splits.find(a => bech32ToHex(a.pubKey) === pk);
if(split) {
return <>{(100 * split.split).toLocaleString()}%</>
}
return <></>
}
2023-01-19 00:03:24 +00:00
return (
2023-01-25 18:08:53 +00:00
<div className="main-content m5">
2023-01-19 00:03:24 +00:00
<h2>Help fund the development of Snort</h2>
<p>
Snort is an open source project built by passionate people in their free time
</p>
<p>
Your donations are greatly appreciated
</p>
<p>
2023-01-19 11:14:41 +00:00
Check out the code here: <a className="highlight" href="https://github.com/v0l/snort" rel="noreferrer" target="_blank">https://github.com/v0l/snort</a>
2023-01-19 00:03:24 +00:00
</p>
2023-01-24 12:26:14 +00:00
<p>
Each contributor will get paid a percentage of all donations and NIP-05 orders, you can see the split amounts below
</p>
<div className="flex">
<div className="mr10">Lightning Donation: </div>
2023-02-03 22:15:49 +00:00
<ZapButton
pubkey={"84de35e2584d2b144aae823c9ed0b0f3deda09648530b93d1a2a146d1dea9864"}
svc={"donate@snort.social"}
/>
</div>
2023-01-26 15:41:10 +00:00
{today && (<small>Total today (UTC): {today.donations.toLocaleString()} sats</small>)}
2023-01-20 17:07:14 +00:00
<h3>Primary Developers</h3>
2023-01-24 12:26:14 +00:00
{Developers.map(a => <ProfilePreview pubkey={a} key={a} actions={actions(a)} />)}
2023-01-20 17:07:14 +00:00
<h4>Contributors</h4>
2023-01-24 12:26:14 +00:00
{Contributors.map(a => <ProfilePreview pubkey={a} key={a} actions={actions(a)} />)}
2023-01-19 00:03:24 +00:00
</div>
);
}
2023-01-19 11:14:41 +00:00
export default DonatePage;