diff --git a/components/cards/ChartCard.js b/components/cards/ChartCard.js new file mode 100644 index 0000000..15702b9 --- /dev/null +++ b/components/cards/ChartCard.js @@ -0,0 +1,101 @@ +import { observer } from 'mobx-react-lite'; +import { Line } from 'react-chartjs-2'; +import styled from 'styled-components'; +import propTypes from "prop-types"; +import Theme from '../../styles/theme'; +import useTabs from '../../utils/useTabs'; + +const Container = styled.div` + padding: 1.5rem; + border-radius: ${props => props.theme.radiusMin}; + background: ${props => props.theme.darkLight}; +` + +const Row = styled.div` + display: flex; + align-items: center; +` + +const RowCenter = styled(Row)` + justify-content: space-between; + margin-top: 1.5rem; +` + +const Type = styled.h4` +` + +const MeasuredByType = styled.p` + font-style: italic; + align-self: flex-end; +` + +const NoWrap = styled.p` + white-space: nowrap; +` + +function ChartCard({ expectedQuantityType, peripheral, measurements }) { + const { currentTab, Tabs } = useTabs(["1 hour", "3 hours", "1 day"]); + const quantityType = peripheral.details.quantityTypes.find(quantityType => quantityType.id === expectedQuantityType); + console.log(measurements) + + return ( + + + {quantityType?.physicalQuantity || "-"} + + + +
+ +
+ Measured by {peripheral?.name || "-"} +
+ + measurement.values.minimum), + fill: true, + backgroundColor: Theme.primaryTransparent, + }, + { + label: "Average", + data: measurements + .map(measurement => measurement.values.average), + fill: true, + backgroundColor: Theme.primarySemiTransparent + }, + { + label: "Maximum", + data: measurements + .map(measurement => measurement.values.maximum), + fill: true, + backgroundColor: Theme.primary + } + ] + }} + /> + +
+ ) +} + +ChartCard.propTypes = { + color: propTypes.string, + expectedQuantityType: propTypes.number.isRequired, + peripheral: propTypes.object.isRequired, + measurements: propTypes.array.isRequired +}; + +ChartCard.defaultProps = { + color: Theme.greyDark, + peripheral: {}, + measurements: [] +}; + +export default observer(ChartCard); \ No newline at end of file diff --git a/components/cards/InformationCard.js b/components/cards/InformationCard.js index 345ae3c..40e474f 100644 --- a/components/cards/InformationCard.js +++ b/components/cards/InformationCard.js @@ -1,7 +1,9 @@ import PropTypes from "prop-types"; import React from "react"; +import Link from "next/link"; import styled from "styled-components"; import Card from "./Card"; +import Button from "../Button"; const Container = styled(Card)` && { @@ -16,12 +18,17 @@ const Headline = styled.h4` margin: 0 0 1rem 0; `; -export default function InformationCard({ className, headline, details }) { +export default function InformationCard({ className, headline, details, serial }) { return ( - - {headline} -

{details}

-
+ <> + + {headline} +

{details}

+
+ {serial ? +