Skip to content

Commit

Permalink
fix: input type valid number
Browse files Browse the repository at this point in the history
  • Loading branch information
tobi-bams committed Dec 13, 2024
1 parent 96c366e commit 17d5c16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/config/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const externalDockerHosts = ['localhost:23007', 'localhost:23000'];
export function getHost(): string {
const host = window.location.host.includes('localhost')
? window.location.host.includes('localhost:3007')
? 'localhost:13000'
? // ? 'localhost:13000'
'people-test.sphinx.chat'
: 'localhost:5002'
: window.location.host;
return host;
Expand Down
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 17d5c16

Please sign in to comment.