import { useState } from 'react'; import { money, positionAmount, nowMinute, requestUuid, type Position } from './api'; import { t as tr } from './i18n'; export function QuickTransfer({ source, target, busy, changeSource, changeTarget, submit, }: { source: Position; target: Position; busy: boolean; changeSource: () => void; changeTarget: () => void; submit: (data: unknown) => void; }) { const [amount, setAmount] = useState(''); const [requestId] = useState(requestUuid); const same = source.currency === target.currency; return (
{ e.preventDefault(); const f = new FormData(e.currentTarget); submit({ requestId, sourceId: source.id, targetId: target.id, amount, received: same ? amount : String(f.get('received')), fee: '0', notes: '', date: nowMinute(), }); }} >
{tr('转出账户')} {source.name} {money(positionAmount(source), source.currency)}
{tr('转入账户')} {target.name} {money(positionAmount(target), target.currency)}
{!same && ( )}

{tr('按当前时间记录,手续费为 0。跨币种请填写实际到账金额。')}

); }