Skip to content

Commit

Permalink
[Fix]충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
김병현 authored and 김병현 committed Sep 19, 2023
2 parents 0af8be9 + 3bd2910 commit 64fe8d6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
44 changes: 27 additions & 17 deletions client/src/components/Headers/stockSearchComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import React, { useState } from "react";
import { useDispatch } from "react-redux";
import styled from "styled-components";
import { toast } from "react-toastify";
import { changeCompanyId } from "../../reducer/CompanyId-Reducer";
import useGetCompanyList from "../../hooks/useGetCompanyList";

Expand All @@ -9,6 +10,12 @@ const search = "검색";
const noExistCompany = "noExistCompany";
const existCompany = "existCompany";

const toastStyle = {
fontSize: "15px",
fontWeight: 350,
color: "black",
};

const StockSearchComponent: React.FC = () => {
const dispatch = useDispatch();
const { companyList } = useGetCompanyList();
Expand All @@ -21,15 +28,24 @@ const StockSearchComponent: React.FC = () => {
const handleSearchCompany = () => {
let searchResult: string = noExistCompany;

if (searchWord === "") {
return;
}

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

if (searchResult === noExistCompany) {
dispatch(changeCompanyId(-1));
toast.error("존재하지 않는 종목입니다", {
style: toastStyle,
position: "top-right",
autoClose: 1500,
});
return;
}
};

Expand All @@ -42,12 +58,7 @@ const StockSearchComponent: React.FC = () => {

return (
<SearchContainer>
<StyledSearchInput
value={searchWord}
onChange={handleChangeSearchWord}
onKeyDown={handlePressEnterToSearch}
placeholder={stockSearch}
/>
<StyledSearchInput value={searchWord} onChange={handleChangeSearchWord} onKeyDown={handlePressEnterToSearch} placeholder={stockSearch} />
<StyledSearchButton onClick={handleSearchCompany}>{search}</StyledSearchButton>
</SearchContainer>
);
Expand All @@ -56,20 +67,19 @@ const StockSearchComponent: React.FC = () => {
export default StockSearchComponent;

interface CompanyProps {
companyId: number;
code: string;
korName: string;
stockAsBiResponseDto: null;
stockInfResponseDto: null;
}

companyId: number;
code: string;
korName: string;
stockAsBiResponseDto: null;
stockInfResponseDto: null;
}

// 스타일 정의

const SearchContainer = styled.div`
display: flex;
align-items: center;
flex-grow: 0.7; // 여기에 추가
flex-grow: 0.7; // 여기에 추가
`;

const StyledSearchInput = styled.input.attrs({
Expand Down
9 changes: 0 additions & 9 deletions client/src/components/HoldingList/StockItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ const StockItem: React.FC<StockItemProps> = ({ companyData, stockData }) => {

// Format percentage to two decimal places
const formattedPercentage = parseFloat(percentage.toFixed(2));


// 이미 import된 로고들을 바탕으로 logos 객체 생성
const logos: { [key: string]: string } = {
'삼성전자': logosamsung,
Expand Down Expand Up @@ -114,7 +112,6 @@ const StockItem: React.FC<StockItemProps> = ({ companyData, stockData }) => {
setIsFavorited(!isFavorited);
};


return (
<EntireContainer>
<ItemContainer
Expand Down Expand Up @@ -217,12 +214,6 @@ const FavoriteStarFilled = styled(FavoriteStar)<{ opacity: number }>`
background-size: contain;
`;







const StockInfo = styled.div`
flex: 5 0 0;
height: 100%;
Expand Down

0 comments on commit 64fe8d6

Please sign in to comment.