From a49b40d9b34d7ddf1a5796afa6b323db03d2096c Mon Sep 17 00:00:00 2001 From: Kieran Date: Tue, 24 Jan 2023 12:26:14 +0000 Subject: [PATCH] feat: splits donate page --- src/Pages/DonatePage.tsx | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/Pages/DonatePage.tsx b/src/Pages/DonatePage.tsx index 5758f5e..9b859c5 100644 --- a/src/Pages/DonatePage.tsx +++ b/src/Pages/DonatePage.tsx @@ -1,19 +1,46 @@ import ProfilePreview from "Element/ProfilePreview"; -import ZapButton from "Element/ZapButton"; +import { HexKey } from "Nostr"; +import { useEffect, useState } from "react"; import { bech32ToHex } from "Util"; const Developers = [ bech32ToHex("npub1v0lxxxxutpvrelsksy8cdhgfux9l6a42hsj2qzquu2zk7vc9qnkszrqj49"), // kieran - bech32ToHex("npub107jk7htfv243u0x5ynn43scq9wrxtaasmrwwa8lfu2ydwag6cx2quqncxg") // verbiricha + bech32ToHex("npub107jk7htfv243u0x5ynn43scq9wrxtaasmrwwa8lfu2ydwag6cx2quqncxg"), // verbiricha + bech32ToHex("npub1r0rs5q2gk0e3dk3nlc7gnu378ec6cnlenqp8a3cjhyzu6f8k5sgs4sq9ac"), // Karnage ]; const Contributors = [ bech32ToHex("npub10djxr5pvdu97rjkde7tgcsjxzpdzmdguwacfjwlchvj7t88dl7nsdl54nf"), // ivan bech32ToHex("npub148jmlutaa49y5wl5mcll003ftj59v79vf7wuv3apcwpf75hx22vs7kk9ay"), // liran cohen - bech32ToHex("npub1r0rs5q2gk0e3dk3nlc7gnu378ec6cnlenqp8a3cjhyzu6f8k5sgs4sq9ac"), // Karnage ]; +interface Splits { + pubKey: string, + split: number +} + const DonatePage = () => { + const [splits, setSplits] = useState([]); + + async function loadSplits() { + let rsp = await fetch("https://api.snort.social/api/v1/revenue/splits"); + if(rsp.ok) { + setSplits(await rsp.json()); + } + } + + useEffect(() => { + loadSplits().catch(console.warn); + }, []); + + function actions(pk: HexKey) { + let split = splits.find(a => bech32ToHex(a.pubKey) === pk); + if(split) { + return <>{(100 * split.split).toLocaleString()}% + } + return <> + } + return (

Help fund the development of Snort

@@ -26,10 +53,13 @@ const DonatePage = () => {

Check out the code here: https://github.com/v0l/snort

+

+ Each contributor will get paid a percentage of all donations and NIP-05 orders, you can see the split amounts below +

Primary Developers

- {Developers.map(a => } />)} + {Developers.map(a => )}

Contributors

- {Contributors.map(a => } />)} + {Contributors.map(a => )}
); }