Implement code changes

The prompt asked to implement code changes.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-18 07:49:51 +00:00
parent 8e609519ac
commit 612cd37b1d
11 changed files with 444 additions and 352 deletions

View File

@@ -1,5 +1,5 @@
import React from 'react';
import React, { useCallback } from 'react';
import TransactionCard, { Transaction } from '@/components/TransactionCard';
interface TransactionDateGroupProps {
@@ -8,22 +8,30 @@ interface TransactionDateGroupProps {
onTransactionDelete: (id: string) => Promise<boolean> | boolean;
}
/**
* 날짜별 트랜잭션 그룹 컴포넌트 - 성능 및 안정성 개선 버전
*/
const TransactionDateGroup: React.FC<TransactionDateGroupProps> = ({
date,
transactions,
onTransactionDelete
}) => {
// 안정적인 삭제 핸들러
const handleDelete = async (id: string): Promise<boolean> => {
// 메모이즈된 삭제 핸들러로 성능 최적화
const handleDelete = useCallback(async (id: string): Promise<boolean> => {
try {
// 적절한 타입 변환 처리
if (!onTransactionDelete) {
console.warn('삭제 핸들러가 제공되지 않았습니다');
return false;
}
// Promise 반환 여부에 따라 적절히 처리
const result = await Promise.resolve(onTransactionDelete(id));
return !!result;
return Boolean(result);
} catch (error) {
console.error('삭제 처리 중 오류:', error);
console.error('트랜잭션 삭제 처리 중 오류:', error);
return false;
}
};
}, [onTransactionDelete]);
return (
<div>
@@ -46,4 +54,4 @@ const TransactionDateGroup: React.FC<TransactionDateGroupProps> = ({
);
};
export default TransactionDateGroup;
export default React.memo(TransactionDateGroup);