Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

감정분석 결과 페이지 데이터 통신 기능을 수정한다 #162

Merged
merged 1 commit into from
Nov 19, 2024
Merged
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
56 changes: 35 additions & 21 deletions src/pages/emotion/result/EmotionResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,35 @@ import variables from '@styles/Variables';
import EmotionGraph from './EmotionGraph';
import EmotionStress from './EmotionStress';
import ECharts from 'echarts-for-react';
import Footer from '@components/common/Footer';
import { useEffect, useState } from 'react';
// import Footer from '@components/common/Footer';
// import { useEffect, useState } from 'react';
import Button from '@components/common/Button';
import { useNavigate } from 'react-router-dom';

const EmotionResult = () => {
const [data, setData] = useState(null);
const result_pk = 1;

useEffect(() => {
const fetchData = async () => {
try {
const res = await fetch(`https://www.wishkr.site/emotions/results/${result_pk}`);
const result = await res.json();
setData(result);
} catch (error) {
console.error('fetching error:', error);
}
};
fetchData();
}, [result_pk]);

const analysisResult = useAnalysisStore((state) => state.analysis) || { keywords: [] };

if (!data) return <div>로딩중.. 데이터가 없음</div>;
const navigate = useNavigate();
// const [data, setData] = useState(null);
// const result_pk = 1;

// useEffect(() => {
// const fetchData = async () => {
// try {
// const res = await fetch(`https://www.wishkr.site/emotions/results/${result_pk}`);
// const result = await res.json();
// setData(result);
// } catch (error) {
// console.error('fetching error:', error);
// }
// };
// fetchData();
// }, [result_pk]);

// if (!data) return <div>로딩중.. 데이터가 없음</div>;

const handleClick = () => {
navigate('/');
};

console.log(analysisResult.keywords);

Expand Down Expand Up @@ -89,6 +95,7 @@ const EmotionResult = () => {
<ResultTextBox>
<pre>난임 스트레스 예상점수</pre>
</ResultTextBox>

<EmotionGraphContainer>
<div className="flex-box">
<EmotionStress />
Expand All @@ -103,7 +110,14 @@ const EmotionResult = () => {
</EmotionGraphContainer>
</ResultSection>

<Footer />
<Button
onClick={handleClick}
fixed={true}
disabled={false}
type="submit"
size="medium"
text="메인화면으로 이동"
/>
</>
);
};
Expand Down