feat: autosubmit
This commit is contained in:
parent
0a753b36d0
commit
bb6d584ed2
@ -5,13 +5,13 @@ import { QRCodeSVG } from 'qrcode.react';
|
|||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
const [word, setWord] = useState('');
|
const [word, setWord] = useState('');
|
||||||
const [qrCode, setQrCode] = useState('');
|
|
||||||
|
|
||||||
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setQrCode(constructAddWordUiCommand({ word, contractId: import.meta.env.VITE_CONTRACT_ADDRESS ?? '' }));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const qrCode = constructAddWordUiCommand({ word, contractId: import.meta.env.VITE_CONTRACT_ADDRESS ?? '' });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<form onSubmit={onSubmit}>
|
<form onSubmit={onSubmit}>
|
||||||
@ -28,15 +28,10 @@ export const App = () => {
|
|||||||
value={word}
|
value={word}
|
||||||
onChange={(e) => setWord(e.target.value)}
|
onChange={(e) => setWord(e.target.value)}
|
||||||
/>
|
/>
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
className="w-full self-end rounded-lg bg-blue-700 px-5 py-2.5 text-center text-sm font-medium text-white hover:bg-blue-800 focus:outline-none focus:ring-4 focus:ring-blue-300 sm:w-auto dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
|
||||||
>
|
|
||||||
Submit
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div className="flex w-full justify-center py-4">
|
<div className="flex w-full justify-center py-4">
|
||||||
|
{word && (
|
||||||
<QRCodeSVG
|
<QRCodeSVG
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText(qrCode).catch((err) => {
|
navigator.clipboard.writeText(qrCode).catch((err) => {
|
||||||
@ -50,6 +45,7 @@ export const App = () => {
|
|||||||
bgColor="transparent"
|
bgColor="transparent"
|
||||||
fgColor="black"
|
fgColor="black"
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user