From ad92cbeef20158b7ffc6caba42ff740d036131f4 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 22 Jul 2024 13:28:06 +0200 Subject: [PATCH] ui fixes --- .../etf/[tickerID]/options/+page.svelte | 6 +- src/routes/politicians/flow-data/+page.svelte | 10 +- .../stocks/[tickerID]/analyst/+page.svelte | 126 +++++++++++------- .../stocks/[tickerID]/options/+page.svelte | 4 +- 4 files changed, 85 insertions(+), 61 deletions(-) diff --git a/src/routes/etf/[tickerID]/options/+page.svelte b/src/routes/etf/[tickerID]/options/+page.svelte index 2c49f60c..81238ea0 100644 --- a/src/routes/etf/[tickerID]/options/+page.svelte +++ b/src/routes/etf/[tickerID]/options/+page.svelte @@ -526,15 +526,15 @@ $: { - + {formatTime(item?.time)} - + {formatDate(item?.date)} - + {item?.dte < 0 ? 'expired' : item?.dte +'d'} diff --git a/src/routes/politicians/flow-data/+page.svelte b/src/routes/politicians/flow-data/+page.svelte index 093dd613..4963841b 100644 --- a/src/routes/politicians/flow-data/+page.svelte +++ b/src/routes/politicians/flow-data/+page.svelte @@ -632,25 +632,25 @@ - assetSelector(item?.ticker, item?.assetType)} class="cursor-pointer text-start text-xs sm:text-sm text-blue-400"> + assetSelector(item?.ticker, item?.assetType)} class="cursor-pointer text-start whitespace-nowrap text-sm text-blue-400">
{item?.ticker?.length !== 0 ? item?.ticker : '-'} {item?.assetDescription.length > charNumber ? formatString(item?.assetDescription.slice(0,charNumber)) + "..." : formatString(item?.assetDescription)?.replace("- Common Stock", "")?.replace("Common Stock", "")}
- + {new Date(item?.transactionDate)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} - + {new Date(item?.disclosureDate)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} - + {item?.amount?.replace("$1,000,001 - $5,000,000","$1Mio - $5Mio")} - + {#if item?.type === 'Bought'} Bought {:else if item?.type === 'Sold'} diff --git a/src/routes/stocks/[tickerID]/analyst/+page.svelte b/src/routes/stocks/[tickerID]/analyst/+page.svelte index 855362ca..b6738b73 100644 --- a/src/routes/stocks/[tickerID]/analyst/+page.svelte +++ b/src/routes/stocks/[tickerID]/analyst/+page.svelte @@ -5,6 +5,7 @@ import InfoModal from '$lib/components/InfoModal.svelte'; import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import { goto } from '$app/navigation'; import UpgradeToPro from '$lib/components/UpgradeToPro.svelte'; +import { Motion, AnimateSharedLayout } from "svelte-motion"; export let data; @@ -17,10 +18,37 @@ let numOfAnalyst = 0; let consensusRating = 'n/a'; let changesPercentage = 0; -let filterRule = 'all'; +const tabs = [ + { + title: "All Analysts", + }, + { + title: "Top Analysts", + } +]; +let activeIdx = 0; +function changeTab(index) { + activeIdx = index; + + if(Object?.keys(analystRating)?.length !== 0) { + numOfAnalyst = analystRating?.numOfAnalyst; + priceTarget = analystRating?.priceTarget + consensusRating = analystRating?.consensusRating; + changesPercentage = ((priceTarget/$currentPortfolioPrice -1)*100)?.toFixed(2) ?? 0; + + } + if (activeIdx === 1) { + rawData = data?.getAnalystTickerHistory?.filter(item => item?.analystScore >=4) + historyList = rawData?.slice(0,10) + } + else { + rawData = data?.getAnalystTickerHistory ?? []; + historyList = rawData?.slice(0,10) + } +} async function infiniteHandler({ detail: { loaded, complete } }) { @@ -34,29 +62,7 @@ if (historyList?.length === rawData?.length) { } } -$: { - if(filterRule) { - if(Object?.keys(analystRating)?.length !== 0) { - numOfAnalyst = analystRating?.numOfAnalyst; - priceTarget = analystRating?.priceTarget - consensusRating = analystRating?.consensusRating; - changesPercentage = ((priceTarget/$currentPortfolioPrice -1)*100)?.toFixed(2) ?? 0; - - - } - if (filterRule === 'topAnalysts') { - rawData = data?.getAnalystTickerHistory?.filter(item => item?.analystScore >=4) - historyList = rawData?.slice(0,10) - } - else { - rawData = data?.getAnalystTickerHistory ?? []; - historyList = rawData?.slice(0,10) - } - - } -} - function latestInfoDate(inputDate) { // Convert the input date string to milliseconds since epoch @@ -75,6 +81,9 @@ function latestInfoDate(inputDate) { return differenceInDays <=4; } + +changeTab(0) + @@ -227,36 +236,50 @@ function latestInfoDate(inputDate) { content={"Filter for analysts rated 4+ stars focusing on their win rate and average return per rating. Analysts with 4+ stars typically exhibit both high accuracy and high return per rating."} id={"topAnalystsInfo"} /> - +
+
+ + {#each tabs as item, i} + + {/each} + +
+
-
- - +
+ + +
+
- - - + + + @@ -291,13 +314,13 @@ function latestInfoDate(inputDate) {
AnalystRatingDateAnalystRatingDate
- + {item?.rating_current} - {item?.action_company?.replace('Initiates Coverage On','Initiates')} + {item?.action_company?.replace('Initiates Coverage On','Initiates')}
{#if Math?.ceil(item?.adjusted_pt_prior) !== 0} - ${Math?.ceil(item?.adjusted_pt_prior)} + ${Math?.ceil(item?.adjusted_pt_prior)} ${Math?.ceil(item?.adjusted_pt_current)} {:else if Math?.ceil(item?.adjusted_pt_current) !== 0} @@ -327,6 +350,7 @@ function latestInfoDate(inputDate) {
+
{#if data?.user?.tier === 'Pro'} diff --git a/src/routes/stocks/[tickerID]/options/+page.svelte b/src/routes/stocks/[tickerID]/options/+page.svelte index 8c9db727..0d78e0e8 100644 --- a/src/routes/stocks/[tickerID]/options/+page.svelte +++ b/src/routes/stocks/[tickerID]/options/+page.svelte @@ -523,7 +523,7 @@ $: { - + {formatTime(item?.time)} @@ -531,7 +531,7 @@ $: { {formatDate(item?.date)} - + {item?.dte < 0 ? 'expired' : item?.dte +'d'}