remove hard coded vega wallet auth values
This commit is contained in:
parent
77214d5427
commit
4bcafea969
@ -1,3 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { RestConnector } from '.';
|
||||
|
||||
@ -15,17 +16,13 @@ export function RestConnectorForm({
|
||||
connector,
|
||||
onAuthenticate,
|
||||
}: RestConnectorFormProps) {
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm<FormFields>({
|
||||
// TODO: Remove default values
|
||||
defaultValues: {
|
||||
wallet: 'matt',
|
||||
passphrase: '123',
|
||||
},
|
||||
});
|
||||
} = useForm<FormFields>();
|
||||
|
||||
async function onSubmit(fields: FormFields) {
|
||||
try {
|
||||
@ -40,30 +37,45 @@ export function RestConnectorForm({
|
||||
throw new Error('Authentication failed');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
if (err instanceof Error) {
|
||||
setError(err);
|
||||
} else if (typeof err === 'string') {
|
||||
setError(new Error(err));
|
||||
} else {
|
||||
setError(new Error('Something went wrong'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div style={{ marginBottom: 10 }}>
|
||||
<div className="mb-12">
|
||||
<input
|
||||
className="w-full px-8 py-2 border-black border"
|
||||
{...register('wallet', { required: 'Required' })}
|
||||
type="text"
|
||||
placeholder="Wallet"
|
||||
/>
|
||||
{errors.wallet?.message && <div>{errors.wallet.message}</div>}
|
||||
{errors.wallet?.message && (
|
||||
<div className="mt-4 text-sm text-intent-danger">
|
||||
{errors.wallet.message}
|
||||
</div>
|
||||
<div style={{ marginBottom: 10 }}>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-12">
|
||||
<input
|
||||
className="w-full px-8 py-2 border-black border"
|
||||
{...register('passphrase', { required: 'Required' })}
|
||||
type="text"
|
||||
type="password"
|
||||
placeholder="Passphrase"
|
||||
/>
|
||||
{errors.passphrase?.message && <div>{errors.passphrase.message}</div>}
|
||||
{errors.passphrase?.message && (
|
||||
<div className="mt-4 text-sm text-intent-danger">
|
||||
{errors.passphrase.message}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{error && <div className="mb-12 text-intent-danger">{error.message}</div>}
|
||||
<button type="submit" className="rounded-sm bg-pink text-white py-4 px-8">
|
||||
Connect
|
||||
</button>
|
||||
|
Loading…
Reference in New Issue
Block a user