diff --git a/frontend/src/hooks/api.tsx b/frontend/src/hooks/api.tsx index 60df89c1..eda505ab 100644 --- a/frontend/src/hooks/api.tsx +++ b/frontend/src/hooks/api.tsx @@ -25,6 +25,9 @@ export interface Robot { owner: string; bom: Bom[]; images: Image[]; + height: string; + weight: string; + degrees_of_freedom: string; } export class api { diff --git a/frontend/src/pages/EditRobotForm.tsx b/frontend/src/pages/EditRobotForm.tsx index dfefc0dc..fae11a69 100644 --- a/frontend/src/pages/EditRobotForm.tsx +++ b/frontend/src/pages/EditRobotForm.tsx @@ -17,6 +17,9 @@ const EditRobotForm: React.FC = () => { const [message, setMessage] = useState(null); const [robot_name, setName] = useState(""); const [robot_description, setDescription] = useState(""); + const [robot_height, setHeight] = useState(""); + const [robot_weight, setWeight] = useState(""); + const [robot_degrees_of_freedom, setDof] = useState(""); const [robot_bom, setBom] = useState([]); const [robot_images, setImages] = useState([]); const [parts, setParts] = useState([]); @@ -33,6 +36,9 @@ const EditRobotForm: React.FC = () => { setBom(robotData.bom); setImages(robotData.images); setRobotId(robotData.robot_id); + setHeight(robotData.height); + setWeight(robotData.weight); + setDof(robotData.degrees_of_freedom); } catch (err) { addAlert(humanReadableError(err), "error"); } @@ -96,6 +102,9 @@ const EditRobotForm: React.FC = () => { owner: "", bom: robot_bom, images: robot_images, + height: robot_height, + weight: robot_weight, + degrees_of_freedom: robot_degrees_of_freedom, }; try { await auth_api.editRobot(newFormData); @@ -134,6 +143,36 @@ const EditRobotForm: React.FC = () => { value={robot_name} required /> + Height: + { + setHeight(e.target.value); + }} + value={robot_height} + /> + Weight: + { + setWeight(e.target.value); + }} + value={robot_weight} + /> + Total Degrees of Freedom: + { + setDof(e.target.value); + }} + value={robot_degrees_of_freedom} + /> Description: { description: robot?.description, images: robot?.images, bom: robot?.bom, + height: robot?.height, + weight: robot?.weight, + degrees_of_freedom: robot?.degrees_of_freedom, }; const { name, description, images } = response; @@ -151,6 +157,31 @@ const RobotDetails = () => { {ownerEmail} + {((response.height && response.height !== "") || + (response.weight && response.weight !== "") || + (response.degrees_of_freedom && + response.degrees_of_freedom !== "")) && ( + <> +
+ {response.height !== "" && ( +

+ Height: {response.height} +

+ )} + {response.weight !== "" && ( +

+ Weight: + {response.weight} +

+ )} + {response.degrees_of_freedom !== "" && ( +

+ Total Degrees of Freedom:{" "} + {response.degrees_of_freedom} +

+ )} + + )}
diff --git a/frontend/src/pages/RobotForm.tsx b/frontend/src/pages/RobotForm.tsx index 5447bfcb..a9abc427 100644 --- a/frontend/src/pages/RobotForm.tsx +++ b/frontend/src/pages/RobotForm.tsx @@ -9,6 +9,9 @@ const RobotForm: React.FC = () => { const auth_api = new api(auth.api); const [message, setMessage] = useState(null); const [robot_name, setName] = useState(""); + const [robot_height, setHeight] = useState(""); + const [robot_weight, setWeight] = useState(""); + const [robot_degrees_of_freedom, setDof] = useState(""); const [robot_description, setDescription] = useState(""); const [robot_bom, setBom] = useState([]); const [robot_images, setImages] = useState([]); @@ -70,6 +73,9 @@ const RobotForm: React.FC = () => { owner: "", bom: robot_bom, images: robot_images, + height: robot_height, + weight: robot_weight, + degrees_of_freedom: robot_degrees_of_freedom, }; try { await auth_api.addRobot(newFormData); @@ -108,6 +114,36 @@ const RobotForm: React.FC = () => { value={robot_name} required /> + Height: + { + setHeight(e.target.value); + }} + value={robot_height} + /> + Weight: + { + setWeight(e.target.value); + }} + value={robot_weight} + /> + Total Degrees of Freedom: + { + setDof(e.target.value); + }} + value={robot_degrees_of_freedom} + /> Description: