import { User } from "@/components/user"; import { NostrQuery } from "@lume/system"; import { createFileRoute } from "@tanstack/react-router"; import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"; import { message } from "@tauri-apps/plugin-dialog"; import { useState } from "react"; import CurrencyInput from "react-currency-input-field"; const DEFAULT_VALUES = [21, 50, 100, 200]; export const Route = createFileRoute("/zap/$id")({ beforeLoad: async ({ params }) => { const event = await NostrQuery.getEvent(params.id); return { event }; }, component: Screen, }); function Screen() { const { event } = Route.useRouteContext(); const [amount, setAmount] = useState(21); const [content, setContent] = useState(""); const [isCompleted, setIsCompleted] = useState(false); const [isLoading, setIsLoading] = useState(false); const submit = async () => { try { // start loading setIsLoading(true); // Zap const val = await event.zap(amount, content); if (val) { setIsCompleted(true); // close current window await getCurrentWebviewWindow().close(); } } catch (e) { setIsLoading(false); await message(String(e), { title: "Zap", kind: "error", }); } }; return (
Send zap to