From f602511fe44aa6a48cd78496c5213f245665f419 Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Sun, 2 Jun 2024 22:43:37 -0700 Subject: [PATCH] fix robot page --- .../src/components/auth/AuthComponent.tsx | 4 +- frontend/src/pages/RobotDetails.tsx | 62 ++----------------- store/app/api/routers/main.py | 20 ++++-- 3 files changed, 22 insertions(+), 64 deletions(-) diff --git a/frontend/src/components/auth/AuthComponent.tsx b/frontend/src/components/auth/AuthComponent.tsx index 921ba596..046c0f04 100644 --- a/frontend/src/components/auth/AuthComponent.tsx +++ b/frontend/src/components/auth/AuthComponent.tsx @@ -5,7 +5,7 @@ import GoogleAuthComponent from "./GoogleAuthComponent"; const AuthComponent = () => { return ( <> - + {/* @@ -14,7 +14,7 @@ const AuthComponent = () => { - + */} ); }; diff --git a/frontend/src/pages/RobotDetails.tsx b/frontend/src/pages/RobotDetails.tsx index 4d135c70..d0d77189 100644 --- a/frontend/src/pages/RobotDetails.tsx +++ b/frontend/src/pages/RobotDetails.tsx @@ -23,6 +23,8 @@ interface RobotDetailsResponse { } const RobotDetails = () => { + const navigate = useNavigate(); + const { id } = useParams(); const [show, setShow] = useState(false); const [robot, setRobot] = useState(null); @@ -67,65 +69,9 @@ const RobotDetails = () => { } const response: RobotDetailsResponse = robot; - // This is a placeholder before the backend is hooked up. - // const response: RobotDetailsResponse = { - // name: "Stompy", - // owner: "K-Scale Labs", - // description: `Stompy is an open-source humanoid robot that anyone can 3D print. - - // ## Purpose - - // Stompy is designed to be a versatile platform for research and development in legged robotics. - - // ## Links - - // - [Wiki Entry](https://humanoids.wiki/w/Stompy) - - // ### Full Body Sim Artifacts - - // - [URDF (with STLs)](https://media.kscale.dev/stompy/latest_stl_urdf.tar.gz) - // - [URDF (with OBJs)](https://media.kscale.dev/stompy/latest_obj_urdf.tar.gz) - // - [MJCF](https://media.kscale.dev/stompy/latest_mjcf.tar.gz) - - // ### Single Arm Sim Artifacts - - // - [URDF (with STLs)](https://media.kscale.dev/stompy/arm_latest_stl_urdf.tar.gz) - // - [URDF (with OBJs)](https://media.kscale.dev/stompy/arm_latest_obj_urdf.tar.gz) - // - [MJCF](https://media.kscale.dev/stompy/arm_latest_mjcf.tar.gz) - // `, - // images: [ - // { - // url: "https://media.robolist.xyz/stompy.png", - // caption: "Stompy the robot 1", - // }, - // { - // url: "https://media.robolist.xyz/stompy.png", - // caption: "Stompy the robot 2", - // }, - // { - // url: "https://media.robolist.xyz/stompy.png", - // caption: "Stompy the robot 3", - // }, - // ], - // bom: [ - // { - // name: "Actuator", - // id: "1234", - // quantity: 10, - // price: 100, - // }, - // { - // name: "Sensor", - // id: "5678", - // quantity: 5, - // price: 50, - // }, - // ], - // }; const { name, owner, description, images } = robot; - const navigate = useNavigate(); return ( <> @@ -240,7 +186,7 @@ const RobotDetails = () => { )} - { - + } ); }; diff --git a/store/app/api/routers/main.py b/store/app/api/routers/main.py index 5a613ce2..45b7b3d2 100644 --- a/store/app/api/routers/main.py +++ b/store/app/api/routers/main.py @@ -1,7 +1,7 @@ """Defines the main API endpoint.""" import logging -from typing import Union +from typing import List,Union import boto3 from botocore.exceptions import ClientError @@ -22,20 +22,32 @@ # Configure your DynamoDB client dynamodb = boto3.resource( "dynamodb", - region_name="us-east-1", # Replace with your AWS region - aws_access_key_id="something", # Replace with your AWS access key - aws_secret_access_key="something", # Replace with your AWS secret key + # region_name="us-east-1", # Replace with your AWS region + # aws_access_key_id="something", # Replace with your AWS access key + # aws_secret_access_key="something", # Replace with your AWS secret key ) # Replace 'Robots' with your DynamoDB table name table = dynamodb.Table("Robots") +class Bom(BaseModel): + name: str + id: str + quantity: int + price: float + + +class Image(BaseModel): + url: str + caption: str class Robot(BaseModel): robot_id: str name: str description: str owner: str + bom: List[Bom] + images: List[Image] @api_router.get("/robots/{robot_id}", response_model=Robot)