-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
35 lines (30 loc) · 934 Bytes
/
index.tsx
File metadata and controls
35 lines (30 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { useHistory } from "../hooks/useHistory";
import { useSelectedServer } from "../hooks/useSelectedServer";
import { runAppMethod } from "@robinplatform/toolkit";
import { useMutation } from "@tanstack/react-query";
import React from "react";
import { z } from "zod";
export const ControlPanel: React.FC = () => {
const { selectedServer } = useSelectedServer();
const history = useHistory();
const { mutate } = useMutation<null, unknown, void, [string]>({
mutationKey: ["StartServer", selectedServer],
mutationFn: async (): Promise<null> => {
await runAppMethod({
methodName: "StartServer",
resultType: z.any(),
data: {
server: selectedServer,
},
});
return null;
},
});
return (
<div className='serverControlPanel'>
<h1 className='serverControlPanelHeading'>{selectedServer}</h1>
<p>{history.pathname}</p>
<button onClick={() => mutate()}>Start</button>
</div>
);
};