This commit is contained in:
MuslemRahimi 2024-09-21 16:56:59 +02:00
parent 15429b2dc7
commit 191d3f1d0c
8 changed files with 104 additions and 156 deletions

View File

@ -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;

View File

@ -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(),
};
};

View File

@ -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(),
};
};

View File

@ -1,6 +1,5 @@
<script lang='ts'>
import { numberOfUnreadNotification } from '$lib/store';
import { goto } from '$app/navigation';
import { numberOfUnreadNotification } from '$lib/store';
import { page } from '$app/stores';
export let data;
@ -10,13 +9,7 @@
function handleMode(i) {
activeIdx = i;
if(activeIdx === 0) {
goto("/industry")
} else if (activeIdx === 1) {
goto("/industry/sectors")
} else if (activeIdx === 2) {
goto("/industry/all")
}
}
const tabs = [
@ -93,7 +86,7 @@ let activeIdx = 0;
<div class="ml-4 sm:ml-0 w-full mb-4">
<div class="bg-[#313131] w-fit relative mr-auto flex flex-wrap items-center justify-center rounded sm:rounded-lg p-1 -mt-3">
{#each tabs as item, i}
<button
<a href={i === 0 ? '/industry' : i === 1 ? '/industry/sectors' : '/industry/all'}
on:click={() => handleMode(i)}
class="group relative z-[1] rounded-full px-6 py-1 {activeIdx === i
? 'z-0'
@ -107,7 +100,7 @@ let activeIdx = 0;
<span class="relative text-[1rem] block font-semibold duration-200 text-white">
{item.title}
</span>
</button>
</a>
{/each}
</div>
</div>

View File

@ -0,0 +1,26 @@
export const load = async ({ locals }) => {
const getIPOCalendar = async () => {
const { apiURL, apiKey } = locals;
// make the POST request to the endpoint
const postData = { year: "all" };
const response = await fetch(apiURL + "/ipo-calendar", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
body: JSON.stringify(postData),
});
const output = await response.json();
return output;
};
// Make sure to return a promise
return {
getIPOCalendar: await getIPOCalendar(),
};
};

View File

@ -1,39 +0,0 @@
import { getCache, setCache } from "$lib/store";
export const load = async ({ parent, params }) => {
const getIPOCalendar = async () => {
let output;
// Get cached data for the specific tickerID
const cachedData = getCache("all", "getIPOCalendar");
if (cachedData) {
output = cachedData;
} else {
const { apiURL, apiKey } = await parent();
// make the POST request to the endpoint
const postData = { year: "all" };
const response = await fetch(apiURL + "/ipo-calendar", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
body: JSON.stringify(postData),
});
output = await response.json();
// Cache the data for this specific tickerID with a specific name 'getIPOCalendar'
setCache("all", output, "getIPOCalendar");
}
return output;
};
// Make sure to return a promise
return {
getIPOCalendar: await getIPOCalendar(),
};
};

View File

@ -0,0 +1,30 @@
export const load = async ({ locals, params }) => {
const getIPOCalendar = async () => {
const { apiURL, apiKey } = locals;
// make the POST request to the endpoint
const postData = { year: params.slug };
const response = await fetch(apiURL + "/ipo-calendar", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
body: JSON.stringify(postData),
});
const output = await response.json();
return output;
};
const getYear = async () => {
return params.slug;
};
// Make sure to return a promise
return {
getIPOCalendar: await getIPOCalendar(),
getYear: await getYear(),
};
};

View File

@ -1,43 +0,0 @@
import { getCache, setCache } from "$lib/store";
export const load = async ({ parent, params }) => {
const getIPOCalendar = async () => {
let output;
// Get cached data for the specific tickerID
const cachedData = getCache(params.slug, "getIPOCalendar");
if (cachedData) {
output = cachedData;
} else {
const { apiURL, apiKey } = await parent();
// make the POST request to the endpoint
const postData = { year: params.slug };
const response = await fetch(apiURL + "/ipo-calendar", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": apiKey,
},
body: JSON.stringify(postData),
});
output = await response.json();
// Cache the data for this specific tickerID with a specific name 'getIPOCalendar'
setCache(params.slug, output, "getIPOCalendar");
}
return output;
};
const getYear = async () => {
return params.slug;
};
// Make sure to return a promise
return {
getIPOCalendar: await getIPOCalendar(),
getYear: await getYear(),
};
};