This commit is contained in:
MuslemRahimi 2024-11-10 22:59:11 +01:00
parent ede1b410cb
commit 6a9664f524

View File

@ -9,6 +9,7 @@
import { GridComponent, TooltipComponent } from "echarts/components"; import { GridComponent, TooltipComponent } from "echarts/components";
import { CanvasRenderer } from "echarts/renderers"; import { CanvasRenderer } from "echarts/renderers";
import { onMount } from "svelte"; import { onMount } from "svelte";
import { goto } from "$app/navigation";
use([LineChart, BarChart, GridComponent, TooltipComponent, CanvasRenderer]); use([LineChart, BarChart, GridComponent, TooltipComponent, CanvasRenderer]);
export let data; export let data;
@ -23,6 +24,16 @@
let optionsFedFundRate; let optionsFedFundRate;
let filterRule = "annual"; let filterRule = "annual";
let activeIdx = 0;
const tabs = [
{
title: "Annual",
},
{
title: "Quarterly",
},
];
let timePeriod = "threeYears"; let timePeriod = "threeYears";
const monthNames = [ const monthNames = [
@ -107,12 +118,16 @@
return quarterlyData; return quarterlyData;
} }
function changeTablePeriod(state: string) { function changeTablePeriod(index) {
filterRule = state; activeIdx = index;
if (state === "annual") { if (activeIdx === 0) {
tableList = filterEndOfYearDates(rawData); tableList = filterEndOfYearDates(rawData);
} else { } else {
tableList = filterEndOfQuarterDates(rawData); if (data?.user?.tier === "Pro") {
tableList = filterEndOfQuarterDates(rawData);
} else {
goto("/pricing");
}
} }
tableList?.sort((a, b) => new Date(b?.date) - new Date(a?.date)); tableList?.sort((a, b) => new Date(b?.date) - new Date(a?.date));
} }
@ -791,51 +806,42 @@
</div> </div>
</Lazy> </Lazy>
<ul <div
class="text-[0.8rem] font-medium text-center w-56 pt-10 sm:w-56 mb-5 flex justify-center sm:justify-end items-center ml-auto" class="mt-10 mb-4 bg-[#313131] w-fit relative flex flex-wrap items-center justify-center rounded-md p-1 flex justify-center sm:justify-end items-center ml-auto"
> >
<li class="w-full"> {#each tabs as item, i}
<label <button
on:click={() => changeTablePeriod("annual")} on:click={() => changeTablePeriod(i)}
class="cursor-pointer rounded-l-md inline-block w-full py-1.5 {filterRule === class="group relative z-[1] rounded-full px-6 py-1 {activeIdx ===
'annual' i
? 'bg-[#fff] text-black' ? 'z-0'
: 'bg-[#313131] text-white'} font-semibold border-r border-gray-600" : ''} "
aria-current="page"
> >
Annual {#if activeIdx === i}
</label> <div class="absolute inset-0 rounded-md bg-[#fff]"></div>
</li> {/if}
<li class="w-full"> <span
{#if data?.user?.tier === "Pro"} class="relative text-sm block font-semibold {activeIdx ===
<label i
on:click={() => changeTablePeriod("quarterly")} ? 'text-black'
class="cursor-pointer inline-block w-full py-1.5 {filterRule === : 'text-white'}"
'quarterly'
? 'bg-[#fff] text-black'
: 'bg-[#313131] text-white'} font-semibold rounded-r-md"
> >
Quartely {item.title}
</label>
{:else}
<a
href="/pricing"
class="flex flex-row items-center m-auto justify-center cursor-pointer inline-block w-full py-2.5 bg-[#313131] font-semibold text-white rounded-r-lg"
>
<span class="">Quarterly</span>
<svg <svg
class="ml-1 -mt-0.5 w-3.5 h-3.5" class="{data?.user?.tier !== 'Pro' && i === 1
? ''
: 'hidden'} inline-block ml-0.5 -mt-1 w-3.5 h-3.5"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24" viewBox="0 0 24 24"
><path ><path
fill="#A3A3A3" fill="#fff"
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
/></svg /></svg
> >
</a> </span>
{/if} </button>
</li> {/each}
</ul> </div>
<div class="w-full overflow-x-scroll"> <div class="w-full overflow-x-scroll">
<table <table