Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 0 additions & 146 deletions app.py

This file was deleted.

122 changes: 56 additions & 66 deletions src/app/components/analyze/AnalyzeContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@/app/constants/prediction';
import { useEffect, useState } from 'react';
import { callGet } from '@/app/utils/callApi';
import Link from 'next/link';
import Icons from '../common/Icons';

const AnalyzeContainer = () => {
Expand All @@ -20,8 +21,8 @@ const AnalyzeContainer = () => {

const [nickname, setNickname] = useState<string>('');
const [analysisData, setAnalysisData] = useState<any>(null);
const [errorMessage, setErrorMessage] = useState<string>('');

// Fetch user nickname
useEffect(() => {
const fetchUser = async () => {
try {
Expand All @@ -39,21 +40,31 @@ const AnalyzeContainer = () => {
fetchUser();
}, []);

// Fetch analysis data
useEffect(() => {
const fetchAnalysisData = async () => {
try {
const response = await callGet('/api/analysis');
if (response.isSuccess) {
setAnalysisData(response.result);
} else {
console.error(
'분석 데이터를 가져오는데 실패했습니다:',
response.message,
);
switch (response.code) {
case 'INVESTMENT_ANALYSIS_001':
setErrorMessage('최소 투자 내역 수를 충족하지 못했습니다.');
break;
case 'INVESTMENT_ANALYSIS_002':
case 'INVESTMENT_ANALYSIS_003':
case 'INVESTMENT_ANALYSIS_004':
case 'INVESTMENT_ANALYSIS_005':
setErrorMessage('서버 요청 중 오류가 발생했습니다.');
break;
default:
setErrorMessage('알 수 없는 오류가 발생했습니다.');
break;
}
}
} catch (error) {
console.error('API 요청 중 오류 발생:', error);
setErrorMessage('서버 요청 중 오류가 발생했습니다.');
}
};

Expand Down Expand Up @@ -88,68 +99,47 @@ const AnalyzeContainer = () => {
</div>
</motion.div>

{analysisData ? (
<>
{/* Investment Style */}
<motion.div
variants={fadeInVariants}
className="px-[6%] w-full h-auto flex-col flex gap-3"
>
<div className="w-full px-3 pt-3 pb-1.5 bg-white border-b border-main-1 justify-between items-end flex">
<div className="text-center text-black text-2xl font-bold leading-9">
{ANALYZE_RESULT_TITLE[0]}
</div>
<div className="text-center text-gray-1 text-xs flex items-center gap-1 tracking-wide">
<Icons name={infoIcon} />
<p>{ANALYZE_RESULT_GUIDE[0]}</p>
</div>
</div>
<div className="pl-10 leading-9 tracking-wide">
<p>
<span className="font-bold">1. 위험도 :</span>{' '}
{analysisData.investmentStyle.riskLevel}
</p>
<p>
<span className="font-bold">2. 거래 패턴 :</span>{' '}
{analysisData.investmentStyle.tradingPattern}
</p>
<p>
<span className="font-bold">3. 분석 :</span>{' '}
{analysisData.investmentStyle.analysis}
</p>
</div>
</motion.div>

{/* Investment Strategy */}
<motion.div
variants={fadeInVariants}
className="px-[6%] w-full h-auto flex-col flex gap-3"
>
<div className="w-full px-3 pt-3 pb-1.5 bg-white border-b border-main-1 justify-between items-end flex">
<div className="text-center text-black text-2xl font-bold leading-9">
{ANALYZE_RESULT_TITLE[1]}
</div>
<div className="text-center text-gray-1 text-xs flex items-center gap-1 tracking-wide">
<Icons name={infoIcon} />
<p>{ANALYZE_RESULT_GUIDE[1]}</p>
</div>
{errorMessage ? (
<div className="text-center mt-[100px] text-black font-bold text-xl flex flex-col ">
⚠️ {errorMessage}
<Link href="/simulation">
<button
type="button"
className="text-sm text-white bg-main-1 px-4 py-2 rounded hover:bg-main-2 transition-all mt-[100px]"
>
모의 투자 하러 가기
</button>
</Link>
</div>
) : analysisData ? (
<motion.div
variants={fadeInVariants}
className="px-[6%] w-full h-auto flex-col flex gap-3"
>
<div className="w-full px-3 pt-3 pb-1.5 bg-white border-b border-main-1 justify-between items-end flex">
<div className="text-center text-black text-2xl font-bold leading-9">
{ANALYZE_RESULT_TITLE[0]}
</div>
<div className="pl-10 leading-9 tracking-wide">
<p>
<span className="font-bold">1. 추천 전략 :</span>{' '}
{analysisData.investmentStrategy.recommendation}
</p>
<p>
<span className="font-bold">2. 리스크 관리 :</span>{' '}
{analysisData.investmentStrategy.riskManagement}
</p>
<p>
<span className="font-bold">3. 분석 :</span>{' '}
{analysisData.investmentStrategy.analysis}
</p>
<div className="text-center text-gray-1 text-xs flex items-center gap-1 tracking-wide">
<Icons name={infoIcon} />
<p>{ANALYZE_RESULT_GUIDE[0]}</p>
</div>
</motion.div>
</>
</div>
<div className="pl-10 leading-9 tracking-wide">
<p>
<span className="font-bold">1. 위험도 :</span>{' '}
{analysisData.investmentStyle.riskLevel}
</p>
<p>
<span className="font-bold">2. 거래 패턴 :</span>{' '}
{analysisData.investmentStyle.tradingPattern}
</p>
<p>
<span className="font-bold">3. 분석 :</span>{' '}
{analysisData.investmentStyle.analysis}
</p>
</div>
</motion.div>
) : (
<div>
<motion.div
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/blog/detail/BlogComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const BlogComment = ({ postId, currentUserId }: BlogCommentProps) => {
try {
const response = await callGet(`/api/comment?id=${postId}`);
if (response.isSuccess) {
console.log('댓글 데이터 갱신:', response.result); // 디버깅
console.log('댓글 데이터 갱신:', response.result);
setComments(response.result);
}
} catch (error) {
Expand Down
6 changes: 5 additions & 1 deletion src/app/components/blog/detail/BlogDetailContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const BlogDetailContainer = ({ postId }: PostDetailProps) => {
const currentUserId = user?.result?.nickname;
const router = useRouter();

// Scroll to top before the component is painted
useLayoutEffect(() => {
window.scrollTo(0, 0);
}, []);

useEffect(() => {
console.log(postId, '받아온 아이디');
console.log(currentUserId, '유저 아이디');

const fetchData = async () => {
try {
Expand Down Expand Up @@ -69,6 +69,9 @@ const BlogDetailContainer = ({ postId }: PostDetailProps) => {
}}
/>
))}
{/* <div className="absolute top-[200px] font-semibold text-[20px]">
게시물을 찾을 수 없습니다.
</div> */}
</div>
);
}
Expand Down Expand Up @@ -111,6 +114,7 @@ const BlogDetailContainer = ({ postId }: PostDetailProps) => {
nickname={blogData.nickname}
createdAt={blogData.createdAt}
userId={blogData.userId}
currentUserId={currentUserId}
onNicknameClick={handleNicknameClick}
following={blogData.following}
/>
Expand Down
Loading
Loading