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