Skip to content

Commit

Permalink
feat start shipyard
Browse files Browse the repository at this point in the history
  • Loading branch information
AkekoChan committed Jan 12, 2024
1 parent 836f034 commit 023bd8c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/ship/market/Market.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ const Market = ({ data }) => {
))
) : (
<tr>
<td>Loading...</td>
<td colSpan={3}>Loading...</td>
</tr>
)
) : (
<tr>
<td>No Marketplace</td>
<td colSpan={3}>No Marketplace</td>
</tr>
)}
</tbody>
Expand Down
8 changes: 7 additions & 1 deletion src/components/ship/shipyard/Shipyard.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from "react";
import React, { useState, useEffect } from "react";

import { useShipContext } from "../../../context/shipContext";
import { useAuthContext } from "../../../context/authContext";

import "./shipyard.css";
const Shipyard = () => {
const { shipyard, getShipyard } = useShipContext();
const { agent } = useAuthContext();
return <div>Shipyard</div>;
};

Expand Down
2 changes: 0 additions & 2 deletions src/components/ship/state/State.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ const State = ({ data }) => {
fetchData();
}, [data.symbol]);

console.log(isFull);

const handleClickRefuel = async () => {
if (isFull || isDocked === "IN_ORBIT" || isDocked === "IN_TRANSIT") {
return;
Expand Down
19 changes: 19 additions & 0 deletions src/context/shipContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const ShipContextProvider = ({ children }) => {
const [cargo, setCargo] = useState();
const [fuel, setFuel] = useState();
const [market, setMarket] = useState([]);
const [shipyard, setShipyard] = useState();

const updateShipData = async (options) => {
try {
Expand Down Expand Up @@ -232,6 +233,24 @@ export const ShipContextProvider = ({ children }) => {
}
};

const getShipyard = async (systemSymbol, waypointSymbol) => {
const options = {
endpoint: `systems/${systemSymbol}/waypoints/${waypointSymbol}/shipyard`,
method: "GET",
headers: {
Accept: "application/json",
Authorization: `Bearer ${userToken}`,
},
};
try {
const response = await fetchData(options);
setShipyard(response);
return response;
} catch (error) {
console.error(error);
}
};

const contextValue = {
dockShip,
orbitShip,
Expand Down

0 comments on commit 023bd8c

Please sign in to comment.