Fix type error in TransactionDateGroup

The onDelete prop in TransactionCard component expects a function that returns boolean or Promise<boolean>, but TransactionDateGroup was passing a function with void return type. This commit updates the type definition to match the expected return type.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-18 05:08:10 +00:00
parent 78dce33769
commit ceb6dd4bcb
2 changed files with 13 additions and 3 deletions

View File

@@ -5,7 +5,7 @@ import TransactionCard, { Transaction } from '@/components/TransactionCard';
interface TransactionDateGroupProps {
date: string;
transactions: Transaction[];
onTransactionDelete: (id: string) => void;
onTransactionDelete: (id: string) => Promise<boolean> | boolean;
}
const TransactionDateGroup: React.FC<TransactionDateGroupProps> = ({
@@ -13,6 +13,16 @@ const TransactionDateGroup: React.FC<TransactionDateGroupProps> = ({
transactions,
onTransactionDelete
}) => {
// onTransactionDelete 함수를 래핑하여 Promise<boolean>을 반환하도록 보장
const handleDelete = async (id: string): Promise<boolean> => {
try {
return await onTransactionDelete(id);
} catch (error) {
console.error('트랜잭션 삭제 처리 중 오류:', error);
return false;
}
};
return (
<div>
<div className="flex items-center gap-2 mb-3">
@@ -26,7 +36,7 @@ const TransactionDateGroup: React.FC<TransactionDateGroupProps> = ({
<TransactionCard
key={transaction.id}
transaction={transaction}
onDelete={onTransactionDelete}
onDelete={handleDelete}
/>
))}
</div>

View File

@@ -5,7 +5,7 @@ import TransactionDateGroup from './TransactionDateGroup';
interface TransactionsListProps {
groupedTransactions: Record<string, Transaction[]>;
onTransactionDelete: (id: string) => void;
onTransactionDelete: (id: string) => Promise<boolean> | boolean;
}
const TransactionsList: React.FC<TransactionsListProps> = ({