split ZapPool
This commit is contained in:
parent
8fef783cf8
commit
bf4e9c9776
@ -12,12 +12,11 @@ import Modal from "@/Components/Modal/Modal";
|
||||
import QrCode from "@/Components/QrCode";
|
||||
import ProfilePreview from "@/Components/User/ProfilePreview";
|
||||
import SnortApi, { RevenueSplit, RevenueToday } from "@/External/SnortApi";
|
||||
import { ZapPoolTarget } from "@/Pages/ZapPool/ZapPoolTarget";
|
||||
import { bech32ToHex, unwrap } from "@/Utils";
|
||||
import { ApiHost, DeveloperAccounts, SnortPubKey } from "@/Utils/Const";
|
||||
import { ZapPoolController, ZapPoolRecipientType } from "@/Utils/ZapPoolController";
|
||||
|
||||
import { ZapPoolTarget } from "./ZapPool";
|
||||
|
||||
const Contributors = [
|
||||
bech32ToHex("npub10djxr5pvdu97rjkde7tgcsjxzpdzmdguwacfjwlchvj7t88dl7nsdl54nf"), // ivan
|
||||
bech32ToHex("npub148jmlutaa49y5wl5mcll003ftj59v79vf7wuv3apcwpf75hx22vs7kk9ay"), // liran cohen
|
||||
|
11
packages/app/src/Pages/ZapPool/ZapPool.tsx
Normal file
11
packages/app/src/Pages/ZapPool/ZapPool.tsx
Normal file
@ -0,0 +1,11 @@
|
||||
import "./ZapPool.css";
|
||||
|
||||
import { ZapPoolPageInner } from "@/Pages/ZapPool/ZapPoolPageInner";
|
||||
import { ZapPoolController } from "@/Utils/ZapPoolController";
|
||||
|
||||
export default function ZapPoolPage() {
|
||||
if (!ZapPoolController) {
|
||||
return null;
|
||||
}
|
||||
return <ZapPoolPageInner />;
|
||||
}
|
@ -1,17 +1,14 @@
|
||||
import "./ZapPool.css";
|
||||
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
import { useMemo, useSyncExternalStore } from "react";
|
||||
import { FormattedMessage, FormattedNumber } from "react-intl";
|
||||
|
||||
import AsyncButton from "@/Components/Button/AsyncButton";
|
||||
import ProfilePreview from "@/Components/User/ProfilePreview";
|
||||
import useEventPublisher from "@/Hooks/useEventPublisher";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
import { ZapPoolTarget } from "@/Pages/ZapPool/ZapPoolTarget";
|
||||
import { bech32ToHex, getRelayName, trackEvent, unwrap } from "@/Utils";
|
||||
import { SnortPubKey } from "@/Utils/Const";
|
||||
import { UploaderServices } from "@/Utils/Upload";
|
||||
import { ZapPoolController, ZapPoolRecipient, ZapPoolRecipientType } from "@/Utils/ZapPoolController";
|
||||
import { ZapPoolController, ZapPoolRecipientType } from "@/Utils/ZapPoolController";
|
||||
import { useWallet } from "@/Wallet";
|
||||
|
||||
const DataProviders = [
|
||||
@ -21,51 +18,7 @@ const DataProviders = [
|
||||
},
|
||||
];
|
||||
|
||||
function ZapPoolTargetInner({ target }: { target: ZapPoolRecipient }) {
|
||||
const login = useLogin();
|
||||
const profile = useUserProfile(target.pubkey);
|
||||
const hasAddress = profile?.lud16 || profile?.lud06;
|
||||
const defaultZapMount = Math.ceil(login.appData.item.preferences.defaultZapAmount * (target.split / 100));
|
||||
return (
|
||||
<ProfilePreview
|
||||
pubkey={target.pubkey}
|
||||
actions={
|
||||
hasAddress ? (
|
||||
<div>
|
||||
<div>
|
||||
<FormattedNumber value={target.split} />% (
|
||||
<FormattedMessage defaultMessage="{n} sats" id="CsCUYo" values={{ n: defaultZapMount }} />)
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min={0}
|
||||
max={100}
|
||||
step={0.5}
|
||||
value={target.split}
|
||||
onChange={e =>
|
||||
ZapPoolController?.set({
|
||||
...target,
|
||||
split: e.target.valueAsNumber,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<FormattedMessage defaultMessage="No lightning address" id="JPFYIM" />
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function ZapPoolTarget({ target }: { target: ZapPoolRecipient }) {
|
||||
if (!ZapPoolController) {
|
||||
return null;
|
||||
}
|
||||
return <ZapPoolTargetInner target={target} />;
|
||||
}
|
||||
|
||||
function ZapPoolPageInner() {
|
||||
export function ZapPoolPageInner() {
|
||||
const login = useLogin();
|
||||
const { system } = useEventPublisher();
|
||||
const zapPool = useSyncExternalStore(
|
||||
@ -232,10 +185,3 @@ function ZapPoolPageInner() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function ZapPoolPage() {
|
||||
if (!ZapPoolController) {
|
||||
return null;
|
||||
}
|
||||
return <ZapPoolPageInner />;
|
||||
}
|
50
packages/app/src/Pages/ZapPool/ZapPoolTarget.tsx
Normal file
50
packages/app/src/Pages/ZapPool/ZapPoolTarget.tsx
Normal file
@ -0,0 +1,50 @@
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
import { FormattedMessage, FormattedNumber } from "react-intl";
|
||||
|
||||
import ProfilePreview from "@/Components/User/ProfilePreview";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
import { ZapPoolController, ZapPoolRecipient } from "@/Utils/ZapPoolController";
|
||||
|
||||
function ZapPoolTargetInner({ target }: { target: ZapPoolRecipient }) {
|
||||
const login = useLogin();
|
||||
const profile = useUserProfile(target.pubkey);
|
||||
const hasAddress = profile?.lud16 || profile?.lud06;
|
||||
const defaultZapMount = Math.ceil(login.appData.item.preferences.defaultZapAmount * (target.split / 100));
|
||||
return (
|
||||
<ProfilePreview
|
||||
pubkey={target.pubkey}
|
||||
actions={
|
||||
hasAddress ? (
|
||||
<div>
|
||||
<div>
|
||||
<FormattedNumber value={target.split} />% (
|
||||
<FormattedMessage defaultMessage="{n} sats" id="CsCUYo" values={{ n: defaultZapMount }} />)
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min={0}
|
||||
max={100}
|
||||
step={0.5}
|
||||
value={target.split}
|
||||
onChange={e =>
|
||||
ZapPoolController?.set({
|
||||
...target,
|
||||
split: e.target.valueAsNumber,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<FormattedMessage defaultMessage="No lightning address" id="JPFYIM" />
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function ZapPoolTarget({ target }: { target: ZapPoolRecipient }) {
|
||||
if (!ZapPoolController) {
|
||||
return null;
|
||||
}
|
||||
return <ZapPoolTargetInner target={target} />;
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
import {ReactNode, useCallback} from "react";
|
||||
import {FormattedMessage} from "react-intl";
|
||||
import {useNavigate} from "react-router-dom";
|
||||
import { ReactNode, useCallback } from "react";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
import {LoginStore, logout} from "@/Utils/Login";
|
||||
import {getCurrentSubscription} from "@/Utils/Subscription";
|
||||
import {SettingsMenuComponent} from "@/Pages/settings/Menu/SettingsMenuComponent";
|
||||
import { SettingsMenuComponent } from "@/Pages/settings/Menu/SettingsMenuComponent";
|
||||
import { LoginStore, logout } from "@/Utils/Login";
|
||||
import { getCurrentSubscription } from "@/Utils/Subscription";
|
||||
|
||||
export type SettingsMenuItems = Array<{
|
||||
title: ReactNode;
|
||||
|
@ -1,15 +1,16 @@
|
||||
import {Link} from "react-router-dom";
|
||||
import classNames from "classnames";
|
||||
import Icon from "@/Components/Icons/Icon";
|
||||
import {SettingsMenuItems} from "@/Pages/settings/Menu/Menu";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
export function SettingsMenuComponent({menu}: { menu: SettingsMenuItems }) {
|
||||
import Icon from "@/Components/Icons/Icon";
|
||||
import { SettingsMenuItems } from "@/Pages/settings/Menu/Menu";
|
||||
|
||||
export function SettingsMenuComponent({ menu }: { menu: SettingsMenuItems }) {
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
{menu.map((group, groupIndex) => (
|
||||
<div key={groupIndex} className="mb-4">
|
||||
<div className="p-2 font-bold uppercase text-secondary text-xs tracking-wide">{group.title}</div>
|
||||
{group.items.map(({icon, iconBg, message, path, action}, index) => (
|
||||
{group.items.map(({ icon, iconBg, message, path, action }, index) => (
|
||||
<Link
|
||||
to={path || "#"}
|
||||
onClick={action}
|
||||
@ -21,15 +22,15 @@ export function SettingsMenuComponent({menu}: { menu: SettingsMenuItems }) {
|
||||
})}>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className={`p-1 ${iconBg} rounded-lg flex justify-center items-center text-white`}>
|
||||
<Icon name={icon} size={18} className="relative"/>
|
||||
<Icon name={icon} size={18} className="relative" />
|
||||
</div>
|
||||
<span className="text-base font-semibold flex-grow">{message}</span>
|
||||
</div>
|
||||
<Icon name="arrowFront" size={12} className="text-secondary"/>
|
||||
<Icon name="arrowFront" size={12} className="text-secondary" />
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import { Outlet, RouteObject } from "react-router-dom";
|
||||
|
||||
import { SettingsMenuComponent } from "@/Pages/settings/Menu/SettingsMenuComponent";
|
||||
|
||||
import { SettingsMenuItems } from "../Menu/Menu";
|
||||
import { FollowsRelayHealth } from "./follows-relay-health";
|
||||
import { PruneFollowList } from "./prune-follows";
|
||||
import {SettingsMenuComponent} from "@/Pages/settings/Menu/SettingsMenuComponent";
|
||||
|
||||
const ToolMenuItems = [
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ import { SubscribeRoutes } from "@/Pages/subscribe";
|
||||
import WalletPage from "@/Pages/wallet";
|
||||
import { WalletReceivePage } from "@/Pages/wallet/receive";
|
||||
import { WalletSendPage } from "@/Pages/wallet/send";
|
||||
import ZapPoolPage from "@/Pages/ZapPool";
|
||||
import ZapPoolPage from "@/Pages/ZapPool/ZapPool";
|
||||
import { System } from "@/system";
|
||||
import { storeRefCode, unwrap } from "@/Utils";
|
||||
import { LoginStore } from "@/Utils/Login";
|
||||
|
Loading…
x
Reference in New Issue
Block a user