feat: select forward type

This commit is contained in:
Kieran 2023-11-07 11:30:01 +00:00
parent c689bd39dc
commit e248889170
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
4 changed files with 34 additions and 13 deletions

View File

@ -8,6 +8,7 @@ export interface ManageHandle {
pubkey: string;
created: Date;
lnAddress?: string;
forwardType?: ForwardType;
}
export enum ForwardType {

View File

@ -5,13 +5,14 @@ import { LNURL } from "@snort/shared";
import { ApiHost } from "Const";
import AsyncButton from "Element/AsyncButton";
import useEventPublisher from "Hooks/useEventPublisher";
import SnortServiceProvider, { ManageHandle } from "Nip05/SnortServiceProvider";
import SnortServiceProvider, { ForwardType, ManageHandle } from "Nip05/SnortServiceProvider";
export default function LNForwardAddress({ handle }: { handle: ManageHandle }) {
const { formatMessage } = useIntl();
const { publisher } = useEventPublisher();
const [newAddress, setNewAddress] = useState(handle.lnAddress ?? "");
const [fwdType, setFwdType] = useState(handle.forwardType ?? ForwardType.Redirect);
const [error, setError] = useState("");
async function startUpdate() {
@ -19,6 +20,7 @@ export default function LNForwardAddress({ handle }: { handle: ManageHandle }) {
const req = {
lnAddress: newAddress,
forwardType: fwdType,
};
setError("");
@ -49,18 +51,28 @@ export default function LNForwardAddress({ handle }: { handle: ManageHandle }) {
<p>
<FormattedMessage defaultMessage="Your handle will act like a lightning address and will redirect to your chosen LNURL or Lightning address" />
</p>
<div className="flex">
<div className="grow">
<input
type="text"
className="w-max mr10"
placeholder={formatMessage({
defaultMessage: "LNURL or Lightning Address",
})}
value={newAddress}
onChange={e => setNewAddress(e.target.value)}
/>
</div>
<p>
<small>
<FormattedMessage defaultMessage="Redirect issues HTTP redirect to the supplied lightning address" />
<br />
<FormattedMessage defaultMessage="Proxy uses HODL invoices to forward the payment, which hides the pubkey of your node" />
</small>
</p>
<div className="flex g8">
<input
type="text"
className="w-max"
placeholder={formatMessage({
defaultMessage: "LNURL or Lightning Address",
})}
value={newAddress}
onChange={e => setNewAddress(e.target.value)}
/>
<select value={fwdType} onChange={e => setFwdType(Number(e.target.value))}>
<option value={ForwardType.Redirect}>Redirect</option>
<option value={ForwardType.ProxyDirect}>Proxy</option>
</select>
<AsyncButton onClick={() => startUpdate()}>
<FormattedMessage defaultMessage="Update" />
</AsyncButton>

View File

@ -235,6 +235,9 @@
"7/h1jn": {
"defaultMessage": "After submitting the pin there may be a slight delay as we encrypt the key."
},
"712i26": {
"defaultMessage": "Proxy uses HODL invoices to forward the payment, which hides the pubkey of your node"
},
"7BX/yC": {
"defaultMessage": "Account Switcher"
},
@ -470,6 +473,9 @@
"FSYL8G": {
"defaultMessage": "Trending Users"
},
"FcNSft": {
"defaultMessage": "Redirect issues HTTP redirect to the supplied lightning address"
},
"FdhSU2": {
"defaultMessage": "Claim Now"
},

View File

@ -77,6 +77,7 @@
"6uMqL1": "Unpaid",
"7+Domh": "Notes",
"7/h1jn": "After submitting the pin there may be a slight delay as we encrypt the key.",
"712i26": "Proxy uses HODL invoices to forward the payment, which hides the pubkey of your node",
"7BX/yC": "Account Switcher",
"7UOvbT": "Offline",
"7hp70g": "NIP-05",
@ -154,6 +155,7 @@
"FMfjrl": "Show status messages on profile pages",
"FS3b54": "Done!",
"FSYL8G": "Trending Users",
"FcNSft": "Redirect issues HTTP redirect to the supplied lightning address",
"FdhSU2": "Claim Now",
"FfYsOb": "An error has occured!",
"FmXUJg": "follows you",