From 0da4a032685f29c479300b1e3184afbf506b0d44 Mon Sep 17 00:00:00 2001 From: cindyCho Date: Wed, 1 Jan 2025 19:00:23 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20stockInfo=EA=B0=80=20null=20=EC=9D=BC=20?= =?UTF-8?q?=EC=88=98=EB=8F=84=20=EC=9E=88=EB=8A=94=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=B4=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_components/order-stock/buy-and-sell/current-price.tsx | 4 ++++ .../[id]/_components/order-stock/buy-and-sell/index.tsx | 4 +++- .../[id]/_components/order-stock/buy-and-sell/input-field.tsx | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/search/[id]/_components/order-stock/buy-and-sell/current-price.tsx b/src/app/search/[id]/_components/order-stock/buy-and-sell/current-price.tsx index 6c6f525..cad203d 100644 --- a/src/app/search/[id]/_components/order-stock/buy-and-sell/current-price.tsx +++ b/src/app/search/[id]/_components/order-stock/buy-and-sell/current-price.tsx @@ -8,6 +8,10 @@ import { getKoreanPrice } from "@/utils/price"; export default function CurrentPrice() { const { stockInfo } = useStockInfoContext(); + if (!stockInfo) { + return
주식 정보를 불러오고 있습니다.
; + } + return (
{Array.from({ length: 4 }).map((_, index) => ( diff --git a/src/app/search/[id]/_components/order-stock/buy-and-sell/index.tsx b/src/app/search/[id]/_components/order-stock/buy-and-sell/index.tsx index 7218a37..c299273 100644 --- a/src/app/search/[id]/_components/order-stock/buy-and-sell/index.tsx +++ b/src/app/search/[id]/_components/order-stock/buy-and-sell/index.tsx @@ -81,7 +81,9 @@ export default function BuyAndSell({ setPriceType(newPriceType); setValue( "bidding", - newPriceType === PriceType.Market ? Number(stockInfo.stockPrice) : 0, + newPriceType === PriceType.Market + ? Number(stockInfo?.stockPrice ?? 0) + : 0, ); }; diff --git a/src/app/search/[id]/_components/order-stock/buy-and-sell/input-field.tsx b/src/app/search/[id]/_components/order-stock/buy-and-sell/input-field.tsx index f7d14db..28be46a 100644 --- a/src/app/search/[id]/_components/order-stock/buy-and-sell/input-field.tsx +++ b/src/app/search/[id]/_components/order-stock/buy-and-sell/input-field.tsx @@ -77,7 +77,7 @@ export default function InputField({ number={type === "count" && quantity} state={state ?? ""} setState={(value) => setState(type, value ? Number(value) : 0)} - stockPrice={type === "bidding" && stockInfo.stockPrice} + stockPrice={type === "bidding" ? stockInfo?.stockPrice : undefined} />