Fix module import errors
Corrected import paths for '@/contexts/BudgetContext' in multiple components to resolve module not found errors.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { PlusIcon } from 'lucide-react';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from './ui/dialog';
|
||||
import { toast } from '@/hooks/useToast.wrapper'; // 래퍼 사용
|
||||
import { useBudget } from '@/contexts/BudgetContext';
|
||||
import { useBudget } from '@/contexts/budget/BudgetContext';
|
||||
import { supabase } from '@/lib/supabase';
|
||||
import { isSyncEnabled, setLastSyncTime, trySyncAllData } from '@/utils/syncUtils';
|
||||
import ExpenseForm, { ExpenseFormValues } from './expenses/ExpenseForm';
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
import React from 'react';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import BudgetTabContent from './BudgetTabContent';
|
||||
import { BudgetPeriod } from '@/contexts/BudgetContext';
|
||||
import { BudgetPeriod } from '@/contexts/budget/BudgetContext';
|
||||
|
||||
interface BudgetData {
|
||||
targetAmount: number;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState, useCallback, useRef } from 'react';
|
||||
import { Transaction } from './TransactionCard';
|
||||
import { Transaction } from '@/contexts/budget/types';
|
||||
import TransactionEditDialog from './TransactionEditDialog';
|
||||
import { ChevronRight } from 'lucide-react';
|
||||
import { useBudget } from '@/contexts/BudgetContext';
|
||||
import { useBudget } from '@/contexts/budget/BudgetContext';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { categoryIcons } from '@/constants/categoryIcons';
|
||||
import TransactionIcon from './transaction/TransactionIcon';
|
||||
@@ -154,7 +154,8 @@ const RecentTransactionsSection: React.FC<RecentTransactionsSectionProps> = ({
|
||||
const formatCurrency = (amount: number) => {
|
||||
return amount.toLocaleString('ko-KR') + '원';
|
||||
};
|
||||
return <div className="mt-4 mb-[40px]">
|
||||
return (
|
||||
<div className="mt-4 mb-[40px]">
|
||||
<div className="flex justify-between items-center mb-2">
|
||||
<h2 className="text-lg font-semibold">최근 지출</h2>
|
||||
<Link to="/transactions" className="text-sm text-neuro-income flex items-center">
|
||||
@@ -163,28 +164,47 @@ const RecentTransactionsSection: React.FC<RecentTransactionsSectionProps> = ({
|
||||
</div>
|
||||
|
||||
<div className="neuro-card divide-y divide-gray-100 w-full">
|
||||
{transactions.length > 0 ? transactions.map(transaction => <div key={transaction.id} onClick={() => handleTransactionClick(transaction)} className="flex justify-between py-2 cursor-pointer px-[5px] bg-transparent">
|
||||
<div className="flex items-center">
|
||||
<TransactionIcon category={transaction.category} />
|
||||
<div className="ml-3">
|
||||
<h3 className="font-medium text-black text-left text-sm">
|
||||
{transaction.title}
|
||||
</h3>
|
||||
<p className="text-xs text-gray-500">{transaction.date}</p>
|
||||
{transactions.length > 0 ? (
|
||||
transactions.map(transaction => (
|
||||
<div
|
||||
key={transaction.id}
|
||||
onClick={() => handleTransactionClick(transaction)}
|
||||
className="flex justify-between py-2 cursor-pointer px-[5px] bg-transparent"
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<TransactionIcon category={transaction.category} />
|
||||
<div className="ml-3">
|
||||
<h3 className="font-medium text-black text-left text-sm">
|
||||
{transaction.title}
|
||||
</h3>
|
||||
<p className="text-xs text-gray-500">{transaction.date}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<p className="font-semibold text-neuro-income text-sm">
|
||||
-{formatCurrency(transaction.amount)}
|
||||
</p>
|
||||
<p className="text-xs text-gray-500">{transaction.category}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<p className="font-semibold text-neuro-income text-sm">
|
||||
-{formatCurrency(transaction.amount)}
|
||||
</p>
|
||||
<p className="text-xs text-gray-500">{transaction.category}</p>
|
||||
</div>
|
||||
</div>) : <div className="py-3 text-center text-gray-500">
|
||||
))
|
||||
) : (
|
||||
<div className="py-3 text-center text-gray-500">
|
||||
지출 내역이 없습니다
|
||||
</div>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{selectedTransaction && <TransactionEditDialog transaction={selectedTransaction} open={isDialogOpen} onOpenChange={setIsDialogOpen} onSave={handleUpdateTransaction} onDelete={handleDeleteTransaction} />}
|
||||
</div>;
|
||||
{selectedTransaction && (
|
||||
<TransactionEditDialog
|
||||
transaction={selectedTransaction}
|
||||
open={isDialogOpen}
|
||||
onOpenChange={setIsDialogOpen}
|
||||
onSave={handleUpdateTransaction}
|
||||
onDelete={handleDeleteTransaction}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default RecentTransactionsSection;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
import React from 'react';
|
||||
import BudgetProgressCard from '@/components/BudgetProgressCard';
|
||||
import BudgetCategoriesSection from '@/components/BudgetCategoriesSection';
|
||||
import RecentTransactionsSection from '@/components/RecentTransactionsSection';
|
||||
import EmptyState from './EmptyState';
|
||||
import { BudgetPeriod } from '@/contexts/BudgetContext';
|
||||
import { BudgetPeriod } from '@/contexts/budget/BudgetContext';
|
||||
import { formatCurrency, calculatePercentage } from '@/utils/formatters';
|
||||
import { Transaction } from '@/components/TransactionCard';
|
||||
import { Transaction } from '@/contexts/budget/types';
|
||||
|
||||
interface HomeContentProps {
|
||||
transactions: Transaction[];
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useState, useRef, useEffect } from 'react';
|
||||
import { UseFormReturn, useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { Transaction } from '@/contexts/budget/types';
|
||||
import { useBudget } from '@/contexts/BudgetContext';
|
||||
import { useBudget } from '@/contexts/budget/BudgetContext';
|
||||
import { toast } from '@/components/ui/use-toast';
|
||||
import { TransactionFormValues, transactionFormSchema, formatWithCommas } from './TransactionFormFields';
|
||||
import { mapCategoryToNew } from './categoryUtils';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
import { useCallback } from 'react';
|
||||
import { Transaction } from '@/contexts/budget/types';
|
||||
import { useBudget } from '@/contexts/BudgetContext';
|
||||
import { useBudget } from '@/contexts/budget/BudgetContext';
|
||||
|
||||
export const useTransactionsOperations = (transactions: Transaction[]) => {
|
||||
const { updateTransaction: budgetUpdateTransaction, deleteTransaction: budgetDeleteTransaction } = useBudget();
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
|
||||
import { useCallback } from 'react';
|
||||
import { Transaction } from '@/contexts/budget/types';
|
||||
import { useBudget } from '@/contexts/BudgetContext';
|
||||
import { useBudget } from '@/contexts/budget/BudgetContext';
|
||||
|
||||
export const useTransactionsOperations = (transactions: Transaction[]) => {
|
||||
const { deleteTransaction: budgetDeleteTransaction } = useBudget();
|
||||
const { updateTransaction: budgetUpdateTransaction, deleteTransaction: budgetDeleteTransaction } = useBudget();
|
||||
|
||||
// 트랜잭션 업데이트 함수
|
||||
const updateTransaction = useCallback((updatedTransaction: Transaction): void => {
|
||||
try {
|
||||
budgetUpdateTransaction(updatedTransaction);
|
||||
} catch (error) {
|
||||
console.error('트랜잭션 업데이트 중 오류:', error);
|
||||
}
|
||||
}, [budgetUpdateTransaction]);
|
||||
|
||||
// 트랜잭션 삭제 함수
|
||||
const deleteTransaction = useCallback(async (id: string): Promise<boolean> => {
|
||||
try {
|
||||
budgetDeleteTransaction(id);
|
||||
@@ -17,6 +26,7 @@ export const useTransactionsOperations = (transactions: Transaction[]) => {
|
||||
}, [budgetDeleteTransaction]);
|
||||
|
||||
return {
|
||||
updateTransaction,
|
||||
deleteTransaction
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import NavBar from '@/components/NavBar';
|
||||
import ExpenseChart from '@/components/ExpenseChart';
|
||||
import AddTransactionButton from '@/components/AddTransactionButton';
|
||||
import { useBudget } from '@/contexts/BudgetContext';
|
||||
import { useBudget } from '@/contexts/budget/BudgetContext';
|
||||
import { MONTHS_KR } from '@/hooks/useTransactions';
|
||||
import { useIsMobile } from '@/hooks/use-mobile';
|
||||
import { getCategoryColor } from '@/utils/categoryColorUtils';
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
import React, { useEffect, useState, useRef, useCallback } from 'react';
|
||||
import NavBar from '@/components/NavBar';
|
||||
import AddTransactionButton from '@/components/AddTransactionButton';
|
||||
import { useBudget } from '@/contexts/BudgetContext';
|
||||
import { useBudget } from '@/contexts/budget/BudgetContext';
|
||||
import { useTransactions } from '@/hooks/transactions';
|
||||
import TransactionsHeader from '@/components/transactions/TransactionsHeader';
|
||||
import TransactionsContent from '@/components/transactions/TransactionsContent';
|
||||
import { Transaction } from '@/components/TransactionCard';
|
||||
import { Transaction } from '@/contexts/budget/types';
|
||||
import { toast } from '@/hooks/useToast.wrapper';
|
||||
|
||||
const Transactions = () => {
|
||||
|
||||
Reference in New Issue
Block a user