Skip to content

Commit

Permalink
Merge pull request stakwork#772 from stakwork/fix/invite-number
Browse files Browse the repository at this point in the history
fix: input type valid number
  • Loading branch information
humansinstitute authored Dec 17, 2024
2 parents 609ae03 + 92e2f1c commit 8022de2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/pages/superadmin/header/InviteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ const InviteModal = (props: InviteProps) => {
setLoading(false);
};

function handleNumberChange(e: any, updateState: (value: number) => void) {
const { value } = e.target;

// Validate: Allow only numbers
if (/^\d*$/.test(value)) {
updateState(Number(value));
}
}
return (
<>
<Modal
Expand Down Expand Up @@ -128,7 +136,7 @@ const InviteModal = (props: InviteProps) => {
width: '100%'
}}
value={inviteNumber}
onChange={(e: any) => setInviteNumber(Number(e.target.value))}
onChange={(e: any) => handleNumberChange(e, setInviteNumber)}
/>
</InvoiceInputContainer>

Expand Down Expand Up @@ -160,12 +168,12 @@ const InviteModal = (props: InviteProps) => {
</InvoiceLabel>
<InvoiceInput
data-testid="withdrawInvoiceInput"
type="number"
type="text"
style={{
width: '100%'
}}
value={satAmount}
onChange={(e: any) => setSatAmount(Number(e.target.value))}
onChange={(e: any) => handleNumberChange(e, setSatAmount)}
/>
</InvoiceInputContainer>
</InvoiceForm>
Expand Down

0 comments on commit 8022de2

Please sign in to comment.