Added functionality to transaction list page

This commit is contained in:
Keannu Christian Bernasol 2023-12-14 19:51:33 +08:00
parent ac55dca368
commit d226d77306
3 changed files with 258 additions and 1 deletions

View file

@ -16,6 +16,7 @@ import {
EquipmentLogListType,
EquipmentInstanceLogListType,
UserType,
TransactionListType,
} from "../Types/Types";
const debug = true;
@ -341,3 +342,17 @@ export async function EquipmentInstanceCreateAPI(
return [false, ParseError(error)];
});
}
// Transactions APIs
export async function TransactionsAPI() {
const config = await GetConfig();
return instance
.get("api/v1/transactions/", config)
.then((response) => {
return response.data as TransactionListType;
})
.catch(() => {
console.log("Error retrieving transactions");
});
}

View file

@ -106,3 +106,22 @@ export type UserType = {
is_teacher: boolean;
is_technician: boolean;
};
export type TransactionType = {
id: number;
borrower: {
id: number;
name: string;
};
teacher: {
id: number;
name: string;
};
equipments: Array<{
id: number;
name: string;
}>;
transaction_status: string;
};
export type TransactionListType = Array<TransactionType>;