summaryrefslogtreecommitdiff
path: root/src/components/ObjectView.js
diff options
context:
space:
mode:
authorErnst Widerberg <ernstwi@kth.se>2021-10-06 16:11:06 +0200
committerErnst Widerberg <ernstwi@kth.se>2021-10-06 16:11:06 +0200
commit46b9df3279f51479cfc607cbce8fb8b73bef69f7 (patch)
treeddca9489ce2779c5c7c23938cb5e666387ace775 /src/components/ObjectView.js
Initial commit
Diffstat (limited to 'src/components/ObjectView.js')
-rw-r--r--src/components/ObjectView.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/components/ObjectView.js b/src/components/ObjectView.js
new file mode 100644
index 0000000..4a04c93
--- /dev/null
+++ b/src/components/ObjectView.js
@@ -0,0 +1,46 @@
+import React from "react";
+
+import ObjectComponent from "./ObjectComponent";
+
+class ObjectView extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ object: null
+ };
+
+ this.getData = this.getData.bind(this);
+ }
+
+ componentDidMount() {
+ this.getData();
+ }
+
+ getData() {
+ fetch("http://localhost:8000/sc/v0/get", {
+ headers: {
+ Authorization: "Basic " + btoa("user1:pw1")
+ }
+ })
+ .then(resp => resp.json())
+ // TODO: Proper API call to get single object
+ .then(data => data.filter(x => x._id == this.props.id)[0])
+ // .then(data => {
+ // console.log(data);
+ // return data;
+ // })
+ .then(object => this.setState({ object: object }));
+ }
+
+ render() {
+ return (
+ <div id="object-view">
+ {this.state.object === null ? null : (
+ <ObjectComponent {...this.state.object} />
+ )}
+ </div>
+ );
+ }
+}
+
+export default ObjectView;