From 191d3f1d0cb7693fa3569c0d6c8323f56609a78c Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sat, 21 Sep 2024 16:56:59 +0200 Subject: [PATCH] ui fixes --- src/lib/components/PriceAlert.svelte | 6 +-- src/routes/about/+page.server.ts | 41 ++++++++++++++++++ src/routes/about/+page.ts | 60 -------------------------- src/routes/industry/+layout.svelte | 15 ++----- src/routes/ipos/+page.server.ts | 26 +++++++++++ src/routes/ipos/+page.ts | 39 ----------------- src/routes/ipos/[slug]/+page.server.ts | 30 +++++++++++++ src/routes/ipos/[slug]/+page.ts | 43 ------------------ 8 files changed, 104 insertions(+), 156 deletions(-) create mode 100644 src/routes/about/+page.server.ts delete mode 100644 src/routes/about/+page.ts create mode 100644 src/routes/ipos/+page.server.ts delete mode 100644 src/routes/ipos/+page.ts create mode 100644 src/routes/ipos/[slug]/+page.server.ts delete mode 100644 src/routes/ipos/[slug]/+page.ts diff --git a/src/lib/components/PriceAlert.svelte b/src/lib/components/PriceAlert.svelte index 435e4422..a30a92e5 100644 --- a/src/lib/components/PriceAlert.svelte +++ b/src/lib/components/PriceAlert.svelte @@ -39,14 +39,14 @@ }); const output = (await response.json())?.items + + const closePopup = document.getElementById("priceAlertModal"); + closePopup?.dispatchEvent(new MouseEvent('click')) if (output === 'success') { toast.success(`Successfully created price alert`, { style: 'border-radius: 10px; background: #333; color: #fff; padding: 12px; margin-top: 10px; box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);', }); - - const closePopup = document.getElementById("priceAlertModal"); - closePopup?.dispatchEvent(new MouseEvent('click')) values = [0]; displayPrice = currentPrice; diff --git a/src/routes/about/+page.server.ts b/src/routes/about/+page.server.ts new file mode 100644 index 00000000..cc8cad66 --- /dev/null +++ b/src/routes/about/+page.server.ts @@ -0,0 +1,41 @@ +export const load = async () => { + const getFrontendStars = async () => { + // make the POST request to the endpoint + const response = await fetch( + "https://api.github.com/repos/stocknear/frontend", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ); + + const output = (await response.json())["stargazers_count"]; + + return output; + }; + + const getBackendStars = async () => { + // make the POST request to the endpoint + const response = await fetch( + "https://api.github.com/repos/stocknear/backend", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ); + + const output = (await response.json())["stargazers_count"]; + + return output; + }; + + // Make sure to return a promise + return { + getFrontendStars: await getFrontendStars(), + getBackendStars: await getBackendStars(), + }; +}; diff --git a/src/routes/about/+page.ts b/src/routes/about/+page.ts deleted file mode 100644 index 3c329d20..00000000 --- a/src/routes/about/+page.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { getCache, setCache } from "$lib/store"; -import { redirect } from "@sveltejs/kit"; - -export const load = async ({ parent }) => { - const getFrontendStars = async () => { - let output; - - // Get cached data for the specific tickerID - const cachedData = getCache("", "getFrontendStars"); - if (cachedData) { - output = cachedData; - } else { - // make the POST request to the endpoint - const response = await fetch( - "https://api.github.com/repos/stocknear/frontend", - { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }, - ); - - output = (await response.json())["stargazers_count"]; - setCache("", output, "getFrontendStars"); - } - return output; - }; - - const getBackendStars = async () => { - let output; - - // Get cached data for the specific tickerID - const cachedData = getCache("", "getBackendStars"); - if (cachedData) { - output = cachedData; - } else { - // make the POST request to the endpoint - const response = await fetch( - "https://api.github.com/repos/stocknear/backend", - { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }, - ); - - output = (await response.json())["stargazers_count"]; - setCache("", output, "getBackendStars"); - } - return output; - }; - - // Make sure to return a promise - return { - getFrontendStars: await getFrontendStars(), - getBackendStars: await getBackendStars(), - }; -}; diff --git a/src/routes/industry/+layout.svelte b/src/routes/industry/+layout.svelte index 3d25ac8a..238d216b 100644 --- a/src/routes/industry/+layout.svelte +++ b/src/routes/industry/+layout.svelte @@ -1,6 +1,5 @@