Skip to content

Commit

Permalink
๐Ÿ”ง fix: API ์ฃผ์†Œ ๋ณ€๊ฒฝ & useEffect ์ฝ”๋“œ ์œ„์น˜ ๋ณ€๊ฒฝ
Browse files Browse the repository at this point in the history
  • Loading branch information
dannysir committed Dec 3, 2024
1 parent ce04401 commit 1549e84
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
37 changes: 20 additions & 17 deletions FE/src/components/StocksDetail/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ export default function Header({ code, data }: StocksDetailHeaderProps) {
const { isLogin } = useAuthStore();
const { toggleModal } = useLoginModalStore();

const stockInfo: { label: string; value: string }[] = [
{ label: '์‹œ์ด', value: `${Number(hts_avls).toLocaleString()}์–ต์›` },
{ label: 'PER', value: `${per}๋ฐฐ` },
];

const colorStyleBySign =
currPrdyVrssSign === '3'
? ''
: currPrdyVrssSign < '3'
? 'text-juga-red-60'
: 'text-juga-blue-40';

const percentAbsolute = Math.abs(Number(currPrdyRate)).toFixed(2);

const plusOrMinus =
currPrdyVrssSign === '3' ? '' : currPrdyVrssSign < '3' ? '+' : '-';

// const { debounceValue } = useDebounce(isBookmarked, 1000);
// const isInitialMount = useRef(true);

Expand All @@ -50,6 +67,9 @@ export default function Header({ code, data }: StocksDetailHeaderProps) {
// unbookmark(code);
// }
// }, [code, debounceValue]);
useEffect(() => {
setIsBookmarked(is_bookmarked);
}, [is_bookmarked]);

useEffect(() => {
setCurrPrice(stck_prpr);
Expand Down Expand Up @@ -77,23 +97,6 @@ export default function Header({ code, data }: StocksDetailHeaderProps) {
};
}, [code]);

const stockInfo: { label: string; value: string }[] = [
{ label: '์‹œ์ด', value: `${Number(hts_avls).toLocaleString()}์–ต์›` },
{ label: 'PER', value: `${per}๋ฐฐ` },
];

const colorStyleBySign =
currPrdyVrssSign === '3'
? ''
: currPrdyVrssSign < '3'
? 'text-juga-red-60'
: 'text-juga-blue-40';

const percentAbsolute = Math.abs(Number(currPrdyRate)).toFixed(2);

const plusOrMinus =
currPrdyVrssSign === '3' ? '' : currPrdyVrssSign < '3' ? '+' : '-';

return (
<div className='flex h-16 w-full items-center justify-between px-2'>
<div className='flex flex-col font-semibold'>
Expand Down
2 changes: 1 addition & 1 deletion FE/src/service/stocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function getStocksChartDataByCode(

export async function unsubscribe(code: string) {
return fetch(
`${import.meta.env.VITE_API_URL}/stocks/trade-history/${code}/unsubscribe`,
`${import.meta.env.VITE_API_URL}/stocks/trade-history/unsubscribe?stockCode=${code}`,
{
headers: { 'Content-Type': 'application/json' },
},
Expand Down

0 comments on commit 1549e84

Please sign in to comment.