diff --git a/src/lib/components/shadcn/table/table-row.svelte b/src/lib/components/shadcn/table/table-row.svelte index 4a724c32..298cf563 100644 --- a/src/lib/components/shadcn/table/table-row.svelte +++ b/src/lib/components/shadcn/table/table-row.svelte @@ -12,7 +12,7 @@ { - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } - }); + import { numberOfUnreadNotification} from '$lib/store'; export let data; - let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL; - - const rawData = data?.getDailyGainerLoserActive; - const rssFeedWIIM = data?.getRssFeedWIIM; - - - - let gainer = rawData?.gainers['1D']?.slice(0,5); - let loser = rawData?.losers['1D']?.slice(0,5); - let active = rawData?.active['1D']?.slice(0,5); - //let sliderList = rawData?.active['1D']; - - let gainerLoserTickers = []; - let showLoser = false; - let buttonText = 'Top Winners'; - - let trendingText = 'gainer'; - gainerLoserTickers = gainer; - -function scrollToItem(state) { - trendingText = state; - - const item = document?.getElementById('start-trending-slider'); - if (item) { - item?.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'start' }); - } - -} - - - - function handleClick() { - showLoser = !showLoser; - buttonText = showLoser ? 'Top Losers' : 'Top Winners'; - - if(showLoser) - { - gainerLoserTickers = loser; - } - else { - gainerLoserTickers = gainer; - } - - - } - + const quickInfo = data?.getDashboard?.quickInfo; function latestInfoDate(inputDate) { // Convert the input date string to milliseconds since epoch @@ -104,28 +45,6 @@ onMount( async() => { }) -async function loadSearchData() { - - if($searchBarData?.length !== 0) - { - return - } - else { - - // make the GET request to the endpoint - const response = await fetch(apiURL+'/searchbar-data', { - method: 'GET', - headers: { - "Content-Type": "application/json","X-API-KEY": apiKey - }, - }); - - $searchBarData = await response.json(); - } - - - } - @@ -173,8 +92,17 @@ async function loadSearchData() { -
$45,231.89
-

+20.1% from last month

+ {quickInfo?.active?.symbol} +

+ ${quickInfo?.active?.price} + {#if quickInfo?.active?.changesPercentage >=0} + + +{quickInfo?.active?.changesPercentage?.toFixed(2)}% + {:else} + + {quickInfo?.active?.changesPercentage?.toFixed(2)}% + {/if} +

@@ -234,16 +182,13 @@ async function loadSearchData() { - {#each data?.getOptionsFlowFeed?.slice(0,3) as item} + {#each data?.getDashboard?.optionsFlow as item} -
{item?.ticker}
- + {item?.ticker}
- {abbreviateNumber(item?.cost_basis)} + {abbreviateNumber(item?.cost_basis,true)} ${item?.strike_price} @@ -275,7 +220,7 @@ async function loadSearchData() { - {#each data?.getPoliticianRSS?.slice(0,4) as item} + {#each data?.getDashboard?.congressFlow as item}
@@ -315,7 +260,7 @@ async function loadSearchData() {
- {#each rssFeedWIIM.slice(0,5) as item} + {#each data?.getDashboard?.wiimFeed as item}
@@ -364,18 +309,20 @@ async function loadSearchData() {
-
-
- + {/each} + -
diff --git a/src/routes/home/+page.ts b/src/routes/home/+page.ts index 35609a21..6be924fe 100644 --- a/src/routes/home/+page.ts +++ b/src/routes/home/+page.ts @@ -49,17 +49,17 @@ export const load = async ({ parent}) => { redirect(303, '/'); } - const getDailyGainerLoserActive = async () => { + + const getDashboard = async () => { let output; // Get cached data for the specific tickerID - const cachedData = getCache('', 'getDailyGainerLoserActive'); + const cachedData = getCache('', 'getDashboard'); if (cachedData) { output = cachedData; } else { - // make the POST request to the endpoint - const response = await fetch(apiURL + '/market-movers', { + const response = await fetch(apiURL + '/dashboard-info', { method: 'GET', headers: { "Content-Type": "application/json", "X-API-KEY": apiKey @@ -68,72 +68,10 @@ export const load = async ({ parent}) => { output = await response.json(); - setCache('', output, 'getDailyGainerLoserActive'); - } - - return output; - }; - - const getRssFeedWIIM = async () => { - let output; - - // Get cached data for the specific tickerID - const cachedData = getCache('', 'getRssFeedWIIM'); - if (cachedData) { - output = cachedData; - } else { - - // make the POST request to the endpoint - const response = await fetch(apiURL + '/rss-feed-wiim', { - method: 'GET', - headers: { - "Content-Type": "application/json", "X-API-KEY": apiKey - }, - }); - - output = await response.json(); - - setCache('', output, 'getRssFeedWIIM'); - } - - return output; - }; - - const getOptionsFlowFeed = async () => { - // make the POST request to the endpoint - const response = await fetch(apiURL + '/options-flow-feed', { - method: 'GET', - headers: { - "Content-Type": "application/json", "X-API-KEY": apiKey - }, - }); - const output = await response.json(); - - return output; - }; - - const getPoliticianRSS = async () => { - let output; - - // Get cached data for the specific tickerID - const cachedData = getCache('', 'getPoliticianRSS'); - if (cachedData) { - output = cachedData; - } else { - - const response = await fetch(apiURL + '/congress-rss-feed', { - method: 'GET', - headers: { - "Content-Type": "application/json", "X-API-KEY": apiKey - }, - }); - - output = await response.json(); - - // Cache the data for this specific tickerID with a specific name 'getPoliticianRSS' - + // Cache the data for this specific tickerID with a specific name 'getDashboard' + let congressFlow = output?.congressFlow; await loadImages(); - output?.forEach(item => { + congressFlow?.forEach(item => { let representative = item?.representative || ''; representative = representative?.replace('Jr', '') @@ -145,7 +83,7 @@ export const load = async ({ parent}) => { item.representative = fullName?.replace(/_/g, ' '); }); - output = output?.map(item => { + congressFlow = congressFlow?.map(item => { const party = getPartyForPoliticians(item?.representative); return { ...item, @@ -153,17 +91,15 @@ export const load = async ({ parent}) => { }; }); - - setCache('', output, 'getPoliticianRSS'); + output.congressFlow = congressFlow; + + setCache('', output, 'getDashboard'); } return output; }; // Make sure to return a promise return { - getDailyGainerLoserActive: await getDailyGainerLoserActive(), - getRssFeedWIIM: await getRssFeedWIIM(), - getPoliticianRSS: await getPoliticianRSS(), - getOptionsFlowFeed: await getOptionsFlowFeed(), + getDashboard: await getDashboard(), }; }; \ No newline at end of file