import React, { useMemo } from 'react';
import { useAppSettings } from '../../hooks/useAppSettings';
import { resetPaperAccount, type PaperAllocationDto } from '../../utils/backendApi';
import PaperSplitPanel from './PaperSplitPanel';
import PaperSymbolStageSettings from './PaperSymbolStageSettings';
interface Props {
selectedMarket?: string;
allocations?: PaperAllocationDto[];
onSettingsSaved?: () => void;
onAccountReset?: () => void;
onOpenSettings?: () => void;
}
const SettingsFieldRow: React.FC<{ label: string; children: React.ReactNode }> = ({ label, children }) => (
{label}
{children}
);
const PaperLeftSettingsTab: React.FC = ({
selectedMarket,
allocations = [],
onSettingsSaved,
onAccountReset,
onOpenSettings,
}) => {
const { defaults, save, isLoaded } = useAppSettings();
const selectedAlloc = useMemo(
() => allocations.find(a => a.symbol === selectedMarket),
[allocations, selectedMarket],
);
if (!isLoaded) {
return 설정 로딩…
;
}
const patch = (p: Parameters[0]) => {
save(p);
onSettingsSaved?.();
};
const handleReset = async () => {
if (!window.confirm('모의투자 계좌를 초기화합니다. 계속할까요?')) return;
const res = await resetPaperAccount();
if (res) onAccountReset?.();
};
const top = (
{onOpenSettings && (
)}
);
const bottom = (
{selectedMarket ? (
) : (
중앙 투자금 관리에서 종목을 선택하면 분할 매매 단계를 설정할 수 있습니다.
)}
);
return (
);
};
export default PaperLeftSettingsTab;