Skip to content

Commit

Permalink
[Remove] 테스트 코드 및 불필요한 차트 컴포넌트 삭제
Browse files Browse the repository at this point in the history
- 중앙 차트에서 차트 갱신 이벤트 테스트 위해 작성했던 코드 삭제 (기능 필요한 컴포넌트로 로직 이동 완료)
- 중앙 차트 부분에 렌더링 되던 코스피 차트 삭제 (오른쪽 메뉴 컴포넌트에서 띄우는 것으로 변경되어 불필요해짐)

Issues #14
  • Loading branch information
novice1993 committed Sep 15, 2023
1 parent 0e8bb3c commit a50ac65
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 227 deletions.
8 changes: 1 addition & 7 deletions client/src/components/CentralChart/Index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { useSelector } from "react-redux";
import { styled } from "styled-components";
import { StateProps } from "../../models/stateProps";

import UpperMenuBar from "../CentralChartMenu/Index";
import KospiChart from "./KospiChart";
import StockChart from "./StockChart";

const CentralChart = () => {
const companyId = useSelector((state: StateProps) => state.companyId);

return (
<Container>
<UpperMenuBar />
{companyId === 0 ? <KospiChart /> : <StockChart />}
<StockChart />
</Container>
);
};
Expand Down
131 changes: 0 additions & 131 deletions client/src/components/CentralChart/KospiChart.tsx

This file was deleted.

90 changes: 1 addition & 89 deletions client/src/components/CentralChart/StockChart.tsx
Original file line number Diff line number Diff line change
@@ -1,86 +1,19 @@
import { useSelector, useDispatch } from "react-redux";
import { useSelector } from "react-redux";
import { styled } from "styled-components";
import EChartsReact from "echarts-for-react";
import { StateProps } from "../../models/stateProps";
import { changeCompanyId } from "../../reducer/CompanyId-Reducer";

import useGetStockData from "../../hooks/useGetStockData";
import useGetStockChart from "../../hooks/useGetStockChart";

// 🔴 회사 목록 데이터 불러오는 로직
import useGetCompanyList from "../../hooks/useGetCompanyList";

const loadingText = "로딩 중 입니다...";
const errorText = "화면을 불러올 수 없습니다";

//🔴 테스트
import { useState } from "react";

const StockChart = () => {
const companyId = useSelector((state: StateProps) => state.companyId);
const dispatch = useDispatch();

const { stockPriceLoading, stockPriceError } = useGetStockData(companyId);
const { options, chartStyle } = useGetStockChart(companyId);

// 🔴 차트 변환 테스트

// 🔴 1) 검색 이벤트
const { companyList, compnayListLoading, companyListError } = useGetCompanyList();
const [searchWord, setSearchWord] = useState("");

if (compnayListLoading) {
return <p>회사정보 불러오는 중</p>;
}

if (companyListError) {
return <p>에러 발생</p>;
}

const handleChangeSearchWord = (e: React.ChangeEvent<HTMLInputElement>) => {
setSearchWord(e.target.value);
};

const handleSearchCompany = () => {
let searchResult: string = "noExistCompany";

companyList.forEach((company: CompanyProps) => {
if (company.korName === searchWord) {
searchResult = "existCompany";
dispatch(changeCompanyId(company.companyId));
}
});

if (searchResult === "noExistCompany") {
dispatch(changeCompanyId(-1));
}
};

const handlePressEmnterToSearch = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.code === "Enter" && e.nativeEvent.isComposing === false) {
handleSearchCompany();
setSearchWord("");
}
};

// 🔴 2) 클릭 이벤트
const handleKospi = () => {
dispatch(changeCompanyId(0));
};

const handlePlus = () => {
dispatch(changeCompanyId(companyId + 1));
};

const handleStock1 = () => {
dispatch(changeCompanyId(1));
};

const handleStock10 = () => {
dispatch(changeCompanyId(10));
};
//

if (stockPriceLoading) {
return <LoadingContainer>{loadingText}</LoadingContainer>;
}
Expand All @@ -91,17 +24,6 @@ const StockChart = () => {

return (
<Container>
{/* 🔴 차트 변경 이벤트 테스트 */}
<label>
종목 검색
<input onChange={handleChangeSearchWord} onKeyDown={handlePressEmnterToSearch} />
<button onClick={handleSearchCompany}>검색</button>
</label>
<button onClick={handleKospi}>코스피 버튼</button>
<button onClick={handlePlus}>CompanyId +1</button>
<button onClick={handleStock1}>1번 주식 버튼</button>
<button onClick={handleStock10}>10번 주식 버튼</button>
{/* 🔴 차트 변경 이벤트 테스트 */}
<EChartsReact option={options} style={chartStyle} />
</Container>
);
Expand Down Expand Up @@ -130,13 +52,3 @@ const LoadingContainer = styled.div`
`;

const ErrorContainer = styled(LoadingContainer)``;

//🔴 테스트
// type 선언
interface CompanyProps {
companyId: number;
code: string;
korName: string;
stockAsBiResponseDto: null;
stockInfResponseDto: null;
}

0 comments on commit a50ac65

Please sign in to comment.