Fix data initialization and toast issues
- Ensure toast notifications disappear after data initialization. - Resolve issues with expense items not displaying on the expense page. - Fix graph display issues on the analytics screen. - Prevent login screen from appearing after data initialization.
This commit is contained in:
@@ -31,7 +31,10 @@ const MonthlyComparisonChart: React.FC<MonthlyComparisonChartProps> = ({
|
||||
return value;
|
||||
};
|
||||
|
||||
// Empty state component
|
||||
// 데이터 확인 로깅
|
||||
console.log('MonthlyComparisonChart 데이터:', monthlyData);
|
||||
|
||||
// EmptyGraphState 컴포넌트: 데이터가 없을 때 표시
|
||||
const EmptyGraphState = () => (
|
||||
<div className="flex flex-col items-center justify-center h-48 text-gray-400">
|
||||
<p>데이터가 없습니다</p>
|
||||
@@ -39,9 +42,14 @@ const MonthlyComparisonChart: React.FC<MonthlyComparisonChartProps> = ({
|
||||
</div>
|
||||
);
|
||||
|
||||
// 데이터 여부 확인 로직 개선 - 데이터가 비어있거나 모든 값이 0인 경우도 고려
|
||||
const hasValidData = monthlyData &&
|
||||
monthlyData.length > 0 &&
|
||||
monthlyData.some(item => item.budget > 0 || item.expense > 0);
|
||||
|
||||
return (
|
||||
<div className="neuro-card h-72 w-full">
|
||||
{!isEmpty && monthlyData.length > 0 && monthlyData.some(item => item.budget > 0 || item.expense > 0) ? (
|
||||
{hasValidData ? (
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={monthlyData} margin={{
|
||||
top: 20,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Trash2 } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -28,6 +27,9 @@ const DataResetSection = () => {
|
||||
// 초기화 실행 전에 사용자 설정 백업
|
||||
const dontShowWelcomeValue = localStorage.getItem('dontShowWelcome');
|
||||
const hasVisitedBefore = localStorage.getItem('hasVisitedBefore');
|
||||
// 로그인 관련 설정도 백업
|
||||
const authSession = localStorage.getItem('authSession');
|
||||
const sb_auth = localStorage.getItem('sb-auth-token');
|
||||
|
||||
// 데이터 초기화
|
||||
resetAllStorageData();
|
||||
@@ -41,6 +43,15 @@ const DataResetSection = () => {
|
||||
localStorage.setItem('hasVisitedBefore', hasVisitedBefore);
|
||||
}
|
||||
|
||||
// 로그인 관련 설정 복원 (로그인 화면이 나타나지 않도록)
|
||||
if (authSession) {
|
||||
localStorage.setItem('authSession', authSession);
|
||||
}
|
||||
|
||||
if (sb_auth) {
|
||||
localStorage.setItem('sb-auth-token', sb_auth);
|
||||
}
|
||||
|
||||
// 스토리지 이벤트 트리거하여 다른 컴포넌트에 변경 알림
|
||||
window.dispatchEvent(new Event('transactionUpdated'));
|
||||
window.dispatchEvent(new Event('budgetDataUpdated'));
|
||||
@@ -94,7 +105,7 @@ const DataResetSection = () => {
|
||||
<DialogTitle>정말 모든 데이터를 초기화하시겠습니까?</DialogTitle>
|
||||
<DialogDescription>
|
||||
이 작업은 되돌릴 수 없으며, 모든 예산, 지출 내역, 설정이 영구적으로 삭제됩니다.
|
||||
단, '환영합니다' 화면 표시 설정은 유지됩니다.
|
||||
단, '환영합니다' 화면 표시 설정과 로그인 상태는 유지됩니다.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter className="flex flex-col sm:flex-row gap-2 sm:gap-0">
|
||||
|
||||
Reference in New Issue
Block a user