import { useCallback } from 'react' import { boolean, object } from 'yup' import { Button } from 'react-bootstrap' import { Form, ClientInput, SubmitButton, Checkbox } from '@/components/form' import { useMe } from '@/components/me' import { useShowModal } from '@/components/modal' import Link from 'next/link' import styles from '@/styles/wallet.module.css' import { useMutation } from '@apollo/client' import { HIDE_WALLET_RECV_PROMPT_MUTATION } from '@/fragments/users' import { useToast } from '@/components/toast' import { useLightningAddressUpsert } from '@/wallets/client/hooks/query' import { protocolClientSchema } from '@/wallets/lib/util' export class WalletPromptClosed extends Error { constructor () { super('wallet prompt closed') } } export function useWalletRecvPrompt () { const { me } = useMe() const showModal = useShowModal() const toaster = useToast() const onAttach = useCallback(({ onClose, resolve }) => () => { toaster.success('lightning address saved', { persistOnNavigate: true }) resolve() onClose() }, [toaster]) const onSkip = useCallback(({ onClose, resolve }) => () => { resolve() onClose() }, []) return useCallback((e) => { return new Promise((resolve, reject) => { if (!me || me.optional?.hasRecvWallet || me.privates?.hideWalletRecvPrompt) return resolve() showModal(onClose => { return ( <>
or
or