Skip to content

Commit 3a36c64

Browse files
Merge pull request #449 from FunD-StockProject/fix/qa-01-19
Refactor SearchTitle component and related styles; add stock score badge
2 parents 6c1b2a4 + 3d1cf15 commit 3a36c64

10 files changed

Lines changed: 58 additions & 122 deletions

File tree

src/components/MyPage/FCMTestButton/FCMTestButton.tsx

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/components/Search/SearchTitle/SearchTitle.Style.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export const SearchTitleContainer = styled.div({
2424
export const SearchTitleHeaderContainer = styled.div({
2525
display: 'flex',
2626
flexDirection: 'column',
27-
// alignItems: 'center',
2827

2928
fontWeight: '700',
3029
fontSize: '42px',
@@ -34,12 +33,18 @@ export const SearchTitleHeaderContainer = styled.div({
3433
[media[0]]: {
3534
fontSize: '32px',
3635
},
36+
});
3737

38-
['>p.price']: {
39-
...theme.font.heading24Semibold,
40-
color: theme.colors.sub_white,
41-
margin: '0',
42-
},
38+
export const SearchTitlePriceWrapper = styled.div({
39+
display: 'flex',
40+
alignItems: 'center',
41+
gap: '12px',
42+
});
43+
44+
export const SearchTitlePrice = styled.p({
45+
...theme.font.heading24Semibold,
46+
color: theme.colors.sub_white,
47+
margin: '0',
4348
});
4449

4550
export const SearchTitleHeaderText = styled.div({
@@ -115,6 +120,27 @@ export const SearchTitleDetailSymbol = styled.span({
115120
},
116121
});
117122

123+
export const SearchTitleScoreBadge = styled.div({
124+
boxSizing: 'border-box',
125+
display: 'flex',
126+
flexDirection: 'row',
127+
justifyContent: 'center',
128+
alignItems: 'center',
129+
padding: '2px 10px',
130+
gap: '10px',
131+
width: 'fit-content',
132+
height: '31px',
133+
border: `1px solid ${theme.colors.sub_gray9}`,
134+
borderRadius: '50px',
135+
136+
['>p']: {
137+
...theme.font.body18Medium,
138+
color: theme.colors.sub_gray6,
139+
margin: '0',
140+
whiteSpace: 'nowrap',
141+
},
142+
});
143+
118144
// export const SearchTitleDescriptionContainer = styled.div(
119145
// ({ showMoreDesc }: { showMoreDesc: boolean }) => ({
120146
// WebkitLineClamp: showMoreDesc ? '' : '2',

src/components/Search/SearchTitle/SearchTitle.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { useEffect, useRef, useState } from 'react';
33
import { useLocation, useNavigate } from 'react-router-dom';
44
import { MARKET_CODES } from '@ts/Constants';
55
import useAuthInfo from '@hooks/useAuthInfo';
6+
import { useQueryComponent } from '@hooks/useQueryComponent';
67
import { webPath } from '@router/index';
78
import Button from '@components/Common/Button';
89
import { useBuyExperimentMutation } from '@controllers/experiment/query';
10+
import { useScoreQuery } from '@controllers/stocks/query';
911
import { StockDetailInfo } from '@controllers/stocks/types';
1012
import KoreaPNG from '@assets/flags/korea.png';
1113
import OverseaPNG from '@assets/flags/oversea.png';
@@ -16,11 +18,14 @@ import {
1618
SearchTitleHeaderContainer,
1719
SearchTitleHeaderText,
1820
SearchTitleHeaderTextAnimated,
21+
SearchTitlePrice,
22+
SearchTitlePriceWrapper,
23+
SearchTitleScoreBadge,
1924
} from './SearchTitle.Style';
2025

2126
const BASE_DELAY = 1500;
2227

23-
const SearchTitleName = ({ stockInfo: { symbolName, country, price } }: { stockInfo: StockDetailInfo }) => {
28+
const SearchTitleName = ({ stockInfo: { symbolName, country, price, stockId } }: { stockInfo: StockDetailInfo }) => {
2429
const { state } = useLocation();
2530

2631
const titleTextRef = useRef<HTMLDivElement>(null);
@@ -32,6 +37,7 @@ const SearchTitleName = ({ stockInfo: { symbolName, country, price } }: { stockI
3237
instant: BASE_DELAY,
3338
});
3439
const [animation, cycleAnimation] = useCycle(...Object.keys(animationDelay));
40+
const [stockScore, suspend] = useQueryComponent({ query: useScoreQuery(stockId, country) });
3541
const concurrency = country === 'KOREA' ? '₩' : '$';
3642
useEffect(() => {
3743
if (titleTextRef.current) {
@@ -83,10 +89,17 @@ const SearchTitleName = ({ stockInfo: { symbolName, country, price } }: { stockI
8389
</SearchTitleHeaderTextAnimated>
8490
</AnimatePresence>
8591
</SearchTitleHeaderText>
86-
<p className="price">
87-
{concurrency}
88-
{price.toLocaleString()}
89-
</p>
92+
<SearchTitlePriceWrapper>
93+
<SearchTitlePrice>
94+
{concurrency}
95+
{price.toLocaleString()}
96+
</SearchTitlePrice>
97+
{!suspend && stockScore && (
98+
<SearchTitleScoreBadge>
99+
<p>인간지표 {stockScore.score}</p>
100+
</SearchTitleScoreBadge>
101+
)}
102+
</SearchTitlePriceWrapper>
90103
</SearchTitleHeaderContainer>
91104
);
92105
};

src/controllers/stocks/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const useChartInfoQuery = (id: number, periodCode: PERIOD_CODE, startDate
6464
};
6565

6666
export const useStockTableInfoQuery = (category: string, country: string) => {
67-
return useQuery<StockTableInfo>(
67+
return useQuery<StockTableInfo[]>(
6868
['stockTableInfo', category, country],
6969
() => fetchStockTable(category, country),
7070
queryOptions,

src/hooks/useQueryComponent.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { UseQueryResult } from 'react-query';
33
import ErrorComponent from '@components/Common/ErrorComponent';
44
import LoadingComponent from '@components/Common/LoadingComponent';
55

6-
export const useQueryComponent = ({ query }: { query: UseQueryResult }) => {
7-
const { data, isLoading, isError }: { data: any; isLoading: boolean; isError: boolean } = query;
6+
export const useQueryComponent = <T,>({ query }: { query: UseQueryResult<T> }) => {
7+
const { data, isLoading, isError } = query;
88

99
const [isDeferred, setIsDeferred] = useState(false);
1010

@@ -15,8 +15,8 @@ export const useQueryComponent = ({ query }: { query: UseQueryResult }) => {
1515
return () => clearTimeout(timeoutId);
1616
}, []);
1717

18-
if (isLoading) return [null, isDeferred && <LoadingComponent />];
19-
if (isError) return [null, <ErrorComponent />];
18+
if (isLoading) return [null, isDeferred && <LoadingComponent />] as const;
19+
if (isError) return [null, <ErrorComponent />] as const;
2020

21-
return [data];
21+
return [data] as const;
2222
};

src/index.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ html {
4949

5050
body {
5151
display: flex;
52-
5352
justify-items: center;
54-
5553
margin: 0px;
5654
background-color: rgba(255, 255, 255, 0.2);
5755
min-width: 320px;

src/pages/MyPage/MyPage.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useNavigate } from 'react-router-dom';
22
import useAuthInfo from '@hooks/useAuthInfo';
33
import { webPath } from '@router/index';
44
import ConfirmModal from '@components/Modal/Confirm/ConfirmModal';
5-
import FCMTestButton from '@components/MyPage/FCMTestButton/FCMTestButton';
65
import { fetchAuthLogout } from '@controllers/auth/api';
76
import { useExperimentStatusQuery } from '@controllers/experiment/query';
87
import { useBookmarkListQuery } from '@controllers/preference/query';
@@ -173,7 +172,6 @@ const MyPage = () => {
173172
</MyPageDefaultContainer>
174173
)}
175174
<span className="divider" />
176-
<FCMTestButton />
177175
<MyPageSNSContainer>
178176
<InstagramSVG onClick={handleClickInstagram} />
179177
<LinkedInSVG onClick={handleClickLinkedIn} />

src/pages/Search/Search.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ const Search = () => {
205205
const [stockInfo] = useQueryComponent({
206206
query: useSymbolNameSearchQuery(state?.symbolName, state?.country),
207207
});
208-
209208
const [selectedTab, setSelectedTab] = useState<TabKey>('HUMAN_INDEX');
210209

211210
const handleTabChange = (tab: TabKey) => {

tsconfig.app.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tsconfig.node.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)