Skip to content

Commit 22b9d65

Browse files
committed
api update
1 parent 5d45c7e commit 22b9d65

12 files changed

Lines changed: 8308 additions & 10246 deletions

File tree

src/app/features/Shipinfo/ShipControlCenter.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,13 @@ function ShipControlCenter({
259259
flightMode: value,
260260
}).then((value) => {
261261
dispatch(
262-
setShipNav({ symbol: ship.symbol, nav: value.data.data }),
262+
setShipNav({ symbol: ship.symbol, nav: value.data.data.nav }),
263+
);
264+
dispatch(
265+
setShipFuel({
266+
symbol: ship.symbol,
267+
fuel: value.data.data.fuel,
268+
}),
263269
);
264270
});
265271
}}

src/app/features/Shipinfo/ShipNavInfo.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,16 @@ function ShipNavInfo({ ship }: { ship: Ship }) {
168168
flightMode: value,
169169
}).then((value) => {
170170
dispatch(
171-
setShipNav({ symbol: ship.symbol, nav: value.data.data }),
171+
setShipNav({
172+
symbol: ship.symbol,
173+
nav: value.data.data.nav,
174+
}),
175+
);
176+
dispatch(
177+
setShipFuel({
178+
symbol: ship.symbol,
179+
fuel: value.data.data.fuel,
180+
}),
172181
);
173182
setLoadingShipNav(false);
174183
});

src/app/features/addAgent/createAgent.tsx

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
import type { FormProps } from "antd";
22
import {
3-
Form,
4-
Input,
5-
Select,
6-
Space,
73
Button,
8-
Result,
94
Card,
105
Divider,
116
Flex,
7+
Form,
8+
Input,
9+
Result,
10+
Select,
11+
Space,
1212
Typography,
1313
} from "antd";
14+
import { useState } from "react";
15+
import { useAppDispatch } from "../../hooks";
16+
import type { Register201ResponseData } from "../../spaceTraderAPI/api";
17+
import { FactionSymbol } from "../../spaceTraderAPI/api";
18+
import { addAgent, setMyAgent } from "../../spaceTraderAPI/redux/agentSlice";
19+
import { setAgentSymbol } from "../../spaceTraderAPI/redux/configSlice";
20+
import { putContract } from "../../spaceTraderAPI/redux/contractSlice";
21+
import { setShips } from "../../spaceTraderAPI/redux/fleetSlice";
22+
import spaceTraderClient from "../../spaceTraderAPI/spaceTraderClient";
1423
import AgentDisp from "../disp/AgentDisp";
1524
import ContractDisp from "../disp/ContractDisp";
1625
import FactionDisp from "../disp/FactionDisp";
1726
import ShipDisp from "../disp/ship/ShipDisp";
18-
import { addAgent, setMyAgent } from "../../spaceTraderAPI/redux/agentSlice";
19-
import { putContract } from "../../spaceTraderAPI/redux/contractSlice";
20-
import { setShip } from "../../spaceTraderAPI/redux/fleetSlice";
21-
import spaceTraderClient from "../../spaceTraderAPI/spaceTraderClient";
22-
import { useState } from "react";
23-
import type {
24-
FactionSymbol,
25-
Register201ResponseData,
26-
} from "../../spaceTraderAPI/api";
27-
import { useAppDispatch } from "../../hooks";
28-
import { setAgentSymbol } from "../../spaceTraderAPI/redux/configSlice";
2927

3028
type createAgentType = {
3129
callsign: string;
3230
email?: string;
3331
faction: FactionSymbol;
32+
accountToken: string;
3433
};
3534

3635
const tailLayout = {
@@ -55,15 +54,15 @@ function CreateAgent() {
5554
const onCreate: FormProps<createAgentType>["onFinish"] = (values) => {
5655
console.log("Success:", values);
5756

58-
spaceTraderClient.DefaultClient.register(
57+
spaceTraderClient.GlobalClient.register(
5958
{
6059
symbol: values.callsign,
6160
faction: values.faction,
6261
email: values.email,
6362
},
6463
{
6564
transformRequest: (data, headers) => {
66-
delete headers["Authorization"];
65+
headers["Authorization"] = `Bearer ${values.accountToken}`;
6766
return data;
6867
},
6968
},
@@ -84,7 +83,7 @@ function CreateAgent() {
8483
agentSymbol: answer.data.data.agent.symbol,
8584
}),
8685
);
87-
dispatch(setShip(answer.data.data.ship));
86+
dispatch(setShips(answer.data.data.ships || []));
8887
});
8988
};
9089

