Store custom amounts in the link

This commit is contained in:
Austin Chen 2022-05-04 12:10:33 -04:00
parent 76d234388b
commit 97b2a5d5a9

View File

@ -1,10 +1,14 @@
import { useState } from 'react'
import { Col } from '../components/layout/col'
import { Page } from '../components/page' import { Page } from '../components/page'
import { SEO } from '../components/SEO' import { SEO } from '../components/SEO'
import { Title } from '../components/title'
import { useUser } from '../hooks/use-user' import { useUser } from '../hooks/use-user'
import { createManalink } from '../lib/firebase/manalinks' import { createManalink } from '../lib/firebase/manalinks'
export default function SendPage() { export default function SendPage() {
const user = useUser() const user = useUser()
const [amount, setAmount] = useState(100)
return ( return (
<Page> <Page>
@ -14,22 +18,38 @@ export default function SendPage() {
url="/send" url="/send"
/> />
<h1>Send Mana</h1> <Col className="gap-4">
{user && ( <Title text="Send mana" />
<button
className="btn" {/* Add a input form to set the amount */}
onClick={async () => { <label>
await createManalink({ Amount M$
fromId: user.id, <input
amount: 1234, className="input"
expiresTime: Date.now() + 1000 * 60 * 60 * 24 * 7, type="number"
maxUses: Infinity, value={amount}
}) onChange={(e) => setAmount(parseInt(e.target.value))}
}} />
> </label>
Create a new Manalink
</button> {user && (
)} <button
className="btn"
onClick={async () => {
await createManalink({
fromId: user.id,
amount: amount,
expiresTime: Date.now() + 1000 * 60 * 60 * 24 * 7,
maxUses: Infinity,
})
}}
>
Create a new Manalink
</button>
)}
</Col>
{/* TODO: show referral links via TailwindUI Table https://tailwindui.com/components/application-ui/lists/tables */}
</Page> </Page>
) )
} }