fix: add toast error feedback for API failures in signals and data explorer pages

Replace silent console.error-only handling with user-visible toast notifications
using sonner, while keeping console.error for debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
머니페니 2026-03-18 22:22:22 +09:00
parent b80feb7176
commit f12709ea79
2 changed files with 14 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { api } from '@/lib/api';
import { toast } from 'sonner';
type Tab = 'stocks' | 'etfs' | 'sectors' | 'valuations';
@ -96,7 +97,9 @@ export default function DataExplorerPage() {
const endpoint = `/api/data/${tab}?${params}`;
const result = await api.get<PaginatedResponse<unknown>>(endpoint);
setData(result);
} catch {
} catch (err) {
console.error('Failed to fetch data:', err);
toast.error('데이터를 불러오는데 실패했습니다.');
setData(null);
} finally {
setFetching(false);
@ -128,7 +131,9 @@ export default function DataExplorerPage() {
: `/api/data/etfs/${ticker}/prices`;
const result = await api.get<PricePoint[]>(endpoint);
setPrices(result);
} catch {
} catch (err) {
console.error('Failed to fetch prices:', err);
toast.error('가격 데이터를 불러오는데 실패했습니다.');
setPrices([]);
} finally {
setPriceLoading(false);

View File

@ -25,6 +25,7 @@ import {
SelectValue,
} from '@/components/ui/select';
import { api } from '@/lib/api';
import { toast } from 'sonner';
import { Radio, History, RefreshCw, ArrowUpCircle, ArrowDownCircle, MinusCircle, Play } from 'lucide-react';
interface Signal {
@ -159,6 +160,7 @@ export default function SignalsPage() {
setTodaySignals(data);
} catch (err) {
console.error('Failed to fetch today signals:', err);
toast.error('오늘의 신호를 불러오는데 실패했습니다.');
}
};
@ -174,6 +176,7 @@ export default function SignalsPage() {
setHistorySignals(data);
} catch (err) {
console.error('Failed to fetch signal history:', err);
toast.error('신호 이력을 불러오는데 실패했습니다.');
}
};
@ -183,6 +186,7 @@ export default function SignalsPage() {
setPortfolios(data);
} catch (err) {
console.error('Failed to fetch portfolios:', err);
toast.error('포트폴리오 목록을 불러오는데 실패했습니다.');
}
};
@ -250,8 +254,9 @@ export default function SignalsPage() {
if (ps.recommended_quantity > 0) {
setExecuteQuantity(String(ps.recommended_quantity));
}
} catch {
// Position sizing is optional
} catch (err) {
console.error('Failed to fetch position sizing:', err);
toast.error('포지션 사이징 정보를 불러오는데 실패했습니다.');
}
}
}