import React, { useCallback } from "react";
import { Center, HStack, Pressable, ScrollView, Text, VStack } from "native-base";
import { Platform } from "react-native";
import moment from "moment";
import { withTheme } from "../../../theme/hoc";
import { Image } from "../../../core/images";
import { GdAmount, TransText } from "../../../core/layout";
import { ClaimContextProps, Transaction } from "../types";
import { isReceiveTransaction } from "../utils/transactionType";
import { getTxIcons } from "../../../utils/icons";
export type TransactionCardProps = {
transaction: Transaction;
onTxDetailsPress: ClaimContextProps["onTxDetailsPress"];
};
//todo: border likely needs to be turned into component because of pattern. border-image not supported in react-native
export const TransactionCard = withTheme({ name: "TransactionCard" })(
({ transaction, onTxDetailsPress }: TransactionCardProps) => {
const { tokenValue, type, status, date, displayName } = transaction;
const openTransactionDetails = useCallback(() => {
onTxDetailsPress?.(transaction);
}, [transaction, onTxDetailsPress]);
const isClaimStart = type === "claim-start";
const isReceive = isReceiveTransaction(transaction);
const amountPrefix = isClaimStart ? "" : isReceive ? "+" : "-";
const txDate = date ? moment(date).local().format?.("MM.DD.YYYY HH:mm") : "";
const colorAmount = isClaimStart ? null : isReceive ? "txGreen" : "goodRed.200";
const { txIcon, networkIcon, contractIcon } = getTxIcons(transaction);
return (
{txDate}
{tokenValue ? (
) : null}
{displayName}
{/* Todo: should read subtitle from pool details*/}
{status === "failed" ? TransactionFailedDetails : null}
{status !== "failed" ? : null}
);
}
);
type TransactionListProps = {
transactions: Transaction[] | undefined;
onTxDetailsPress: ClaimContextProps["onTxDetailsPress"];
limit?: number;
};
export const TransactionList = ({ transactions, onTxDetailsPress, limit = 3 }: TransactionListProps) => (
{transactions?.map((tx: Transaction, i: any) => (
))}
);