From ac5971d6791a1f091f1af03c548833debcd98ad5 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Thu, 31 Oct 2024 14:13:31 +0100 Subject: [PATCH] bugfixing --- src/lib/components/Searchbar.svelte | 14 +++++--------- src/lib/components/Sidecard.svelte | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/lib/components/Searchbar.svelte b/src/lib/components/Searchbar.svelte index c3319600..b00fc690 100644 --- a/src/lib/components/Searchbar.svelte +++ b/src/lib/components/Searchbar.svelte @@ -165,23 +165,19 @@ const onKeyPress = (e) => { if (e?.charCode === 13) { focusedSuggestion = ""; - const assetActions = { ETF: () => goto(`/etf/${searchQuery}`), Stock: () => goto(`/stocks/${searchQuery}`), Crypto: () => goto(`/crypto/${searchQuery}`), }; - if (showSuggestions?.length > 0) { - // Use the first search result - searchQuery = firstResult.symbol; - assetType = firstResult.type; + if (searchResults?.length > 0) { + searchQuery = searchResults.at(0).symbol; + assetType = searchResults.at(0).type; } - // Execute the appropriate action for the asset type - if (assetActions[assetType]) { - assetActions[assetType](); - } + // Call the function for the selected asset type + assetActions[assetType]?.(); // Trigger search bar action searchBarTicker(searchQuery); diff --git a/src/lib/components/Sidecard.svelte b/src/lib/components/Sidecard.svelte index 5c6a6293..bd7a9fe8 100644 --- a/src/lib/components/Sidecard.svelte +++ b/src/lib/components/Sidecard.svelte @@ -124,8 +124,8 @@ 100 )?.toFixed(2); priceTarget = - data?.getAnalystRating?.priceTarget !== ("n/a" && 0) - ? data?.getAnalystRating?.priceTarget + data?.getAnalystRating?.medianPriceTarget !== ("n/a" && 0) + ? data?.getAnalystRating?.medianPriceTarget : "-"; consensusRating = data?.getAnalystRating?.consensusRating;