From 9931d8850f719130f79c5ff82df3b43a9d8c487e Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Thu, 29 Feb 2024 16:44:29 +0900 Subject: [PATCH 1/6] feat: add condition for preventing duplicated stock --- src/app/(main)/ticker/_components/ticker-content.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/(main)/ticker/_components/ticker-content.tsx b/src/app/(main)/ticker/_components/ticker-content.tsx index 4e7a063..8ab7264 100644 --- a/src/app/(main)/ticker/_components/ticker-content.tsx +++ b/src/app/(main)/ticker/_components/ticker-content.tsx @@ -59,10 +59,17 @@ const TickerContent = React.memo(() => { if (selectedStock) { resetData(); - addStock({ ...selectedStock, count: tickerCount }); + const existingStockIndex = stocks.findIndex((stock) => stock.stockId === selectedStock.stockId); + + if (existingStockIndex !== -1) { + // 주식이 이미 존재하는 경우 업데이트 + editStock({ ...selectedStock, count: tickerCount }); + } else { + addStock({ ...selectedStock, count: tickerCount }); + } isDrawerOpenChange(false); } - }, [addStock, isDialogOpenChange, isDrawerOpenChange, resetData, selectedStock, stocks.length, tickerCount]); + }, [addStock, editStock, isDialogOpenChange, isDrawerOpenChange, resetData, selectedStock, stocks, tickerCount]); const handleInputClear = React.useCallback((type: DrawerType) => { if (type === "name") { From 29594c91a1db62ae99f5b96bb53ec4610e2f3fab Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Thu, 29 Feb 2024 16:55:34 +0900 Subject: [PATCH 2/6] feat: implement ticker default image --- .../(main)/ticker/_components/ticker-list.tsx | 21 ++++++++++++------- src/components/icons/ticker-default.tsx | 15 +++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 src/components/icons/ticker-default.tsx diff --git a/src/app/(main)/ticker/_components/ticker-list.tsx b/src/app/(main)/ticker/_components/ticker-list.tsx index 3682a7f..7d54267 100644 --- a/src/app/(main)/ticker/_components/ticker-list.tsx +++ b/src/app/(main)/ticker/_components/ticker-list.tsx @@ -3,6 +3,7 @@ import { Stock } from "@/state/stores/stocks-store"; import React from "react"; import Image from "next/image"; +import TickerDefault from "@/components/icons/ticker-default"; interface TickerProps { data: Stock[]; @@ -41,14 +42,18 @@ const TickerList = React.memo(({ data, tickerName, hasShares, onClick }: TickerP
{data.map((item, index) => (
onClick(item)}> -
- {"stock +
+ {item.logoUrl === null ? ( + + ) : ( + {"stock + )}
{getHighlightText(item.ticker)} diff --git a/src/components/icons/ticker-default.tsx b/src/components/icons/ticker-default.tsx new file mode 100644 index 0000000..140ba16 --- /dev/null +++ b/src/components/icons/ticker-default.tsx @@ -0,0 +1,15 @@ +import React from "react"; + +export interface TickerDefaultProps extends React.SVGProps {} + +const TickerDefault = React.memo(({ ...props }: TickerDefaultProps) => { + return ( + + + + + + ); +}); + +export default TickerDefault; From 83700951f80b7182b10f8051c969a5fd7542ed5f Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Thu, 29 Feb 2024 17:32:11 +0900 Subject: [PATCH 3/6] feat: implement ticker default image on dividend-row --- .../dividend/_components/dividend-row.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/(main)/report/dividend/_components/dividend-row.tsx b/src/app/(main)/report/dividend/_components/dividend-row.tsx index da4b5c1..adc44d0 100644 --- a/src/app/(main)/report/dividend/_components/dividend-row.tsx +++ b/src/app/(main)/report/dividend/_components/dividend-row.tsx @@ -1,6 +1,7 @@ import { SingleYearlyDividendResponse, StockResponse } from "@/api/generated/endpoint.schemas"; import Image from "next/image"; import React from "react"; +import TickerDefault from "@/components/icons/ticker-default"; export interface Dividend extends StockResponse { share?: number; @@ -10,13 +11,17 @@ export const DividendRow = React.memo(({ dividend }: { dividend: SingleYearlyDiv return (
- {dividend.ticker} + {dividend.logoUrl === null ? ( + + ) : ( + {dividend.ticker} + )}
From 3e1725e66728496b55cc0cb4fb7b95df49986c2e Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Thu, 29 Feb 2024 17:34:30 +0900 Subject: [PATCH 4/6] refactor: remove unused component --- .../sector-list/_components/sector-row.tsx | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 src/app/(main)/report/sector-list/_components/sector-row.tsx diff --git a/src/app/(main)/report/sector-list/_components/sector-row.tsx b/src/app/(main)/report/sector-list/_components/sector-row.tsx deleted file mode 100644 index a4c3d7d..0000000 --- a/src/app/(main)/report/sector-list/_components/sector-row.tsx +++ /dev/null @@ -1,30 +0,0 @@ -"use client"; -import { SectorRatioResponse } from "@/api/generated/endpoint.schemas"; -import ChevronRightIcon from "@/components/icons/chevron-right"; -import Image from "next/image"; -import { useRouter } from "next/navigation"; -import React from "react"; - -export interface SectorRatio extends Required {} - -export const SectorRow = React.memo(({ sector }: { sector: SectorRatio }) => { - const router = useRouter(); - - const handleSectorClick = () => { - // @TODO 수정 필요 - router.push(`/`); - }; - return ( -
- {sector.sectorName} -
-
-

{sector.sectorName}

-

{(sector.sectorRatio * 100).toFixed(0) + "%"}

-
- - -
-
- ); -}); From 75adb8ee52faec9e5da4dc907f02d5bc52983c89 Mon Sep 17 00:00:00 2001 From: JinleeJeong Date: Thu, 29 Feb 2024 17:42:53 +0900 Subject: [PATCH 5/6] feat: implement ticker default image on sector-insights-item component --- .../_components/sector-insights-item.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/(main)/report/sector-detail/_components/sector-insights-item.tsx b/src/app/(main)/report/sector-detail/_components/sector-insights-item.tsx index c97ad0c..57d5708 100644 --- a/src/app/(main)/report/sector-detail/_components/sector-insights-item.tsx +++ b/src/app/(main)/report/sector-detail/_components/sector-insights-item.tsx @@ -2,6 +2,7 @@ import { formatDateStringToMonthDay } from "@/utils/date"; import Image from "next/image"; import { useRouter } from "next/navigation"; import React, { useCallback } from "react"; +import TickerDefault from "@/components/icons/ticker-default"; interface InsightsStock { dividendYield?: number; @@ -49,14 +50,17 @@ export const SectorInsightsItem = React.memo(({ title, data, type }: SectorInsig }} >
- {stock.ticker} - + {stock.logoUrl === null ? ( + + ) : ( + {stock.ticker} + )}
{stock.ticker}

From 3298386eb53fc67b263bf355a6706af5183c1ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=A7=84=EB=A6=AC/=EC=8A=A4=ED=86=A0=EC=96=B4?= =?UTF-8?q?=ED=94=84=EB=A1=A0=ED=8A=B8=ED=8C=80?= Date: Fri, 1 Mar 2024 10:23:56 +0900 Subject: [PATCH 6/6] feat: added prev ticker count --- src/app/(main)/ticker/_components/ticker-content.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/(main)/ticker/_components/ticker-content.tsx b/src/app/(main)/ticker/_components/ticker-content.tsx index 8ab7264..4431392 100644 --- a/src/app/(main)/ticker/_components/ticker-content.tsx +++ b/src/app/(main)/ticker/_components/ticker-content.tsx @@ -59,11 +59,11 @@ const TickerContent = React.memo(() => { if (selectedStock) { resetData(); - const existingStockIndex = stocks.findIndex((stock) => stock.stockId === selectedStock.stockId); + const existingStock = stocks.find((stock) => stock.stockId === selectedStock.stockId); - if (existingStockIndex !== -1) { + if (existingStock !== undefined) { // 주식이 이미 존재하는 경우 업데이트 - editStock({ ...selectedStock, count: tickerCount }); + editStock({ ...selectedStock, count: existingStock.count + tickerCount }); } else { addStock({ ...selectedStock, count: tickerCount }); }