diff --git a/packages/react-app/src/assets/images/icon-chart.png b/packages/react-app/src/assets/images/icon-chart.png
new file mode 100644
index 00000000..2ff98f13
Binary files /dev/null and b/packages/react-app/src/assets/images/icon-chart.png differ
diff --git a/packages/react-app/src/assets/images/icon-globe.svg b/packages/react-app/src/assets/images/icon-globe.svg
new file mode 100644
index 00000000..038b46f9
--- /dev/null
+++ b/packages/react-app/src/assets/images/icon-globe.svg
@@ -0,0 +1,3 @@
+
diff --git a/packages/react-app/src/components/Header.tsx b/packages/react-app/src/components/Header.tsx
index 04d1db7d..986b6db8 100644
--- a/packages/react-app/src/components/Header.tsx
+++ b/packages/react-app/src/components/Header.tsx
@@ -1,14 +1,20 @@
import React from "react";
import { ConnectWalletButton, SearchPlots } from ".";
-
+import { ParcelInfoContainer } from "../containers";
interface Props {
connectWallet: () => void;
}
-export default function Header({ connectWallet }: Props) {
+export default function Header({ connectWallet }: Props): JSX.Element {
return (
-
-
-
+
);
}
diff --git a/packages/react-app/src/components/ParcelInfo.tsx b/packages/react-app/src/components/ParcelInfo.tsx
new file mode 100644
index 00000000..28873997
--- /dev/null
+++ b/packages/react-app/src/components/ParcelInfo.tsx
@@ -0,0 +1,75 @@
+import React from "react";
+import { timesAgo, tsToDate } from "../utils";
+import IconChart from "../assets/images/icon-chart.png";
+import IconGlobe from "../assets/images/icon-globe.svg";
+interface SensorData {
+ snr: number;
+ vbat: number;
+ latitude: number;
+ longitude: number;
+ gas_resistance: number;
+ temperature: number;
+ pressure: number;
+ humidity: number;
+ light: number;
+ temperature2: number;
+ gyroscope: [number, number, number];
+ accelerometer: [number, number, number];
+ timestamp: string;
+ random: string;
+}
+interface Props {
+ sensorData: SensorData;
+}
+interface DataBoxProps {
+ value: string;
+ label: string;
+ unit?: string;
+}
+function DataBox({ value, label, unit }: DataBoxProps): JSX.Element {
+ return (
+
+
+

+
+ );
+}
+export default function ParcelInfo({ sensorData }: Props): JSX.Element {
+ const { temperature, pressure, humidity, gas_resistance, timestamp, latitude, longitude } = sensorData;
+ const localisedTime = new Date().toLocaleTimeString("en-US", {
+ timeZone: "America/Denver",
+ hour: "2-digit",
+ minute: "2-digit",
+ });
+ const fetchedTime = tsToDate(timestamp);
+
+ return (
+
+
+

+
+ {latitude}, {longitude}
+
+ BENNET CREEK ROAD, POWELL WYOMING 82435
+
+
+
It’s currently {localisedTime}
[-7 GMT] -------------- Last transmissoin
+ ~{timesAgo(fetchedTime)} ago{" "}
+
+ view on MachineFi
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/packages/react-app/src/components/index.ts b/packages/react-app/src/components/index.ts
index 96edb57c..26f98646 100644
--- a/packages/react-app/src/components/index.ts
+++ b/packages/react-app/src/components/index.ts
@@ -12,3 +12,4 @@ export { default as LogoDisplay } from "./LogoDisplay";
export { default as Header } from "./Header";
export { default as ConnectWalletButton } from "./ConnectWalletButton";
export { default as SearchPlots } from "./SearchPlots";
+export { default as ParcelInfo } from "./ParcelInfo";
diff --git a/packages/react-app/src/containers/ParcelInfoContainer.tsx b/packages/react-app/src/containers/ParcelInfoContainer.tsx
new file mode 100644
index 00000000..c8d0d29c
--- /dev/null
+++ b/packages/react-app/src/containers/ParcelInfoContainer.tsx
@@ -0,0 +1,43 @@
+import React from "react";
+import { gql, useQuery, InMemoryCache, ApolloClient } from "@apollo/client";
+import { ParcelInfo } from "../components";
+
+const PEBBLE_DEVICE_ID = "351358813276802";
+const pebbleUri = "https://pebble.iotex.me/v1/graphql";
+
+const pebbleClient = new ApolloClient({
+ uri: pebbleUri,
+ cache: new InMemoryCache(),
+});
+
+const GET_SENSOR_DATA = gql`
+ query getDevices($deviceId: String!) {
+ pebble_device_record(
+ limit: 1
+ order_by: { timestamp: desc }
+ where: { imei: { _eq: $deviceId }, latitude: { _neq: "200.0000000" } }
+ ) {
+ temperature
+ humidity
+ gas_resistance
+ pressure
+ latitude
+ longitude
+ timestamp
+ }
+ }
+`;
+
+function ParcelInfoContainer(): JSX.Element {
+ const { loading, error, data } = useQuery(GET_SENSOR_DATA, {
+ variables: { deviceId: PEBBLE_DEVICE_ID },
+ client: pebbleClient,
+ });
+ if (loading) return
Sensor Data Loading ...
;
+ if (error) console.log(error);
+ if (error) return
Sensor Data Load Failed.
;
+ console.log(data?.pebble_device_record[0]);
+ return
;
+}
+
+export default ParcelInfoContainer;
diff --git a/packages/react-app/src/containers/index.ts b/packages/react-app/src/containers/index.ts
new file mode 100644
index 00000000..6cd0c774
--- /dev/null
+++ b/packages/react-app/src/containers/index.ts
@@ -0,0 +1 @@
+export { default as ParcelInfoContainer } from "./ParcelInfoContainer"
\ No newline at end of file
diff --git a/packages/react-app/src/utils.ts b/packages/react-app/src/utils.ts
new file mode 100644
index 00000000..27ae6c0c
--- /dev/null
+++ b/packages/react-app/src/utils.ts
@@ -0,0 +1,38 @@
+export function tsToDate(ts: string): Date {
+ return new Date(Number(ts) * 1000);
+}
+
+export function timesAgo(date: Date): string { // source: https://stackoverflow.com/a/55999110/458679
+ const seconds = Math.floor((+new Date() - +date) / 1000); // get the diffrence of date object sent with current date time of the system time
+ let interval = Math.floor(seconds / 31536000); // divide seconds by seconds in avg for a year to get years
+
+ //conditioning based on years derived above
+ if (interval > 1) {
+ return interval + " years";
+ }
+ interval = Math.floor(seconds / 2592000); // months check similar to years
+ if (interval > 1) {
+ return interval + " months";
+ }
+ interval = Math.floor(seconds / 86400); // days check similar to above
+ if (interval > 1) {
+ return interval + " days";
+ }
+ interval = Math.floor(seconds / 3600); // hours check
+ if (interval > 1) {
+ return interval + " hours";
+ }
+ interval = Math.floor(seconds / 60); // minutes check
+ if (interval > 1) {
+ return interval + " min";
+ }
+ return Math.floor(seconds) + " seconds"; // seconds check at the end
+}
+
+// withYears 22 years
+// withMonths 9 months
+// withDays 5 days
+// withPreviousDay 24 hours
+// withHours 2 hours
+// withMinutes 5 min
+
diff --git a/packages/react-app/src/views/BrowsePlots.tsx b/packages/react-app/src/views/BrowsePlots.tsx
index 9a48f37e..691a9bce 100644
--- a/packages/react-app/src/views/BrowsePlots.tsx
+++ b/packages/react-app/src/views/BrowsePlots.tsx
@@ -123,7 +123,7 @@ export default function BrowsePlots({ networkProvider, web3Modal }: Props) {
return (
<>
-
+ {/*
*/}
diff --git a/packages/react-app/tailwind.config.js b/packages/react-app/tailwind.config.js
index 6b5ea366..b9845564 100644
--- a/packages/react-app/tailwind.config.js
+++ b/packages/react-app/tailwind.config.js
@@ -7,8 +7,24 @@ module.exports = {
base: "14px",
lg: "16px",
xl: "20px",
+ xxl: "28px",
+ },
+ extend: {
+ colors: {
+ "green-0": "rgba(153, 248, 181, 0.5)",
+ "green-1": "#00FFA8",
+ "green-2": "#038B5C",
+ },
+ lineHeight: {
+ 2: "10px",
+ },
+ padding: {
+ "50px": "50px",
+ },
+ maxWidth: {
+ "750px": "750px",
+ },
},
- extend: {},
},
variants: {
extend: {},
diff --git a/yarn.lock b/yarn.lock
index 54ac3434..63c00217 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2984,6 +2984,11 @@
"@types/minimatch" "*"
"@types/node" "*"
+"@types/history@^4.7.11":
+ version "4.7.11"
+ resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.11.tgz#56588b17ae8f50c53983a524fc3cc47437969d64"
+ integrity sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==
+
"@types/hoist-non-react-statics@^3.3.0":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f"
@@ -3159,6 +3164,23 @@
hoist-non-react-statics "^3.3.0"
redux "^4.0.0"
+"@types/react-router-dom@^5.3.2":
+ version "5.3.3"
+ resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.3.3.tgz#e9d6b4a66fcdbd651a5f106c2656a30088cc1e83"
+ integrity sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw==
+ dependencies:
+ "@types/history" "^4.7.11"
+ "@types/react" "*"
+ "@types/react-router" "*"
+
+"@types/react-router@*":
+ version "5.1.18"
+ resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.18.tgz#c8851884b60bc23733500d86c1266e1cfbbd9ef3"
+ integrity sha512-YYknwy0D0iOwKQgz9v8nOzt2J6l4gouBmDnWqUUznltOTaon+r8US8ky8HvN0tXvc38U9m6z/t2RsVsnd1zM0g==
+ dependencies:
+ "@types/history" "^4.7.11"
+ "@types/react" "*"
+
"@types/react@*":
version "17.0.19"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.19.tgz#8f2a85e8180a43b57966b237d26a29481dacc991"