import React, { useState } from 'react';
import Loading from '../../../components/Loading';
import { kindMeta, conditionLabel, relativeTime, formatDetail } from '../watchlistUtils';
import { formatNumber } from '../stockUtils';
const DAYS_OPTIONS = [
{ value: 1, label: '1D' },
{ value: 7, label: '7D' },
{ value: 30, label: '30D' },
];
const AlertCard = ({ a }) => {
const meta = kindMeta(a.kind);
const detailText = formatDetail(a.detail);
return (
{meta.label}
{a.name || a.ticker}
{a.ticker}
{relativeTime(a.fired_at)}
{conditionLabel(a.condition)}
{a.price != null && {formatNumber(a.price)}원}
{a.reason &&
{a.reason}
}
{detailText &&
{detailText}
}
);
};
const WatchlistTab = ({ wl }) => {
const [form, setForm] = useState({ ticker: '', name: '', note: '' });
const submit = async (e) => {
e.preventDefault();
if (!form.ticker.trim()) return;
const ok = await wl.add(form);
if (ok) setForm({ ticker: '', name: '', note: '' });
};
return (
<>
{/* 관심종목 관리 */}
관심종목
관심종목 관리
등록한 종목은 매매 시그널 감시 유니버스에 포함됩니다.
{wl.loading && }
{wl.error && {wl.error}
}
{wl.items.length === 0 ? (
아직 관심종목이 없습니다. 종목코드를 추가해 보세요.
) : (
)}
{/* 최근 시그널 알림 */}
시그널
최근 매매 알림
감시 종목에서 발생한 매수·매도 시그널 이력입니다.
{DAYS_OPTIONS.map((o) => (
))}
{wl.alertError && {wl.alertError}
}
{wl.alerts.length === 0 ? (
해당 기간에 발생한 알림이 없습니다.
) : (
{wl.alerts.map((a) => (
))}
)}
※ 어드바이저리 알림이며 자동매매가 아닙니다. 최종 판단은 본인 책임입니다.
>
);
};
export default WatchlistTab;