Skip to content

Commit fdbb36e

Browse files
committed
ui: move command send together
1 parent dcad967 commit fdbb36e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/ui/app/pages/Commands.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { notifications } from '@mantine/notifications';
55
export default function Commands() {
66
const [command, setCommand] = React.useState('');
77

8-
const operation = async (op: string) => {
8+
const operation = async (op: string, withCommand = false) => {
99
try {
1010
const res = await (await fetch('/commands', {
1111
method: 'POST',
1212
headers: { 'Content-Type': 'application/json' },
13-
body: JSON.stringify({ operation: op }),
13+
body: JSON.stringify({ operation: op, command: withCommand ? command : undefined }),
1414
})).json();
1515
if (res.error) {
1616
notifications.show({ title: 'Error', message: `${res.error.message}(${res.error.params})`, color: 'red' });
@@ -36,7 +36,7 @@ export default function Commands() {
3636
onChange={(ev) => setCommand(ev.target.value)}
3737
/>
3838
<Group justify="center" my="md">
39-
<Button onClick={() => fetch('/commands', { method: 'POST', body: JSON.stringify({ command, operation: 'command' }) })}>Send</Button>
39+
<Button onClick={() => operation('command', true)}>Send</Button>
4040
</Group>
4141
<Divider my="md" />
4242
<Title order={3}>Quick Commands</Title>

0 commit comments

Comments
 (0)