import React from 'react' import { useRecurringExpenseDetail } from '../../hooks/useExpense'; import { formatUTCToLocalTime } from '../../utils/dateUtils'; import { formatFigure, getColorNameFromHex } from '../../utils/appUtils'; import Avatar from '../common/Avatar'; import { FREQUENCY_FOR_RECURRING } from '../../utils/constants'; import { ExpenseDetailsSkeleton } from '../Expenses/ExpenseSkeleton'; const ViewRecurringExpense = ({ RecurringId }) => { const { data, isLoading, isError, error, isFetching } = useRecurringExpenseDetail(RecurringId); const statusColorMap = { "da462422-13b2-45cc-a175-910a225f6fc8": "primary", // Active "306856fb-5655-42eb-bf8b-808bb5e84725": "success", // Completed "3ec864d2-8bf5-42fb-ba70-5090301dd816": "danger", // De-Activated "8bfc9346-e092-4a80-acbf-515ae1ef6868": "warning", // Paused }; if (isLoading) return ; return (
Recurring Payment Details
{/*
*/}
{/* Row 1 Recurring Id and Status */}
{data?.recurringPaymentUID} {data?.status?.name || "N/A"}
{/* Row 2 Category*/}
{data?.expenseCategory?.name || "N/A"}
{/* Row 3 Amount and Project */}
{data?.amount != null ? `${data?.currency?.symbol ?? "¥"} ${Number(data.amount).toFixed(2)} ${data?.currency?.currencyCode ?? "CN"}` : "N/A"}
{data?.project?.name || "N/A"}
{/* Row 4 Created At and Title*/}
{/*
{formatUTCToLocalTime(data?.createdAt, true)}
*/}
{data?.createdAt ? formatUTCToLocalTime(data.createdAt, true) : "N/A"}
{data?.title || "N/A"}
{/* Row 5 Payee and Notify*/}
{data?.payee || "N/A"}
{data?.notifyTo?.length > 0 ? data.notifyTo?.map((user, index) => ( {user.email} {index < data?.notifyTo?.length - 1 && ", "} )) : "N/A"}
{/* Row 6 Strike Date*/}
{/*
{formatUTCToLocalTime(data?.strikeDate)}
*/}
{data?.strikeDate ? formatUTCToLocalTime(data.strikeDate, true) : "N/A"}
{/* Row 7 Frequency and Buffer Days*/}
{data?.frequency !== undefined ? FREQUENCY_FOR_RECURRING[data.frequency] : "N/A"}
{data?.paymentBufferDays || "N/A"}
{/* Row 8 Updated At and Number of Iteration*/}
{data?.updatedAt ? formatUTCToLocalTime(data.updatedAt, true) : "N/A"}
{data?.numberOfIteration || "N/A"}
{/* Row 9 Created By and Updated By*/}
{`${data?.createdBy?.firstName ?? ""} ${data?.createdBy?.lastName ?? ""}`.trim() || "N/A"}
{data?.updatedBy ? ( <> {`${data.updatedBy.firstName ?? ""} ${data.updatedBy.lastName ?? ""}`.trim() || "N/A"} ) : ( N/A )}
{/* Row 10 Description */}
{data?.description || "N/A"}
{/*
*/}
) } export default ViewRecurringExpense