update
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
// exportFunctions.ts
|
||||
import * as XLSX from 'xlsx';
|
||||
import jsPDF from 'jspdf';
|
||||
import autoTable from 'jspdf-autotable';
|
||||
@ -6,6 +7,7 @@ import { format } from 'date-fns';
|
||||
import { toast } from 'sonner';
|
||||
import { toAbsoluteUrl } from '@/utils';
|
||||
|
||||
// Types
|
||||
interface WalletData {
|
||||
ID?: string;
|
||||
name?: string;
|
||||
@ -26,6 +28,7 @@ interface TransactionItem {
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
// Category mapping
|
||||
const categoryMap: Record<string, string> = {
|
||||
T: 'TRANSFER',
|
||||
P: 'PURCHASE',
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// ShowDetailWalletDialog.tsx - Versi yang sudah disederhanakan
|
||||
import React, { createContext, useCallback, useEffect, useState } from 'react';
|
||||
import {
|
||||
Dialog,
|
||||
@ -149,6 +150,7 @@ const ShowDetailWalletDialog = () => {
|
||||
}
|
||||
];
|
||||
|
||||
// Function untuk mendapatkan data transaksi dengan pagination
|
||||
const getTransactionLists = useCallback(
|
||||
async (page: number, limit: number, sorting: any, _columnFilters: any) => {
|
||||
try {
|
||||
@ -179,6 +181,7 @@ const ShowDetailWalletDialog = () => {
|
||||
[GetData, filters, selectedWallet]
|
||||
);
|
||||
|
||||
// Function untuk mendapatkan semua data transaksi
|
||||
const getAllTransactionData = async () => {
|
||||
try {
|
||||
const response = await GetData(
|
||||
@ -200,21 +203,24 @@ const ShowDetailWalletDialog = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// Function untuk export Excel - sekarang hanya memanggil function terpisah
|
||||
const doExportExcel = async () => {
|
||||
try {
|
||||
if (!selectedWallet) {
|
||||
console.error('Something went wrong. Please try again...');
|
||||
return;
|
||||
}
|
||||
|
||||
const allData = await getAllTransactionData();
|
||||
await exportToExcel(allData, selectedWallet);
|
||||
} catch (error) {
|
||||
console.error('Error in doExportExcel:', error);
|
||||
toast.error('Failed to export Excel');
|
||||
try {
|
||||
if (!selectedWallet) {
|
||||
console.error('Something went wrong. Please try again...');
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const allData = await getAllTransactionData();
|
||||
await exportToExcel(allData, selectedWallet);
|
||||
} catch (error) {
|
||||
console.error('Error in doExportExcel:', error);
|
||||
toast.error('Failed to export Excel');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Function untuk export PDF - sekarang hanya memanggil function terpisah
|
||||
const doExportPDF = async () => {
|
||||
try {
|
||||
if (!selectedWallet) {
|
||||
|
||||
Reference in New Issue
Block a user