import { getGetServerSideProps } from '@/api/ssrApollo' import { Form, Input, SubmitButton } from '@/components/form' import { CenterLayout } from '@/components/layout' import { useLightning } from '@/components/lightning' import { useMe } from '@/components/me' import { useShowModal } from '@/components/modal' import { usePaidMutation } from '@/components/use-paid-mutation' import { BUY_CREDITS } from '@/fragments/paidAction' import { amountSchema } from '@/lib/validate' import { Button, Col, InputGroup, Row } from 'react-bootstrap' export const getServerSideProps = getGetServerSideProps({ authRequired: true }) export default function Credits () { const { me } = useMe() return ( {me?.privates?.credits} cowboy credits {me?.privates?.sats - me?.privates?.credits} sats withdraw sats {me?.privates?.credits} cowboy credits {me?.privates?.sats - me?.privates?.credits} sats withdraw sats ) } export function BuyCreditsButton () { const showModal = useShowModal() const strike = useLightning() const [buyCredits] = usePaidMutation(BUY_CREDITS) return ( <> showModal(onClose => ( { const { error } = await buyCredits({ variables: { credits: Number(amount) }, onCompleted: () => { strike() } }) onClose() if (error) throw error }} > sats} /> buy ))} className='mt-3' variant='secondary' >buy credits > ) }