import { Button, InputGroup } from 'react-bootstrap' import React, { useState, useRef, useEffect } from 'react' import { Form, Input, SubmitButton } from './form' import { useMe } from './me' import UpBolt from '../svgs/bolt.svg' import { amountSchema } from '../lib/validate' const defaultTips = [100, 1000, 10000, 100000] const Tips = ({ setOValue }) => { const tips = [...getCustomTips(), ...defaultTips].sort((a, b) => a - b) return tips.map(num => ) } const getCustomTips = () => JSON.parse(localStorage.getItem('custom-tips')) || [] const addCustomTip = (amount) => { if (defaultTips.includes(amount)) return let customTips = Array.from(new Set([amount, ...getCustomTips()])) if (customTips.length > 3) { customTips = customTips.slice(0, 3) } localStorage.setItem('custom-tips', JSON.stringify(customTips)) } export default function ItemAct ({ onClose, itemId, act, strike }) { const inputRef = useRef(null) const me = useMe() const [oValue, setOValue] = useState() useEffect(() => { inputRef.current?.focus() }, [onClose, itemId]) return (
{ await act({ variables: { id: itemId, sats: Number(amount) } }) await strike() addCustomTip(Number(amount)) onClose() }} > sats} />
tip
) }