diff --git a/src/contract/contractTransactionTable.tsx b/src/contract/contractTransactionTable.tsx index 4574bb7..4508377 100644 --- a/src/contract/contractTransactionTable.tsx +++ b/src/contract/contractTransactionTable.tsx @@ -144,7 +144,7 @@ export default function ContractTransactionTable(props: Props) { //use the transaction api to revoke the transaction //--moved all the functionality for adjusting the objects involved to the backend so this can be handled with a single call-- transactionAPI - .revokeTransaction(activeTransaction.transaction.key) + .revokeTransaction(activeTransaction.transaction.key, as) .then(resp => { openSnack("Transaction revoked and inventory moved back"); transactionRevokedCallback(activeTransaction.transaction.key); diff --git a/src/grain/GrainTransaction.tsx b/src/grain/GrainTransaction.tsx index 2777f9c..e35f84a 100644 --- a/src/grain/GrainTransaction.tsx +++ b/src/grain/GrainTransaction.tsx @@ -248,7 +248,7 @@ export default function GrainTransaction(props: Props) { grainTransaction.subtype = obj.subtype(); } } - transactionAPI.addTransaction(newTransaction, imageIDs).then(resp => { + transactionAPI.addTransaction(newTransaction, imageIDs, as).then(resp => { newTransaction.key = resp.data.key; closeDialogs(true, newTransaction); }); diff --git a/src/pages/Transactions.tsx b/src/pages/Transactions.tsx index 1f2a747..e69e7fd 100644 --- a/src/pages/Transactions.tsx +++ b/src/pages/Transactions.tsx @@ -8,7 +8,7 @@ import TransactionViewer from "transactions/transactionViewer"; import { TransactionOptions } from "objects/ObjectDescriber"; import { GetDefaultDateRange } from "common/time/DateRange"; import TimeBar from "common/time/TimeBar"; -import { useTransactionAPI } from "providers"; +import { useGlobalState, useTransactionAPI } from "providers"; import { Transaction } from "models/Transaction"; import { makeStyles } from "@mui/styles"; @@ -40,6 +40,7 @@ export default function Transactions() { const [objectNames, setObjectNames] = useState>(new Map()); const [fromName, setFromName] = useState(""); const [toName, setToName] = useState(""); + const [{as}] = useGlobalState(); const updateDateRange = (newStartDate: any, newEndDate: any) => { let range = GetDefaultDateRange(); @@ -78,7 +79,7 @@ export default function Transactions() { if (!isLoading) { setIsLoading(true); transactionAPI - .transactionPageData(startDate.toISOString(), endDate.toISOString()) + .transactionPageData(startDate.toISOString(), endDate.toISOString(), as) .then(resp => { setTotalTransactions( resp.data.transactions.map((t: pond.Transaction) => Transaction.create(t)) diff --git a/src/providers/pond/transactionAPI.tsx b/src/providers/pond/transactionAPI.tsx index 9ca00be..70d8b95 100644 --- a/src/providers/pond/transactionAPI.tsx +++ b/src/providers/pond/transactionAPI.tsx @@ -8,11 +8,13 @@ import { useGlobalState } from "providers"; export interface ITransactionAPIContext { addTransaction: ( transaction: pond.Transaction, - fileIDs?: string[] + fileIDs?: string[], + as?: string ) => Promise>; transactionPageData: ( start: string, - end: string + end: string, + as?: string ) => Promise>; listTransactions: ( start: string, @@ -20,12 +22,14 @@ export interface ITransactionAPIContext { fromObject?: pond.ObjectType, toObject?: pond.ObjectType, fromKey?: string, - toKey?: string + toKey?: string, + as?: string ) => Promise>; - revokeTransaction: (key: string) => Promise>; + revokeTransaction: (key: string, as?: string) => Promise>; updateTransaction: ( key: string, - data: pond.TransactionData + data: pond.TransactionData, + as?: string ) => Promise>; } @@ -38,9 +42,9 @@ interface Props {} export default function TransactionProvider(props: PropsWithChildren) { const { children } = props; const { get, post, put } = useHTTP(); - const [{ as }] = useGlobalState(); + //const [{ as }] = useGlobalState(); - const addTransaction = (transaction: pond.Transaction, fileIDs?: string[]) => { + const addTransaction = (transaction: pond.Transaction, fileIDs?: string[], as?: string) => { if (as) return post( pondURL( @@ -60,7 +64,8 @@ export default function TransactionProvider(props: PropsWithChildren) { fromObject?: pond.ObjectType, toObject?: pond.ObjectType, fromKey?: string, - toKey?: string + toKey?: string, + as?: string ) => { if (as) { return get( @@ -81,7 +86,7 @@ export default function TransactionProvider(props: PropsWithChildren) { ); }; - const updateTransaction = (key: string, data: pond.TransactionData) => { + const updateTransaction = (key: string, data: pond.TransactionData, as?: string) => { if (as) return post( pondURL("/transactions/" + key + "/update?as=" + as), @@ -90,7 +95,7 @@ export default function TransactionProvider(props: PropsWithChildren) { return post(pondURL("/transactions/" + key + "/update"), data); }; - const transactionPageData = (start: string, end: string) => { + const transactionPageData = (start: string, end: string, as?: string) => { if (as) { return get( pondURL("/transactionsPage?as=" + as + "&start=" + start + "&end=" + end) @@ -101,7 +106,7 @@ export default function TransactionProvider(props: PropsWithChildren) { ); }; - const revokeTransaction = (key: string) => { + const revokeTransaction = (key: string, as?: string) => { if (as) { return put( pondURL("/transactions/" + key + "/revoke?as=" + as)