fix payment service + appsumo + ui

This commit is contained in:
Emily
2025-04-22 18:42:18 +02:00
parent f631c29fb2
commit a9bbc58ad1
13 changed files with 121 additions and 65 deletions

View File

@@ -70,27 +70,27 @@ const avgBouncingRate = computed(() => {
function weightedAverage(data: number[]): number {
if (data.length === 0) return 0;
// Compute median
const sortedData = [...data].sort((a, b) => a - b);
const middle = Math.floor(sortedData.length / 2);
const median = sortedData.length % 2 === 0
? (sortedData[middle - 1] + sortedData[middle]) / 2
const median = sortedData.length % 2 === 0
? (sortedData[middle - 1] + sortedData[middle]) / 2
: sortedData[middle];
// Define a threshold (e.g., 3 times the median) to filter out extreme values
const threshold = median * 3;
const filteredData = data.filter(num => num <= threshold);
if (filteredData.length === 0) return median; // Fallback to median if all are removed
// Compute weights based on inverse absolute deviation from median
const weights = filteredData.map(num => 1 / (1 + Math.abs(num - median)));
// Compute weighted sum and sum of weights
const weightedSum = filteredData.reduce((sum, num, i) => sum + num * weights[i], 0);
const sumOfWeights = weights.reduce((sum, weight) => sum + weight, 0);
return weightedSum / sumOfWeights;
}
const avgSessionDuration = computed(() => {
@@ -109,6 +109,9 @@ const avgSessionDuration = computed(() => {
seconds += avg * 60;
while (seconds >= 60) { seconds -= 60; minutes += 1; }
while (minutes >= 60) { minutes -= 60; hours += 1; }
if (hours == 0 && minutes == 0 && seconds < 10) return `0m ~10s`
return `${hours > 0 ? hours + 'h ' : ''}${minutes}m ${seconds.toFixed()}s`
});

View File

@@ -32,7 +32,7 @@ const { data: pendingInvites, refresh: refreshInvites } = useFetch('/api/project
headers: useComputedHeaders({})
});
const { userRoles } = useLoggedUser();
const { userRoles, isPremium } = useLoggedUser();
const { projectList } = useProject();
const debugMode = process.dev;
@@ -94,6 +94,9 @@ async function generatePDF() {
const { actions } = useProject();
const { showDrawer } = useDrawer();
const modal = useModal();
@@ -138,13 +141,6 @@ function openPendingInvites() {
}">
<div class="py-4 pb-2 px-2 gap-6 flex flex-col w-full">
<!-- <div class="flex px-2" v-if="!isPremium">
<LyxUiButton type="primary" class="w-full text-center text-[.8rem] font-medium" @click="pricingDrawer.visible.value = true;">
Upgrade plan
</LyxUiButton>
</div> -->
<div class="flex px-2 flex-col">
<div class="flex items-center gap-2 w-full">
@@ -304,6 +300,16 @@ function openPendingInvites() {
<div class="grow"></div>
<LyxUiCard class="w-full mb-4" v-if="!isPremium">
<div class="flex flex-col gap-3">
<div class="text-center"> Upgrade to premium </div>
<LyxUiButton type="primary" class="w-full text-center text-[.8rem] font-medium"
@click="showDrawer('PRICING')">
Upgrade
</LyxUiButton>
</div>
</LyxUiCard>
<div v-if="pendingInvites && pendingInvites.length > 0" @click="openPendingInvites()"
class="w-full bg-[#fbbf2422] p-4 rounded-lg text-[.9rem] flex flex-col justify-center cursor-pointer">
<div class="poppins font-medium dark:text-lyx-text text-lyx-lightmode-text">
@@ -316,13 +322,18 @@ function openPendingInvites() {
</div>
</div>
<LyxUiSeparator class="px-4 mb-2"></LyxUiSeparator>
<div class="flex px-1 w-full">
<!-- <LyxUiSeparator class="px-4 mb-2"></LyxUiSeparator> -->
<LyxUiCard class="flex py-1 px-1 w-full relative">
<div class="absolute top-[-22%] right-0">
<div @click="showDrawer('PRICING')"
class="flex items-center gap-1 poppins text-[.5rem] bg-[#fbbe244f] outline outline-[1px] outline-[#fbbf24] px-3 py-[.12rem] rounded-sm">
<i class="far fa-crown mb-[2px]"></i>
<div>Premium</div>
</div>
</div>
<LayoutVerticalBottomMenu></LayoutVerticalBottomMenu>
</div>
</LyxUiCard>

View File

@@ -54,7 +54,7 @@ async function redeemCode() {
Redeemed codes: {{ valid_codes.data.value?.count || '0' }}
</div>
<div class="poppins text-[1.1rem] text-lyx-lightmode-text dark:text-yellow-400 mb-2">
*Plan upgrades are applicable exclusively to this project(workspace).
*Plan upgrades are applied to account level.
</div>
</template>
</SettingsTemplate>