This repository was archived by the owner on Jan 30, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTransactions.js
More file actions
72 lines (68 loc) · 2.31 KB
/
Transactions.js
File metadata and controls
72 lines (68 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { useState } from 'react';
import MXEndpoint from "./MXEndpoint";
function Transactions({userGuid, memberGuid}) {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(null);
const [transactions, setTransactions] = useState([]);
const [jsonData, setJsonData] = useState(null);
const [status, setStatus] = useState(2)
const loadTransactions = async () => {
setIsLoading(true);
await fetch('https://api-59jd.onrender.com'+`/users/${userGuid}/members/${memberGuid}/transactions`)
.then(res => {
if (res.ok) {
return res.json();
}
throw new Error()
})
.then((res) => {
setTransactions(res.transactions);
setStatus(3)
setJsonData(res)
setIsLoading(false);
})
.catch(error => {
setIsLoading(false);
setError({
code: '400',
type: 'Bad Request',
message: 'Something happend and you were unable to get transactions',
link: 'https://docs.mx.com/api#core_resources_transactions_list_transactions_by_member'
})
});
}
return (
<div style={{marginTop: '24px'}}>
<MXEndpoint
docsLink="https://docs.mx.com/api#core_resources_transactions_list_transactions_by_member"
title="List Transactions"
finalDataUrl="/users/{user_guid}/members/{member_guid}/transactions"
jobType="Transactions"
status={status}
showNotice={true}
requestType="Post"
requestUrl="/users/{user_guid}/members/{member_guid}/aggregate"
isLoading={isLoading}
subText="Requests to this endpoint return a list of transactions associated with the specified member, across all accounts associated with that member."
onAction={loadTransactions}
error={error}
jsonData={jsonData}
tableData={{
headers: ['Description', 'Category', 'Amount', 'Date'],
rowData: transactions.slice(0,10).map(transaction => {
return ({
id: transaction.guid,
cols: [
transaction.description,
transaction.category,
transaction.amount,
transaction.date,
]
})
})
}}
/>
</div>
);
}
export default Transactions;