=> {
const res = await wxApi.getTransactions();
setTransactions(res);
};
fetchData();
}, []);
if (!transactions) {
return Loading ...
;
}
const txs = [...transactions.transactions].reverse();
return (
{txs.map((tx, i) => (
))}
);
}
function TransactionItem(props: { tx: Transaction }): JSX.Element {
const tx = props.tx;
switch (tx.type) {
case TransactionType.Withdrawal:
return (
);
case TransactionType.Payment:
return (
);
case TransactionType.Refund:
return (
);
case TransactionType.Tip:
return (
);
case TransactionType.Refresh:
return (
);
case TransactionType.Deposit:
return (
);
}
}
function TransactionLayout(props: TransactionLayoutProps): JSX.Element {
const date = new Date(props.timestamp.t_ms);
const dateStr = date.toLocaleString([], {
dateStyle: "medium",
timeStyle: "short",
} as any);
return (
{dateStr}
{props.subtitle}
);
}
interface TransactionLayoutProps {
debitCreditIndicator: "debit" | "credit" | "unknown";
amount: AmountString | "unknown";
timestamp: Timestamp;
title: string;
id: string;
subtitle: string;
iconPath: string;
pending: boolean;
}
interface TransactionAmountProps {
debitCreditIndicator: "debit" | "credit" | "unknown";
amount: AmountString | "unknown";
pending: boolean;
}
function TransactionAmount(props: TransactionAmountProps): JSX.Element {
const [currency, amount] = props.amount.split(":");
let sign: string;
switch (props.debitCreditIndicator) {
case "credit":
sign = "+";
break;
case "debit":
sign = "-";
break;
case "unknown":
sign = "";
}
const style: JSX.AllCSSProperties = {
marginLeft: "auto",
display: "flex",
flexDirection: "column",
alignItems: "center",
alignSelf: "center"
};
if (props.pending) {
style.color = "gray";
}
return (
{sign}
{amount}
{currency}
);
}