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) {
// Predefined list of senators and their parties
const senatorPartyMap = {
"Bryon Donalds": "Republican",
"Blake Moore": "Republican",
"Bill Hagerty": "Republican",
"Scott Peters": "Democratic",

View File

@ -14,55 +14,19 @@
let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL;
let rawData = data?.getPoliticianRSS;
let slicedRawData = [];
let displayList = [];
let isLoaded = false;
let displayStructure = "Table";
let displayRows = 100;
let filterList = [];
let changeRowFilter = false;
let changeRuleFilter = false;
let displayList = rawData?.slice(0, 50) || [];
async function handleScroll() {
const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height
const isBottom = window.innerHeight + window.scrollY >= scrollThreshold;
if (isBottom && displayList?.length !== slicedRawData?.length) {
if (isBottom && displayList?.length !== rawData?.length) {
const nextIndex = displayList?.length;
const filteredNewResults = slicedRawData?.slice(nextIndex, nextIndex + 9);
const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 9);
displayList = [...displayList, ...filteredNewResults];
}
}
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('keydown', handleKeyDown);
@ -135,7 +99,7 @@
</svelte:head>
<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">
<ul>
@ -157,7 +121,6 @@
</div>
<body class="w-full overflow-hidden m-auto">
{#if isLoaded}
<section class="w-full overflow-hidden m-auto sm:mt-10">
<div class=" flex justify-center w-full m-auto overflow-hidden">
<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"
>
<thead>
<tr
class="bg-[#09090B] border-b border-[#27272A]"
>
<tr class="bg-[#09090B] border-b border-[#27272A]">
<th
class="bg-[#09090B] text-start bg-[#09090B] text-white text-sm font-medium sm:font-semibold"
>
@ -207,8 +168,7 @@
<tr
class="odd:bg-[#27272A] border-b-[#09090B] {index +
1 ===
rawData?.length &&
data?.user?.tier !== 'Pro'
rawData?.length && data?.user?.tier !== 'Pro'
? 'opacity-[0.1]'
: ''}"
>
@ -233,9 +193,7 @@
loading="lazy"
/>
</div>
<div
class="flex flex-col ml-3 font-normal"
>
<div class="flex flex-col ml-3 font-normal">
<a
href={`/politicians/${item?.id}`}
class="sm:hover:text-white text-blue-400"
@ -274,10 +232,7 @@
) + "..."
: formatString(item?.assetDescription)
?.replace("- Common Stock", "")
?.replace(
"Common Stock",
"",
)}</span
?.replace("Common Stock", "")}</span
>
</div>
</td>
@ -325,24 +280,11 @@
</div>
</div>
</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>
</main>
<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
class="w-full text-white border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer"
>