Skip to content

Commit

Permalink
fix(tip): rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
songkeys committed Jul 1, 2024
1 parent f33d114 commit f7a13e3
Showing 1 changed file with 49 additions and 25 deletions.
74 changes: 49 additions & 25 deletions src/renderer/src/modules/wallet/tip-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,6 @@ export const TipModalContent: FC<{

const settingModalPresent = useSettingModal()

const CustomBalanceInput = () => {
const { onChange: ctxOnChange } = useRadioContext()

return (
<Input
className="focus:border-0"
type="number"
min={0}
max={balanceNumber}
step={0.01}
placeholder="Enter amount"
value={amount}
onClick={() => {
setAmountCard("custom")
ctxOnChange?.("custom")
}}
onChange={(e) => {
setAmount(Number(e.target.value))
}}
/>
)
}

if (transactionsQuery.isPending || myWallet.isPending) {
return (
<div className="center h-32 w-[650px]">
Expand Down Expand Up @@ -147,8 +124,21 @@ export const TipModalContent: FC<{
<RadioCard className="justify-center" label="2.00" value="2" />

<RadioCard
className="justify-center p-0"
label={(<CustomBalanceInput />)}
wrapperClassName="justify-center p-0"
label={(
<CustomBalanceInput
max={balanceNumber}
value={amount}
onChange={(e) => {
setAmountCard("custom")
setAmount(Number(e.target.value))
}}
onClick={(e) => {
setAmountCard("custom")
setAmount(Number(e.target.value))

Check failure on line 138 in src/renderer/src/modules/wallet/tip-modal.tsx

View workflow job for this annotation

GitHub Actions / Lint and Typecheck (18.x)

Property 'value' does not exist on type 'EventTarget'.
}}
/>
)}
value="custom"
/>
</div>
Expand Down Expand Up @@ -217,3 +207,37 @@ export const TipModalContent: FC<{
</div>
)
}

const CustomBalanceInput = ({
max,
value,
onClick,
onChange,
}: {
max?: number
value: number
onClick?: (e: React.MouseEvent<HTMLInputElement>) => void
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
}) => {
const { onChange: ctxOnChange } = useRadioContext()

return (
<Input
key="custom"
className="focus:border-0"
type="number"
min={0}
max={max}
step={0.01}
placeholder="Enter amount"
value={value}
onClick={(e) => {
ctxOnChange?.("custom")
onClick?.(e)
}}
onChange={(e) => {
onChange?.(e)
}}
/>
)
}

0 comments on commit f7a13e3

Please sign in to comment.