From c1f175f9bdfcc64384e8f7bb520de93af3086e1f Mon Sep 17 00:00:00 2001 From: zephyrdark Date: Tue, 3 Feb 2026 07:13:14 +0900 Subject: [PATCH] feat: add new portfolio creation page --- frontend/src/app/portfolio/new/page.tsx | 103 ++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 frontend/src/app/portfolio/new/page.tsx diff --git a/frontend/src/app/portfolio/new/page.tsx b/frontend/src/app/portfolio/new/page.tsx new file mode 100644 index 0000000..cf0eb48 --- /dev/null +++ b/frontend/src/app/portfolio/new/page.tsx @@ -0,0 +1,103 @@ +'use client'; + +import { useState } from 'react'; +import { useRouter } from 'next/navigation'; +import Sidebar from '@/components/layout/Sidebar'; +import Header from '@/components/layout/Header'; +import { api } from '@/lib/api'; + +export default function NewPortfolioPage() { + const router = useRouter(); + const [name, setName] = useState(''); + const [portfolioType, setPortfolioType] = useState('general'); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setLoading(true); + setError(null); + + try { + const portfolio = await api.post('/api/portfolios', { + name, + portfolio_type: portfolioType, + }); + router.push(`/portfolio/${(portfolio as { id: number }).id}`); + } catch (err) { + const message = err instanceof Error ? err.message : 'Failed to create portfolio'; + setError(message); + } finally { + setLoading(false); + } + }; + + return ( +
+ +
+
+
+

새 포트폴리오

+ + {error && ( +
+ {error} +
+ )} + +
+
+
+ + setName(e.target.value)} + className="w-full px-3 py-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder="예: 퇴직연금 포트폴리오" + required + /> +
+ +
+ + +
+ +
+ + +
+
+
+
+
+
+ ); +}