update as in the transaction api
This commit is contained in:
parent
ae458c3fca
commit
4912d319ff
4 changed files with 21 additions and 15 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<Map<string, string>>(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))
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ import { useGlobalState } from "providers";
|
|||
export interface ITransactionAPIContext {
|
||||
addTransaction: (
|
||||
transaction: pond.Transaction,
|
||||
fileIDs?: string[]
|
||||
fileIDs?: string[],
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.AddTransactionResponse>>;
|
||||
transactionPageData: (
|
||||
start: string,
|
||||
end: string
|
||||
end: string,
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.TransactionPageDataResponse>>;
|
||||
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<AxiosResponse<pond.ListTransactionsResponse>>;
|
||||
revokeTransaction: (key: string) => Promise<AxiosResponse<pond.RevokeTransactionResponse>>;
|
||||
revokeTransaction: (key: string, as?: string) => Promise<AxiosResponse<pond.RevokeTransactionResponse>>;
|
||||
updateTransaction: (
|
||||
key: string,
|
||||
data: pond.TransactionData
|
||||
data: pond.TransactionData,
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.UpdateTransactionResponse>>;
|
||||
}
|
||||
|
||||
|
|
@ -38,9 +42,9 @@ interface Props {}
|
|||
export default function TransactionProvider(props: PropsWithChildren<Props>) {
|
||||
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<pond.AddTransactionResponse>(
|
||||
pondURL(
|
||||
|
|
@ -60,7 +64,8 @@ export default function TransactionProvider(props: PropsWithChildren<Props>) {
|
|||
fromObject?: pond.ObjectType,
|
||||
toObject?: pond.ObjectType,
|
||||
fromKey?: string,
|
||||
toKey?: string
|
||||
toKey?: string,
|
||||
as?: string
|
||||
) => {
|
||||
if (as) {
|
||||
return get<pond.ListTransactionsResponse>(
|
||||
|
|
@ -81,7 +86,7 @@ export default function TransactionProvider(props: PropsWithChildren<Props>) {
|
|||
);
|
||||
};
|
||||
|
||||
const updateTransaction = (key: string, data: pond.TransactionData) => {
|
||||
const updateTransaction = (key: string, data: pond.TransactionData, as?: string) => {
|
||||
if (as)
|
||||
return post<pond.UpdateTransactionResponse>(
|
||||
pondURL("/transactions/" + key + "/update?as=" + as),
|
||||
|
|
@ -90,7 +95,7 @@ export default function TransactionProvider(props: PropsWithChildren<Props>) {
|
|||
return post<pond.UpdateTransactionResponse>(pondURL("/transactions/" + key + "/update"), data);
|
||||
};
|
||||
|
||||
const transactionPageData = (start: string, end: string) => {
|
||||
const transactionPageData = (start: string, end: string, as?: string) => {
|
||||
if (as) {
|
||||
return get<pond.TransactionPageDataResponse>(
|
||||
pondURL("/transactionsPage?as=" + as + "&start=" + start + "&end=" + end)
|
||||
|
|
@ -101,7 +106,7 @@ export default function TransactionProvider(props: PropsWithChildren<Props>) {
|
|||
);
|
||||
};
|
||||
|
||||
const revokeTransaction = (key: string) => {
|
||||
const revokeTransaction = (key: string, as?: string) => {
|
||||
if (as) {
|
||||
return put<pond.RevokeTransactionResponse>(
|
||||
pondURL("/transactions/" + key + "/revoke?as=" + as)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue