Skip to content

Commit

Permalink
feat(home): use nextui input and checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
escapedcat committed Nov 12, 2024
1 parent 7002e41 commit 3d85598
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 23 deletions.
19 changes: 13 additions & 6 deletions src/pages/Home/SendModal/SendLN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Alert } from "@/components/Alert";
import AvailableBalance from "@/components/AvailableBalance";
import { Button } from "@/components/Button";
import { ConfirmModal } from "@/components/ConfirmModal";
import InputField from "@/components/InputField";
import { convertMSatToSat } from "@/utils/format";
import { Input } from "@nextui-org/react";
import { FC, useState } from "react";
import type { SubmitHandler } from "react-hook-form";
import { useForm } from "react-hook-form";
Expand Down Expand Up @@ -60,18 +60,25 @@ const SendLn: FC<Props> = ({
<ConfirmModal.Body>
<AvailableBalance balance={convertedBalance!} />

<InputField
<Input
className="w-full"
classNames={{
inputWrapper:
"bg-tertiary group-data-[focus=true]:bg-tertiary group-data-[hover=true]:bg-tertiary",
}}
type="text"
isInvalid={!!errors.invoice}
errorMessage={errors.invoice?.message}
label={t("wallet.invoice")}
placeholder="lnbc..."
disabled={isLoading}
{...register("invoice", {
required: t("forms.validation.lnInvoice.required"),
pattern: {
value: /^(lnbc|lntb)\w+/i,
message: t("forms.validation.lnInvoice.patternMismatch"),
},
})}
label={t("wallet.invoice")}
errorMessage={errors.invoice}
placeholder="lnbc..."
disabled={isLoading}
/>

{error && <Alert color="danger">{error}</Alert>}
Expand Down
52 changes: 35 additions & 17 deletions src/pages/Home/SendModal/SendOnChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import AmountInput from "@/components/AmountInput";
import AvailableBalance from "@/components/AvailableBalance";
import { Button } from "@/components/Button";
import { ConfirmModal } from "@/components/ConfirmModal";
import InputField from "@/components/InputField";
import { stringToNumber } from "@/utils/format";
import { Checkbox } from "@nextui-org/checkbox";
import { Input } from "@nextui-org/react";
import { ChangeEvent, FC, useState } from "react";
import type { SubmitHandler } from "react-hook-form";
import { useForm } from "react-hook-form";
Expand Down Expand Up @@ -67,7 +67,12 @@ const SendOnChain: FC<Props> = ({ balance, onConfirm, confirmData }) => {

<fieldset className="flex flex-col items-center justify-center text-center">
<div className="w-full py-1">
<InputField
<Input
className="w-full"
classNames={{
inputWrapper:
"bg-tertiary group-data-[focus=true]:bg-tertiary group-data-[hover=true]:bg-tertiary",
}}
{...register("address", {
required: t("forms.validation.chainAddress.required"),
pattern: {
Expand All @@ -77,7 +82,8 @@ const SendOnChain: FC<Props> = ({ balance, onConfirm, confirmData }) => {
})}
placeholder="bc1..."
label={t("wallet.address")}
errorMessage={errors.address}
isInvalid={!!errors.address}
errorMessage={errors.address?.message}
/>
</div>

Expand All @@ -95,9 +101,7 @@ const SendOnChain: FC<Props> = ({ balance, onConfirm, confirmData }) => {
},
validate: {
greaterThanZero: (val) =>
//@ts-ignore
stringToNumber(val) > 0 ||
t("forms.validation.chainAmount.required"),
val > 0 || t("forms.validation.chainAmount.required"),
},
onChange: changeAmountHandler,
})}
Expand All @@ -106,28 +110,42 @@ const SendOnChain: FC<Props> = ({ balance, onConfirm, confirmData }) => {
)}

<div className="flex w-full justify-start gap-2 pb-1">
<InputField
{...register("spendAll", {})}
label={t("tx.spend_all")}
errorMessage={errors.spendAll}
type="checkbox"
/>
<Checkbox {...register("spendAll", {})}>
{t("tx.spend_all")}
</Checkbox>
</div>

<div className="w-full py-1">
<InputField
<Input
className="w-full"
classNames={{
inputWrapper:
"bg-tertiary group-data-[focus=true]:bg-tertiary group-data-[hover=true]:bg-tertiary",
}}
{...register("fee", {
required: t("forms.validation.chainFee.required"),
})}
label={t("tx.fee")}
errorMessage={errors.fee}
inputRightAddon="sat / vByte"
isInvalid={!!errors.fee}
errorMessage={errors.fee?.message}
type="number"
endContent={
<div className="pointer-events-none flex items-center">
<span className="whitespace-nowrap text-small text-default-400">
sat / vByte
</span>
</div>
}
/>
</div>

<div className="w-full py-1">
<InputField
<Input
className="w-full"
classNames={{
inputWrapper:
"bg-tertiary group-data-[focus=true]:bg-tertiary group-data-[hover=true]:bg-tertiary",
}}
{...register("comment")}
label={t("tx.comment")}
placeholder={t("tx.comment_placeholder")}
Expand Down

0 comments on commit 3d85598

Please sign in to comment.