starting table

This commit is contained in:
csawatzky 2025-05-23 11:07:34 -06:00
parent 3f33a7dd41
commit 9bacaa12d9
3 changed files with 32 additions and 11 deletions

View file

@ -1,8 +1,10 @@
import { Box } from "@mui/material"; import { Box } from "@mui/material";
import ResponsiveTable from "common/ResponsiveTable";
import { Bin } from "models"; import { Bin } from "models";
import { Transaction } from "models/Transaction";
import { pond } from "protobuf-ts/pond"; import { pond } from "protobuf-ts/pond";
import { useTransactionAPI } from "providers"; import { useTransactionAPI } from "providers";
import { useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
interface Props { interface Props {
bin: Bin bin: Bin
@ -12,17 +14,30 @@ export default function BinTransactions(props: Props){
const { bin } = props const { bin } = props
const [state, setState] = useState<pond.TransactionState>(pond.TransactionState.TRANSACTION_STATE_PENDING) const [state, setState] = useState<pond.TransactionState>(pond.TransactionState.TRANSACTION_STATE_PENDING)
const transactionAPI = useTransactionAPI() const transactionAPI = useTransactionAPI()
const [transactions, setTransactions] = useState<Transaction[]>([])
useEffect(()=>{ const load = useCallback(()=>{
// load transactions for bin with matching state (pending is default) // load transactions for bin with matching state (pending is default)
transactionAPI.listTransactionsFor(10, 0, "asc", bin.key()).then(resp => { transactionAPI.listTransactionsFor(10, 0, "asc", bin.key(), state).then(resp => {
console.log(resp) console.log(resp)
}) })
},[state, bin]) },[state, bin])
useEffect(()=>{
load()
},[state, bin, load])
// dialog for approving a transaction
return ( return (
<Box> <Box>
{/* */} {/* dropdown for transaction state */}
{/* table to display transactions */}
{/* <ResponsiveTable<Transaction>
rows={transactions}
/> */}
</Box> </Box>
) )
} }

View file

@ -285,7 +285,9 @@ export default function BinGraphs(props: Props) {
<Box> <Box>
<BinWaterLevel <BinWaterLevel
bin={bin} bin={bin}
range={{ start: startDate, end: endDate }} // range={{ start: startDate, end: endDate }}
start={startDate.toISOString()}
end={endDate.toISOString()}
plenumKey={componentDevices.get(plenums[0].key()) + ":" + plenums[0].key()} plenumKey={componentDevices.get(plenums[0].key()) + ":" + plenums[0].key()}
cableKey={componentDevices.get(moistureCables[0].key()) + ":" + moistureCables[0].key()} cableKey={componentDevices.get(moistureCables[0].key()) + ":" + moistureCables[0].key()}
pressureKey={componentDevices.get(pressures[0].key()) + ":" + pressures[0].key()} pressureKey={componentDevices.get(pressures[0].key()) + ":" + pressures[0].key()}

View file

@ -9,7 +9,9 @@ import React, { useEffect, useState } from "react";
interface Props { interface Props {
bin: Bin; bin: Bin;
range: DateRange; // range: DateRange;
start: string,
end: string,
plenumKey: string; plenumKey: string;
cableKey: string; cableKey: string;
pressureKey: string; pressureKey: string;
@ -23,7 +25,9 @@ interface Props {
export default function BinWaterLevel(props: Props) { export default function BinWaterLevel(props: Props) {
const { const {
bin, bin,
range, //range,
start,
end,
plenumKey, plenumKey,
cableKey, cableKey,
pressureKey, pressureKey,
@ -63,8 +67,8 @@ export default function BinWaterLevel(props: Props) {
binAPI binAPI
.listBinLiters( .listBinLiters(
bin.key(), bin.key(),
range.start.toISOString(), start,
range.end.toISOString(), end,
grainMoisture, grainMoisture,
//(note: the variable needs to be the device the component belongs to and then the component key ie. "10:LTe7Q1sT5g65") //(note: the variable needs to be the device the component belongs to and then the component key ie. "10:LTe7Q1sT5g65")
plenumKey, plenumKey,
@ -94,7 +98,7 @@ export default function BinWaterLevel(props: Props) {
}); });
} }
} }
}, [binAPI, range, bin, grainMoisture, plenumKey, cableKey, pressureKey, as]); // eslint-disable-line react-hooks/exhaustive-deps }, [binAPI, start, end, bin, grainMoisture, plenumKey, cableKey, pressureKey, as]); // eslint-disable-line react-hooks/exhaustive-deps
return ( return (
<React.Fragment> <React.Fragment>