Skip to content

Commit 64fe8d6

Browse files
김병현김병현
authored andcommitted
[Fix]충돌 해결
2 parents 0af8be9 + 3bd2910 commit 64fe8d6

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

client/src/components/Headers/stockSearchComponent.tsx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import React, { useState } from 'react';
1+
import React, { useState } from "react";
22
import { useDispatch } from "react-redux";
33
import styled from "styled-components";
4+
import { toast } from "react-toastify";
45
import { changeCompanyId } from "../../reducer/CompanyId-Reducer";
56
import useGetCompanyList from "../../hooks/useGetCompanyList";
67

@@ -9,6 +10,12 @@ const search = "검색";
910
const noExistCompany = "noExistCompany";
1011
const existCompany = "existCompany";
1112

13+
const toastStyle = {
14+
fontSize: "15px",
15+
fontWeight: 350,
16+
color: "black",
17+
};
18+
1219
const StockSearchComponent: React.FC = () => {
1320
const dispatch = useDispatch();
1421
const { companyList } = useGetCompanyList();
@@ -21,15 +28,24 @@ const StockSearchComponent: React.FC = () => {
2128
const handleSearchCompany = () => {
2229
let searchResult: string = noExistCompany;
2330

31+
if (searchWord === "") {
32+
return;
33+
}
34+
2435
companyList.forEach((company: CompanyProps) => {
2536
if (company.korName === searchWord) {
26-
searchResult = existCompany ;
37+
searchResult = existCompany;
2738
dispatch(changeCompanyId(company.companyId));
2839
}
2940
});
3041

3142
if (searchResult === noExistCompany) {
32-
dispatch(changeCompanyId(-1));
43+
toast.error("존재하지 않는 종목입니다", {
44+
style: toastStyle,
45+
position: "top-right",
46+
autoClose: 1500,
47+
});
48+
return;
3349
}
3450
};
3551

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

4359
return (
4460
<SearchContainer>
45-
<StyledSearchInput
46-
value={searchWord}
47-
onChange={handleChangeSearchWord}
48-
onKeyDown={handlePressEnterToSearch}
49-
placeholder={stockSearch}
50-
/>
61+
<StyledSearchInput value={searchWord} onChange={handleChangeSearchWord} onKeyDown={handlePressEnterToSearch} placeholder={stockSearch} />
5162
<StyledSearchButton onClick={handleSearchCompany}>{search}</StyledSearchButton>
5263
</SearchContainer>
5364
);
@@ -56,20 +67,19 @@ const StockSearchComponent: React.FC = () => {
5667
export default StockSearchComponent;
5768

5869
interface CompanyProps {
59-
companyId: number;
60-
code: string;
61-
korName: string;
62-
stockAsBiResponseDto: null;
63-
stockInfResponseDto: null;
64-
}
65-
70+
companyId: number;
71+
code: string;
72+
korName: string;
73+
stockAsBiResponseDto: null;
74+
stockInfResponseDto: null;
75+
}
6676

6777
// 스타일 정의
6878

6979
const SearchContainer = styled.div`
7080
display: flex;
7181
align-items: center;
72-
flex-grow: 0.7; // 여기에 추가
82+
flex-grow: 0.7; // 여기에 추가
7383
`;
7484

7585
const StyledSearchInput = styled.input.attrs({

client/src/components/HoldingList/StockItem.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ const StockItem: React.FC<StockItemProps> = ({ companyData, stockData }) => {
6262

6363
// Format percentage to two decimal places
6464
const formattedPercentage = parseFloat(percentage.toFixed(2));
65-
66-
6765
// 이미 import된 로고들을 바탕으로 logos 객체 생성
6866
const logos: { [key: string]: string } = {
6967
'삼성전자': logosamsung,
@@ -114,7 +112,6 @@ const StockItem: React.FC<StockItemProps> = ({ companyData, stockData }) => {
114112
setIsFavorited(!isFavorited);
115113
};
116114

117-
118115
return (
119116
<EntireContainer>
120117
<ItemContainer
@@ -217,12 +214,6 @@ const FavoriteStarFilled = styled(FavoriteStar)<{ opacity: number }>`
217214
background-size: contain;
218215
`;
219216

220-
221-
222-
223-
224-
225-
226217
const StockInfo = styled.div`
227218
flex: 5 0 0;
228219
height: 100%;

0 commit comments

Comments
 (0)