update flow page

This commit is contained in:
MuslemRahimi 2024-11-11 19:23:15 +01:00
parent 64ef6d916b
commit 77f93f8e80
3 changed files with 151 additions and 208 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -597,6 +597,7 @@ function convertNYTimeToLocalTime(nyTimeString) {
export function getPartyForPoliticians(name) { export function getPartyForPoliticians(name) {
// Predefined list of senators and their parties // Predefined list of senators and their parties
const senatorPartyMap = { const senatorPartyMap = {
"Bryon Donalds": "Republican",
"Blake Moore": "Republican", "Blake Moore": "Republican",
"Bill Hagerty": "Republican", "Bill Hagerty": "Republican",
"Scott Peters": "Democratic", "Scott Peters": "Democratic",

View File

@ -14,55 +14,19 @@
let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL; let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL;
let rawData = data?.getPoliticianRSS; let rawData = data?.getPoliticianRSS;
let slicedRawData = []; let displayList = rawData?.slice(0, 50) || [];
let displayList = [];
let isLoaded = false;
let displayStructure = "Table";
let displayRows = 100;
let filterList = [];
let changeRowFilter = false;
let changeRuleFilter = false;
async function handleScroll() { async function handleScroll() {
const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height
const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; const isBottom = window.innerHeight + window.scrollY >= scrollThreshold;
if (isBottom && displayList?.length !== slicedRawData?.length) { if (isBottom && displayList?.length !== rawData?.length) {
const nextIndex = displayList?.length; const nextIndex = displayList?.length;
const filteredNewResults = slicedRawData?.slice(nextIndex, nextIndex + 9); const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 9);
displayList = [...displayList, ...filteredNewResults]; displayList = [...displayList, ...filteredNewResults];
} }
} }
onMount(async () => { onMount(async () => {
rawData?.forEach((item) => {
let representative = item?.representative || "";
representative = representative
?.replace("Jr", "")
.replace(/Dr./g, "")
.replace(/Dr_/g, "");
const fullName = representative
?.replace(/(\s(?:Dr\s)?\w(?:\.|(?=\s)))?\s/g, "_")
.trim();
item.representative = fullName?.replace(/_/g, " ");
});
rawData = rawData?.map((item) => {
const party = getPartyForPoliticians(item?.representative);
return {
...item,
party: party,
};
});
slicedRawData = rawData?.slice(0, displayRows) ?? [];
displayList = slicedRawData?.slice(0, 20) ?? [];
isLoaded = true;
window.addEventListener("scroll", handleScroll); window.addEventListener("scroll", handleScroll);
//window.addEventListener('keydown', handleKeyDown); //window.addEventListener('keydown', handleKeyDown);
@ -135,7 +99,7 @@
</svelte:head> </svelte:head>
<section <section
class="w-full max-w-3xl sm:max-w-screen-2xl overflow-hidden pb-20 pt-5 px-4 lg:px-3" class="w-full max-w-3xl sm:max-w-screen-2xl overflow-hidden min-h-screen pb-20 pt-5 px-4 lg:px-3"
> >
<div class="text-sm sm:text-[1rem] breadcrumbs"> <div class="text-sm sm:text-[1rem] breadcrumbs">
<ul> <ul>
@ -157,7 +121,6 @@
</div> </div>
<body class="w-full overflow-hidden m-auto"> <body class="w-full overflow-hidden m-auto">
{#if isLoaded}
<section class="w-full overflow-hidden m-auto sm:mt-10"> <section class="w-full overflow-hidden m-auto sm:mt-10">
<div class=" flex justify-center w-full m-auto overflow-hidden"> <div class=" flex justify-center w-full m-auto overflow-hidden">
<div <div
@ -172,9 +135,7 @@
class="table table-sm table-pin-cols table-compact rounded-none sm:rounded-md w-full bg-[#09090B] border-bg-[#09090B] m-auto" class="table table-sm table-pin-cols table-compact rounded-none sm:rounded-md w-full bg-[#09090B] border-bg-[#09090B] m-auto"
> >
<thead> <thead>
<tr <tr class="bg-[#09090B] border-b border-[#27272A]">
class="bg-[#09090B] border-b border-[#27272A]"
>
<th <th
class="bg-[#09090B] text-start bg-[#09090B] text-white text-sm font-medium sm:font-semibold" class="bg-[#09090B] text-start bg-[#09090B] text-white text-sm font-medium sm:font-semibold"
> >
@ -207,8 +168,7 @@
<tr <tr
class="odd:bg-[#27272A] border-b-[#09090B] {index + class="odd:bg-[#27272A] border-b-[#09090B] {index +
1 === 1 ===
rawData?.length && rawData?.length && data?.user?.tier !== 'Pro'
data?.user?.tier !== 'Pro'
? 'opacity-[0.1]' ? 'opacity-[0.1]'
: ''}" : ''}"
> >
@ -233,9 +193,7 @@
loading="lazy" loading="lazy"
/> />
</div> </div>
<div <div class="flex flex-col ml-3 font-normal">
class="flex flex-col ml-3 font-normal"
>
<a <a
href={`/politicians/${item?.id}`} href={`/politicians/${item?.id}`}
class="sm:hover:text-white text-blue-400" class="sm:hover:text-white text-blue-400"
@ -274,10 +232,7 @@
) + "..." ) + "..."
: formatString(item?.assetDescription) : formatString(item?.assetDescription)
?.replace("- Common Stock", "") ?.replace("- Common Stock", "")
?.replace( ?.replace("Common Stock", "")}</span
"Common Stock",
"",
)}</span
> >
</div> </div>
</td> </td>
@ -325,24 +280,11 @@
</div> </div>
</div> </div>
</section> </section>
{:else}
<div class="flex justify-center items-center h-80">
<div class="relative">
<label
class="bg-[#09090B] rounded-xl h-14 w-14 flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
>
<span
class="loading loading-spinner loading-md text-gray-400"
></span>
</label>
</div>
</div>
{/if}
</body> </body>
</main> </main>
<aside class="hidden lg:block relative fixed w-1/4 ml-4"> <aside class="hidden lg:block relative fixed w-1/4 ml-4">
{#if data?.user?.tier !== "Pro" || data?.user?.freeTrial} {#if data?.user?.tier !== "Pro"}
<div <div
class="w-full text-white border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer" class="w-full text-white border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer"
> >