diff --git a/src/lib/components/HoverStockChart.svelte b/src/lib/components/HoverStockChart.svelte index 1e1b4a94..b69322fd 100644 --- a/src/lib/components/HoverStockChart.svelte +++ b/src/lib/components/HoverStockChart.svelte @@ -8,6 +8,7 @@ import { afterUpdate } from "svelte"; export let symbol; export let assetType = "stock"; + export let link = null; let priceData = []; let changesPercentage = 0; @@ -54,18 +55,19 @@ function getHref(symbol: string) { let path = ""; if (symbol?.length !== 0) { - if (["stocks", "stock"]?.includes(assetType?.toLowerCase())) { - path = `/stocks/${symbol}`; + if (["stocks", "stock"].includes(assetType?.toLowerCase())) { + path = `/stocks/${symbol}${link ? `/${link}` : ""}`; } else if (assetType?.toLowerCase() === "etf") { - path = `/etf/${symbol}`; - } else if (["BTC", "USD"]?.includes(symbol)) { + path = `/etf/${symbol}${link ? `/${link}` : ""}`; + } else if (["BTC", "USD"].includes(symbol)) { path = ""; } else { - path = `/index/${symbol}`; + path = `/index/${symbol}${link ? `/${link}` : ""}`; } } return path; } + $: topLineColor = changesPercentage >= 0 ? "#71CA96" : "#FF7070"; let width = $screenWidth < 640 ? 80 : 150; //= ($screenWidth <= 1200 && $screenWidth > 900) ? 360 : ($screenWidth <= 900 && $screenWidth > 700) ? 260 : ($screenWidth <= 700 && $screenWidth >=600 ) ? 200 : ($screenWidth < 600 && $screenWidth >=500 ) ? 150 : 80; diff --git a/src/routes/api/update-notification-channels/+server.ts b/src/routes/api/update-notification-channels/+server.ts index bc5f8857..790760ba 100644 --- a/src/routes/api/update-notification-channels/+server.ts +++ b/src/routes/api/update-notification-channels/+server.ts @@ -1,22 +1,27 @@ import type { RequestHandler } from "./$types"; export const POST: RequestHandler = async ({ request, locals }) => { - const data = await request.json(); const { pb } = locals; - let output = 'failure'; - try { - await pb.collection("notificationChannels").update(data?.id, { - 'earningsSurprise': data?.earningsSurprise, - 'wiim': data?.wiim, - }) - output = 'success'; - } - catch(e) { - console.log(e) - output = 'failure'; + const payload = await request.json(); + const { id, ...updateData } = payload; + + if (!id) { + return new Response( + JSON.stringify({ status: "failure", message: "Missing id" }), + { status: 400 } + ); } - return new Response(JSON.stringify(output)); + await pb.collection("notificationChannels").update(id, updateData); + + return new Response(JSON.stringify({ status: "success" }), { status: 200 }); + } catch (e: any) { + console.error(e); + return new Response( + JSON.stringify({ status: "failure", error: e.message }), + { status: 500 } + ); + } }; diff --git a/src/routes/notifications/+page.svelte b/src/routes/notifications/+page.svelte index 21c9d718..da052e76 100644 --- a/src/routes/notifications/+page.svelte +++ b/src/routes/notifications/+page.svelte @@ -187,6 +187,55 @@ + {:else if item?.notifyType === "topAnalyst"} +
+
+ + + Company Logo + + +
+ + +
+
+
+
+ New Top Analyst Rating for + +
+
+ The rating company {item?.liveResults?.analyst} has + issued a new rating of „{item?.liveResults + ?.rating_current}“ with an updated price + target of ${item?.liveResults + ?.adjusted_pt_current}. +
+
+
+ {formatDate(item?.created)} + +
+
+
+
{:else if item?.notifyType === "earningsSurprise"}
+
+ + +
+ +