changed component, follow standard naming
This commit is contained in:
parent
d9947daf83
commit
7fc058565b
@ -1,68 +1,14 @@
|
||||
import moment from "moment";
|
||||
import { exportToCSV, exportToExcel, exportToPDF, printTable } from "../../utils/tableExportUtils";
|
||||
import {
|
||||
exportToCSV,
|
||||
exportToExcel,
|
||||
exportToPDF,
|
||||
printTable,
|
||||
} from "../../utils/tableExportUtils";
|
||||
import { FREQUENCY_FOR_RECURRING } from "../../utils/constants";
|
||||
import ExpenseRepository from "../../repositories/ExpsenseRepository";
|
||||
|
||||
// const handleRecurringExpenseExport = (type, expenses, tableRef) => {
|
||||
// if (!expenses || expenses.length === 0) return;
|
||||
|
||||
// // Mapped Export Data
|
||||
// const exportData = expenses.map((item) => ({
|
||||
// Category: item?.expenseCategory?.name ?? "-",
|
||||
// Title: item?.title ?? "-",
|
||||
// Payee: item?.payee ?? "-",
|
||||
// Frequency:
|
||||
// item?.frequency !== undefined && item?.frequency !== null
|
||||
// ? FREQUENCY_FOR_RECURRING[item?.frequency] ?? "-"
|
||||
// : "-",
|
||||
// Amount: item?.amount ? item.amount.toLocaleString() : "-",
|
||||
// Currency: item?.currency?.symbol ?? "-",
|
||||
// "Next Generation Date": item?.nextGenerationDate
|
||||
// ? moment(item.nextGenerationDate).format("DD-MMM-YYYY")
|
||||
// : "-",
|
||||
// Status: item?.status?.name ?? "-",
|
||||
// "Created At": item?.createdAt
|
||||
// ? moment(item.createdAt).format("DD-MMM-YYYY")
|
||||
// : "-",
|
||||
// }));
|
||||
|
||||
// // COLUMN ORDER
|
||||
// const columns = [
|
||||
// "Category",
|
||||
// "Title",
|
||||
// "Payee",
|
||||
// "Frequency",
|
||||
// "Amount",
|
||||
// "Currency",
|
||||
// "Next Generation Date",
|
||||
// "Status",
|
||||
// "Created At",
|
||||
// ];
|
||||
|
||||
// switch (type) {
|
||||
// case "csv":
|
||||
// exportToCSV(exportData, "recurring-expense", columns);
|
||||
// break;
|
||||
|
||||
// case "excel":
|
||||
// exportToExcel(exportData, "recurring-expense", columns);
|
||||
// break;
|
||||
|
||||
// case "pdf":
|
||||
// exportToPDF(exportData, "recurring-expense", columns);
|
||||
// break;
|
||||
|
||||
// case "print":
|
||||
// if (tableRef?.current) printTable(tableRef.current);
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// console.warn("Unhandled export type:", type);
|
||||
// break;
|
||||
// }
|
||||
// };
|
||||
|
||||
const handleRecurringExpenseExport = async (
|
||||
const HandleRecurringExpenseExport = async (
|
||||
type,
|
||||
filters = {},
|
||||
searchString = "",
|
||||
@ -72,7 +18,8 @@ const handleRecurringExpenseExport = async (
|
||||
try {
|
||||
if (setLoading) setLoading(true);
|
||||
|
||||
const safeSearchString = typeof searchString === "string" ? searchString : "";
|
||||
const safeSearchString =
|
||||
typeof searchString === "string" ? searchString : "";
|
||||
let allRecurringExpense = [];
|
||||
let pageNumber = 1;
|
||||
const pageSize = 1000;
|
||||
@ -150,7 +97,6 @@ const handleRecurringExpenseExport = async (
|
||||
default:
|
||||
console.warn("Unknown export type:", type);
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.error("Export failed:", err);
|
||||
} finally {
|
||||
@ -158,4 +104,4 @@ const handleRecurringExpenseExport = async (
|
||||
}
|
||||
};
|
||||
|
||||
export default handleRecurringExpenseExport;
|
||||
export default HandleRecurringExpenseExport;
|
||||
|
||||
@ -7,7 +7,7 @@ import RecurringExpenseList from "../../components/RecurringExpense/RecurringExp
|
||||
import { PAYEE_RECURRING_EXPENSE } from "../../utils/constants";
|
||||
import { defaultRecurringExpense, SearchRecurringExpenseSchema } from "../../components/RecurringExpense/RecurringExpenseSchema";
|
||||
import ViewRecurringExpense from "../../components/RecurringExpense/ViewRecurringExpense";
|
||||
import handleRecurringExpenseExport from "../../components/RecurringExpense/handleRecurringExpenseExport";
|
||||
import HandleRecurringExpenseExport from "../../components/RecurringExpense/HandleRecurringExpenseExport";
|
||||
|
||||
export const RecurringExpenseContext = createContext();
|
||||
export const useRecurringExpenseContext = () => {
|
||||
@ -54,7 +54,7 @@ const RecurringExpensePage = () => {
|
||||
|
||||
|
||||
const handleExport = (type) => {
|
||||
handleRecurringExpenseExport(type, filters, search, tableRef, setExportLoading);
|
||||
HandleRecurringExpenseExport(type, filters, search, tableRef, setExportLoading);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user