Skip to content

Commit 4747114

Browse files
committed
olay olay olay
1 parent 47738a2 commit 4747114

File tree

11 files changed

+2607
-372
lines changed

11 files changed

+2607
-372
lines changed

apps/dashboard/app/(main)/websites/[id]/_components/tabs/overview-tab.tsx

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
LayoutIcon,
1414
MonitorIcon,
1515
QuestionIcon,
16-
TelevisionIcon,
1716
TimerIcon,
1817
UsersIcon,
1918
WarningIcon,
@@ -25,7 +24,7 @@ import timezone from 'dayjs/plugin/timezone';
2524
import utc from 'dayjs/plugin/utc';
2625
import { useAtom } from 'jotai';
2726
import { useRouter } from 'next/navigation';
28-
import { useCallback, useEffect, useMemo, useState } from 'react';
27+
import { useCallback, useEffect, useState } from 'react';
2928
import { DataTable } from '@/components/analytics/data-table';
3029
import { StatCard } from '@/components/analytics/stat-card';
3130
import {
@@ -60,8 +59,6 @@ import {
6059
getBrowserIcon,
6160
getOSIcon,
6261
PercentageBadge,
63-
processBrowserData,
64-
processDeviceData,
6562
TechnologyIcon,
6663
} from '../utils/technology-helpers';
6764
import type { FullTabProps, MetricPoint } from '../utils/types';
@@ -120,8 +117,12 @@ function LiveUserIndicator({ websiteId }: { websiteId: string }) {
120117
}
121118

122119
const getChangeColor = () => {
123-
if (change === 'up') return 'text-green-500';
124-
if (change === 'down') return 'text-red-500';
120+
if (change === 'up') {
121+
return 'text-green-500';
122+
}
123+
if (change === 'down') {
124+
return 'text-red-500';
125+
}
125126
return 'text-foreground';
126127
};
127128

@@ -198,13 +199,7 @@ const deviceTypeColorMap: Record<string, string> = {
198199
unknown: 'text-gray-400',
199200
};
200201

201-
function DeviceTypeCell({
202-
device_type,
203-
name,
204-
}: {
205-
device_type: string;
206-
name: string;
207-
}) {
202+
function DeviceTypeCell({ device_type }: { device_type: string }) {
208203
const Icon = deviceTypeIconMap[device_type] || QuestionIcon;
209204
const colorClass =
210205
deviceTypeColorMap[device_type] || deviceTypeColorMap.unknown;
@@ -226,7 +221,6 @@ function DeviceTypeCell({
226221
export function WebsiteOverviewTab({
227222
websiteId,
228223
dateRange,
229-
websiteData,
230224
isRefreshing,
231225
setIsRefreshing,
232226
}: FullTabProps) {
@@ -433,7 +427,9 @@ export function WebsiteOverviewTab({
433427
};
434428

435429
const chartData = (() => {
436-
if (!analytics.events_by_date?.length) return [];
430+
if (!analytics.events_by_date?.length) {
431+
return [];
432+
}
437433
const filteredEvents = filterFutureEvents(analytics.events_by_date);
438434
return filteredEvents.map((event: any): ChartDataPoint => {
439435
const filtered: ChartDataPoint = {
@@ -459,7 +455,9 @@ export function WebsiteOverviewTab({
459455
})();
460456

461457
const miniChartData = (() => {
462-
if (!analytics.events_by_date?.length) return {};
458+
if (!analytics.events_by_date?.length) {
459+
return {};
460+
}
463461
const filteredEvents = filterFutureEvents(analytics.events_by_date);
464462
const createChartSeries = (
465463
field: string,
@@ -479,7 +477,9 @@ export function WebsiteOverviewTab({
479477
pagesPerSession: createChartSeries('pages_per_session'),
480478
bounceRate: createChartSeries('bounce_rate'),
481479
sessionDuration: createChartSeries('avg_session_duration', (value) => {
482-
if (value < 60) return Math.round(value);
480+
if (value < 60) {
481+
return Math.round(value);
482+
}
483483
const minutes = Math.floor(value / 60);
484484
const seconds = Math.round(value % 60);
485485
return minutes * 60 + seconds;
@@ -563,7 +563,9 @@ export function WebsiteOverviewTab({
563563
};
564564

565565
const formatNumber = (value: number | null | undefined): string => {
566-
if (value == null || Number.isNaN(value)) return '0';
566+
if (value == null || Number.isNaN(value)) {
567+
return '0';
568+
}
567569
return Intl.NumberFormat(undefined, {
568570
notation: 'compact',
569571
maximumFractionDigits: 1,
@@ -754,7 +756,9 @@ export function WebsiteOverviewTab({
754756
const validEntries = period
755757
.map((item) => Number(item[field]))
756758
.filter((value) => !Number.isNaN(value) && value > 0);
757-
if (validEntries.length === 0) return 0;
759+
if (validEntries.length === 0) {
760+
return 0;
761+
}
758762
return (
759763
validEntries.reduce((acc, value) => acc + value, 0) /
760764
validEntries.length
@@ -804,7 +808,9 @@ export function WebsiteOverviewTab({
804808
minimumBase = 0
805809
) => {
806810
const change = calculateTrendPercentage(current, previous, minimumBase);
807-
if (change === undefined) return change;
811+
if (change === undefined) {
812+
return change;
813+
}
808814
return {
809815
change,
810816
current,
@@ -919,8 +925,12 @@ export function WebsiteOverviewTab({
919925
title: 'SESSION DURATION',
920926
value: (() => {
921927
const duration = analytics.summary?.avg_session_duration;
922-
if (!duration) return '0s';
923-
if (duration < 60) return `${duration.toFixed(1)}s`;
928+
if (!duration) {
929+
return '0s';
930+
}
931+
if (duration < 60) {
932+
return `${duration.toFixed(1)}s`;
933+
}
924934
const minutes = Math.floor(duration / 60);
925935
const seconds = Math.round(duration % 60);
926936
return `${minutes}m ${seconds}s`;
@@ -930,13 +940,17 @@ export function WebsiteOverviewTab({
930940
chartData: miniChartData.sessionDuration,
931941
trend: calculateTrends.session_duration,
932942
formatValue: (value: number) => {
933-
if (value < 60) return `${Math.round(value)}s`;
943+
if (value < 60) {
944+
return `${Math.round(value)}s`;
945+
}
934946
const minutes = Math.floor(value / 60);
935947
const seconds = Math.round(value % 60);
936948
return `${minutes}m ${seconds}s`;
937949
},
938950
formatChartValue: (value: number) => {
939-
if (value < 60) return `${Math.round(value)}s`;
951+
if (value < 60) {
952+
return `${Math.round(value)}s`;
953+
}
940954
const minutes = Math.floor(value / 60);
941955
const seconds = Math.round(value % 60);
942956
return `${minutes}m ${seconds}s`;
@@ -1048,7 +1062,7 @@ export function WebsiteOverviewTab({
10481062
initialPageSize={8}
10491063
isLoading={isLoading}
10501064
minHeight={350}
1051-
renderSubRow={(subRow: any, parentRow: any, index: number) => {
1065+
renderSubRow={(subRow: any, parentRow: any) => {
10521066
const propertyKey = subRow.key;
10531067
const propertyTotal = subRow.total;
10541068
const propertyValues = subRow.values;

0 commit comments

Comments
 (0)