All files / src/pages/FundraisersDonationList utils.ts

80% Statements 4/5
0% Branches 0/2
50% Functions 1/2
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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            1x 6x   6x                                                                                                 6x    
import {
  formatDate,
  sourceMethodParser,
} from "@components/ManageMoney/TransactionTable/transactions.helpers";
import { useFormatDateInTimezone } from "@utils/date.helpers";
 
export const useParseTransactionRow = () => {
  const { formatInTimezone } = useFormatDateInTimezone();
  
  const rowParser = (thx: any) => {
    return {
      ...thx,
      id: thx.id,
      product: thx.product,
      charged: thx.transactionCharged / 100,
      displayStatus: thx.transactionDisplayStatus,
      createdAtTimestamp: thx.createdAt,
      createdAt: formatInTimezone(thx.createdAt, "MMMM dd yyyy HH:mm"),
      updatedAt: thx.updatedAt,
      sourceAccount: {
        user: {
          ...thx.transactionCustomer,
        },
      },
      sourceMethod: {
        method: sourceMethodParser({
          sourceMethod: thx.transactionPaymentData,
        } as any),
      },
      email: thx.transactionCustomer.email,
      fees: thx.transactionFees / 100,
      recurringStatus: thx.recurringStatus,
      processed: formatDate(thx.createdAt * 1000),
      revenue: "Website",
      transactionId: thx.TransactionObjID,
      cardholderName: thx.transactionPaymentData.card?.cardholderName,
      sorceAccountFullName: `${thx.transactionCustomer.firstName} ${thx.transactionCustomer.lastName}`,
      recurringInterval: thx.recurringInterval,
      recurringMax: thx.recurringMax,
      recurringCount: thx.recurringCount,
      unitPrice: thx.unitPrice / 100,
      itemCharged: thx.unitPrice / 100 + thx.transactionFees / 100,
      quantity: thx.quantity,
      totalAmount: thx.transactionCost / 100,
      transactionCost: thx.transactionCost / 100,
      transactionID: thx.TransactionObjID,
      price: thx.price / 100,
      passFees: thx.transactionPassFees,
      transactionCustomerId: thx.transactionCustomer.id,
      transactionProcessingState: thx.transactionProcessingState,
      processingState: thx.transactionProcessingState,
      orderRecurringItemID: thx.orderRecurringItemID,
      transactionCharged: (thx.transactionCharged ?? 0) / 100,
      hideRefund: thx.disallowReversalRequests,
      customer: thx.transactionCustomer,
    };
  };
 
  return { rowParser };
};