diff --git a/src/routes/analysts/[slug]/+page.server.ts b/src/routes/analysts/[slug]/+page.server.ts index 6d23a6ce..d40ae441 100644 --- a/src/routes/analysts/[slug]/+page.server.ts +++ b/src/routes/analysts/[slug]/+page.server.ts @@ -13,7 +13,7 @@ export const load = async ({ locals, params }) => { body: JSON.stringify(postData), }); - const output = await response.json(); + const output = await response.json() || {}; return output; }; diff --git a/src/routes/analysts/[slug]/+page.svelte b/src/routes/analysts/[slug]/+page.svelte index 114c7d75..17e51773 100644 --- a/src/routes/analysts/[slug]/+page.svelte +++ b/src/routes/analysts/[slug]/+page.svelte @@ -5,6 +5,8 @@ import { onMount } from "svelte"; import HoverStockChart from "$lib/components/HoverStockChart.svelte"; import RatingsChart from "$lib/components/RatingsChart.svelte"; + import Infobox from "$lib/components/Infobox.svelte"; + export let data; let analystStats = data?.getAnalystStats; @@ -16,7 +18,7 @@ let analystScore = analystStats?.analystScore; let rank = analystStats?.rank; - let analystName = analystStats?.analystName; + let analystName = analystStats?.analystName ?? "n/a"; let companyName = analystStats?.companyName; let totalRatings = analystStats?.totalRatings; let successRate = analystStats?.successRate; @@ -30,7 +32,7 @@ function processTickerData(data) { const tickerMap = new Map(); - data.forEach((item) => { + data?.forEach((item) => { const { ticker } = item; if (!ticker) return; // Skip if ticker is not defined @@ -212,7 +214,7 @@
- Stock Analyst at {companyName} + Stock Analyst at {companyName ?? "n/a"}
| + + | |||||||||||||
| - |
- {#if index >= 5 && data?.user?.tier !== "Pro"}
-
-
- XXXX
-
-
-
- XXXXXXXXXXXXXXXX
-
-
-
-
-
+
+ {#if index >= 5 && data?.user?.tier !== "Pro"}
+
- Upgrade
+ XXXX
+
+
+ |
-
- {item?.name?.length > charNumber
- ? item?.name?.slice(0, charNumber) + "..."
- : item?.name}
+
+ XXXXXXXXXXXXXXXX
+
+
+
+
+
+
+ Upgrade
+
+
+
+ {:else}
+
+
-
- {:else}
-
-
+ |
+
+ {item?.action_company}:
+
- {/if}
- |
-
-
- {item?.action_company}:
-
-
- |
+
+
+ {#if Math?.ceil(item?.adjusted_pt_prior) !== 0}
+ {Math?.ceil(item?.adjusted_pt_prior)}
+
+ {Math?.ceil(item?.adjusted_pt_current)}
+ {:else if Math?.ceil(item?.adjusted_pt_current) !== 0}
+ {Math?.ceil(item?.adjusted_pt_current)}
+ {:else}
+ n/a
+ {/if}
+
+ |
-
-
- {#if Math?.ceil(item?.adjusted_pt_prior) !== 0}
- {Math?.ceil(item?.adjusted_pt_prior)}
-
- {Math?.ceil(item?.adjusted_pt_current)}
- {:else if Math?.ceil(item?.adjusted_pt_current) !== 0}
- {Math?.ceil(item?.adjusted_pt_current)}
- {:else}
- n/a
- {/if}
-
- |
+ + {item?.price !== null ? item?.price : "n/a"} + | -- {item?.price !== null ? item?.price : "n/a"} - | ++ {item?.upside !== null ? item?.upside + "%" : "n/a"} + | -- {item?.upside !== null ? item?.upside + "%" : "n/a"} - | ++ {item?.ratings !== null ? item?.ratings : "n/a"} + | -- {item?.ratings !== null ? item?.ratings : "n/a"} - | - -- {new Date(item?.date).toLocaleString("en-US", { - month: "short", - day: "numeric", - year: "numeric", - daySuffix: "2-digit", - })} - | -
-
-
- | |||||||||||||
+
-
+
-
-
+
|
- |||||||||||||