predikt/oracle/web/components/contract/editable-payment-info.tsx
caelum0x 2b68bde5d5 Predikt: full Polymarket-style prediction market — web + mobile + on-chain + bots
Working tree is now the canonical repo. Off-chain play-money + trustless on-chain
(FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution,
mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 23:29:50 +03:00

68 lines
1.9 KiB
TypeScript

import { useEffect, useState } from 'react'
import { CheckIcon, XIcon, PencilIcon } from '@heroicons/react/solid'
import { IconButton } from '../buttons/button'
import { Input } from '../widgets/input'
import { usePrivateUser } from 'web/hooks/use-user'
import { api } from 'web/lib/api/api'
export const EditablePaymentInfo = () => {
const [isEditing, setEditing] = useState(false)
const privateUser = usePrivateUser()
const [paymentInfo, setPaymentInfo] = useState(privateUser?.paymentInfo || '')
useEffect(() => {
setPaymentInfo(privateUser?.paymentInfo || '')
}, [privateUser])
const edit = () => {
setEditing(true)
}
const onSave = async (newPaymentInfo: string) => {
await api('me/private/update', {
paymentInfo: newPaymentInfo,
})
setEditing(false)
}
return isEditing ? (
<div className="flex items-center gap-2">
<Input
className="grow"
type="text"
aria-label="Payment information"
maxLength={60}
value={paymentInfo}
onChange={(e) => setPaymentInfo(e.target.value || '')}
autoFocus
/>
<IconButton
aria-label="Save payment information"
onClick={() => onSave(paymentInfo)}
className="p-1"
>
<CheckIcon className="h-4 w-4 text-teal-600" />
</IconButton>
<IconButton
aria-label="Cancel editing payment information"
onClick={() => setEditing(false)}
className="p-1"
>
<XIcon className="text-scarlet-400 h-4 w-4" />
</IconButton>
</div>
) : (
<div className="text-md flex items-center">
<span>{paymentInfo}</span>
<button
type="button"
aria-label="Edit payment information"
onClick={edit}
className="align-center hover:bg-ink-100 hover:text-ink-600 text-ink-500 ml-1 rounded p-1 transition-colors sm:group-hover:inline"
>
<PencilIcon className="h-4 w-4" />
</button>
</div>
)
}