@@ -98,6 +97,13 @@ function CreateAgent() {
9897
name="createAgent"
9998
style={{ maxWidth: 600 }}
10099
>
100+
<Form.Item
101+
name="accountToken"
102+
label="AccountToken"
103+
rules={[{ required: true }]}
104+
>
105+
<Input placeholder="Enter a AccountToken" />
106+
</Form.Item>
101107
<Form.Item
102108
name="callsign"
103109
label="Callsign"
@@ -121,27 +127,12 @@ function CreateAgent() {
121127
<Select
122128
placeholder="Select a faction"
123129
allowClear
124-
options={[
125-
{ value: "COSMIC", label: "COSMIC" },
126-
{ value: "VOID", label: "VOID" },
127-
{ value: "GALACTIC", label: "GALACTIC" },
128-
{ value: "QUANTUM", label: "QUANTUM" },
129-
{ value: "DOMINION", label: "DOMINION" },
130-
{ value: "ASTRO", label: "ASTRO" },
131-
{ value: "CORSAIRS", label: "CORSAIRS" },
132-
{ value: "OBSIDIAN", label: "OBSIDIAN" },
133-
{ value: "AEGIS", label: "AEGIS" },
134-
{ value: "UNITED", label: "UNITED" },
135-
{ value: "SOLITARY", label: "SOLITARY" },
136-
{ value: "COBALT", label: "COBALT" },
137-
{ value: "OMEGA", label: "OMEGA" },
138-
{ value: "ECHO", label: "ECHO" },
139-
{ value: "LORDS", label: "LORDS" },
140-
{ value: "CULT", label: "CULT" },
141-
{ value: "ANCIENTS", label: "ANCIENTS" },
142-
{ value: "SHADOW", label: "SHADOW" },
143-
{ value: "ETHEREAL", label: "ETHEREAL" },
144-
]}
130+
options={Object.values(FactionSymbol).map((value) => {
131+
return {
132+
label: value,
133+
value: value,
134+
};
135+
})}
145136
></Select>
146137
</Form.Item>
147138
<Form.Item {...tailLayout}>
@@ -172,7 +163,9 @@ function CreateAgent() {
172163
<Flex wrap gap="middle" align="center" justify="space-evenly">
173164
<AgentDisp agent={newAgent.agent}></AgentDisp>
174165
<FactionDisp faction={newAgent.faction}></FactionDisp>
175-
<ShipDisp ship={newAgent.ship}></ShipDisp>
166+
{(newAgent.ships || []).map((ship) => (
167+
<ShipDisp ship={ship}></ShipDisp>
168+
))}
176169
<ContractDisp contract={newAgent.contract}></ContractDisp>
177170
</Flex>
178171
</Card>,

src/app/features/automation/runner/Navigator.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,14 @@ function Navigator({ ship }: { ship: Ship }) {
127127
dispatch(
128128
setShipNav({
129129
symbol: ship.symbol,
130-
nav: patch.data.data,
130+
nav: patch.data.data.nav,
131+
}),
132+
);
133+
134+
dispatch(
135+
setShipFuel({
136+
symbol: ship.symbol,
137+
fuel: patch.data.data.fuel,
131138
}),
132139
);
133140

src/app/features/automation/runner/SimpleTrader.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,13 @@ function SimpleTrader({ ship }: { ship: Ship }) {
344344
dispatch(
345345
setShipNav({
346346
symbol: ship.symbol,
347-
nav: patch.data.data,
347+
nav: patch.data.data.nav,
348+
}),
349+
);
350+
dispatch(
351+
setShipFuel({
352+
symbol: ship.symbol,
353+
fuel: patch.data.data.fuel,
348354
}),
349355
);
350356
}

src/app/sites/main/Main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import spaceTraderClient from "../../spaceTraderAPI/spaceTraderClient";
1818
function Main() {
1919
const [status, setStatus] = useState<GetStatus200Response | null>(null);
2020
useEffect(() => {
21-
spaceTraderClient.DefaultClient.getStatus().then((response) => {
21+
spaceTraderClient.GlobalClient.getStatus().then((response) => {
2222
console.log("response", response);
2323
setStatus(response.data);
2424
});

0 commit comments

Comments
 (0)