Skip to content

Commit bc45a6d

Browse files
committed
Fix lint issues in dashboard.
1 parent f1aee4e commit bc45a6d

File tree

10 files changed

+105
-39
lines changed

10 files changed

+105
-39
lines changed

apps/dashboard/app/(main)/websites/[id]/errors/_components/error-table-columns.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,15 @@ export const createErrorTypeColumns = () => [
130130

131131
export const createDeviceColumn = () =>
132132
createNameColumn('Device Type', (name) => {
133-
if (!name)
133+
if (!name) {
134134
return (
135135
<MonitorIcon
136136
className="h-4 w-4 text-gray-500"
137137
size={16}
138138
weight="duotone"
139139
/>
140140
);
141+
}
141142

142143
const device = name.toLowerCase();
143144
return device.includes('mobile') || device.includes('phone') ? (

apps/dashboard/app/(main)/websites/[id]/errors/_components/error-trends-chart.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ export const ErrorTrendsChart = ({ errorChartData }: ErrorTrendsChartProps) => {
155155
axisLine={false}
156156
tick={{ fontSize: 10, fill: 'var(--muted-foreground)' }}
157157
tickFormatter={(value) => {
158-
if (value >= 1_000_000)
158+
if (value >= 1_000_000) {
159159
return `${(value / 1_000_000).toFixed(1)}M`;
160-
if (value >= 1000) return `${(value / 1000).toFixed(1)}k`;
160+
}
161+
if (value >= 1000) {
162+
return `${(value / 1000).toFixed(1)}k`;
163+
}
161164
return value.toString();
162165
}}
163166
tickLine={false}

apps/dashboard/app/(main)/websites/[id]/errors/_components/errors-page-content.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ export const ErrorsPageContent = ({ params }: ErrorsPageContentProps) => {
4343
// Add a new filter
4444
const addFilter = (field: string, value: string | number) => {
4545
// Prevent adding duplicate filters
46-
if (activeFilters.some((f) => f.field === field && f.value === value))
46+
if (activeFilters.some((f) => f.field === field && f.value === value)) {
4747
return;
48+
}
4849

4950
const newFilter: DynamicQueryFilter = { field, operator: 'eq', value };
5051
setActiveFilters((prev) => [...prev, newFilter]);
@@ -182,7 +183,9 @@ export const ErrorsPageContent = ({ params }: ErrorsPageContentProps) => {
182183

183184
// Find the top error
184185
const topError = useMemo(() => {
185-
if (!processedData.error_types?.length) return null;
186+
if (!processedData.error_types?.length) {
187+
return null;
188+
}
186189

187190
return processedData.error_types.reduce(
188191
(max, error) => (error.count > max.count ? error : max),
@@ -192,7 +195,9 @@ export const ErrorsPageContent = ({ params }: ErrorsPageContentProps) => {
192195

193196
// Chart data for error trends
194197
const errorChartData = useMemo(() => {
195-
if (!processedData.error_trends?.length) return [];
198+
if (!processedData.error_trends?.length) {
199+
return [];
200+
}
196201

197202
return processedData.error_trends.map((point: any) => ({
198203
date: safeFormatDate(point.date, 'MMM d'),

apps/dashboard/app/(main)/websites/[id]/errors/_components/top-error-card.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ interface TopErrorCardProps {
1010
}
1111

1212
export const TopErrorCard = ({ topError }: TopErrorCardProps) => {
13-
if (!topError) return null;
13+
if (!topError) {
14+
return null;
15+
}
1416

1517
return (
1618
<Card>

apps/dashboard/app/(main)/websites/[id]/errors/_components/utils.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@ import { format, isValid, parseISO } from 'date-fns';
22

33
// Helper function to safely parse dates
44
export const safeDateParse = (dateString: string): Date => {
5-
if (!dateString) return new Date();
5+
if (!dateString) {
6+
return new Date();
7+
}
68

79
let date = parseISO(dateString);
8-
if (isValid(date)) return date;
10+
if (isValid(date)) {
11+
return date;
12+
}
913

1014
const isoString = dateString.replace(' ', 'T');
1115
date = parseISO(isoString);
12-
if (isValid(date)) return date;
16+
if (isValid(date)) {
17+
return date;
18+
}
1319

1420
date = new Date(dateString);
15-
if (isValid(date)) return date;
21+
if (isValid(date)) {
22+
return date;
23+
}
1624

1725
console.warn('Failed to parse date:', dateString);
1826
return new Date();

apps/dashboard/app/(main)/websites/[id]/funnels/_components/edit-funnel-dialog.tsx

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ export function EditFunnelDialog({
9393
}, [funnel]);
9494

9595
const handleSubmit = async () => {
96-
if (!formData) return;
96+
if (!formData) {
97+
return;
98+
}
9799

98100
if (isCreateMode && onCreate) {
99101
const createData: CreateFunnelData = {
@@ -132,7 +134,9 @@ export function EditFunnelDialog({
132134
}, [isCreateMode]);
133135

134136
const addStep = useCallback(() => {
135-
if (!formData) return;
137+
if (!formData) {
138+
return;
139+
}
136140
setFormData((prev) =>
137141
prev
138142
? {
@@ -148,7 +152,9 @@ export function EditFunnelDialog({
148152

149153
const removeStep = useCallback(
150154
(index: number) => {
151-
if (!formData || formData.steps.length <= 2) return;
155+
if (!formData || formData.steps.length <= 2) {
156+
return;
157+
}
152158
setFormData((prev) =>
153159
prev
154160
? {
@@ -163,7 +169,9 @@ export function EditFunnelDialog({
163169

164170
const updateStep = useCallback(
165171
(index: number, field: keyof FunnelStep, value: string) => {
166-
if (!formData) return;
172+
if (!formData) {
173+
return;
174+
}
167175
setFormData((prev) =>
168176
prev
169177
? {
@@ -180,13 +188,17 @@ export function EditFunnelDialog({
180188

181189
const reorderSteps = useCallback(
182190
(result: DropResult) => {
183-
if (!(result.destination && formData)) return;
191+
if (!(result.destination && formData)) {
192+
return;
193+
}
184194

185195
const sourceIndex = result.source.index;
186196
const destinationIndex = result.destination.index;
187197

188198
// No change needed
189-
if (sourceIndex === destinationIndex) return;
199+
if (sourceIndex === destinationIndex) {
200+
return;
201+
}
190202

191203
const items = [...formData.steps];
192204
const [reorderedItem] = items.splice(sourceIndex, 1);
@@ -205,7 +217,9 @@ export function EditFunnelDialog({
205217
);
206218

207219
const addFilter = useCallback(() => {
208-
if (!formData) return;
220+
if (!formData) {
221+
return;
222+
}
209223
setFormData((prev) =>
210224
prev
211225
? {
@@ -221,7 +235,9 @@ export function EditFunnelDialog({
221235

222236
const removeFilter = useCallback(
223237
(index: number) => {
224-
if (!formData) return;
238+
if (!formData) {
239+
return;
240+
}
225241
setFormData((prev) =>
226242
prev
227243
? {
@@ -236,7 +252,9 @@ export function EditFunnelDialog({
236252

237253
const updateFilter = useCallback(
238254
(index: number, field: keyof FunnelFilter, value: string) => {
239-
if (!formData) return;
255+
if (!formData) {
256+
return;
257+
}
240258
setFormData((prev) =>
241259
prev
242260
? {
@@ -275,7 +293,9 @@ export function EditFunnelDialog({
275293

276294
const getSuggestions = useCallback(
277295
(field: string): string[] => {
278-
if (!autocompleteData) return [];
296+
if (!autocompleteData) {
297+
return [];
298+
}
279299

280300
switch (field) {
281301
case 'browser_name':
@@ -301,7 +321,9 @@ export function EditFunnelDialog({
301321

302322
const getStepSuggestions = useCallback(
303323
(stepType: string): string[] => {
304-
if (!autocompleteData) return [];
324+
if (!autocompleteData) {
325+
return [];
326+
}
305327

306328
if (stepType === 'PAGE_VIEW') {
307329
return autocompleteData.pagePaths || [];
@@ -324,15 +346,19 @@ export function EditFunnelDialog({
324346

325347
// Memoize form validation
326348
const isFormValid = useMemo(() => {
327-
if (!formData) return false;
349+
if (!formData) {
350+
return false;
351+
}
328352
return (
329353
formData.name &&
330354
!formData.steps.some((s) => !(s.name && s.target)) &&
331355
!(formData.filters || []).some((f) => !f.value || f.value === '')
332356
);
333357
}, [formData]);
334358

335-
if (!formData) return null;
359+
if (!formData) {
360+
return null;
361+
}
336362

337363
return (
338364
<Sheet onOpenChange={handleClose} open={isOpen}>

apps/dashboard/app/(main)/websites/[id]/goals/_components/delete-goal-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { Target, Trash } from '@phosphor-icons/react';
3+
import { Trash } from '@phosphor-icons/react';
44
import {
55
AlertDialog,
66
AlertDialogAction,

apps/dashboard/app/(main)/websites/[id]/goals/_components/edit-goal-dialog.tsx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export function EditGoalDialog({
7171
}, [goal]);
7272

7373
const handleSubmit = async () => {
74-
if (!formData) return;
74+
if (!formData) {
75+
return;
76+
}
7577
await onSave(formData);
7678
};
7779

@@ -89,7 +91,9 @@ export function EditGoalDialog({
8991

9092
const updateGoal = useCallback(
9193
(field: keyof Goal | keyof CreateGoalData, value: string) => {
92-
if (!formData) return;
94+
if (!formData) {
95+
return;
96+
}
9397
setFormData((prev) =>
9498
prev
9599
? {
@@ -103,7 +107,9 @@ export function EditGoalDialog({
103107
);
104108

105109
const addFilter = useCallback(() => {
106-
if (!formData) return;
110+
if (!formData) {
111+
return;
112+
}
107113
setFormData((prev) =>
108114
prev
109115
? {
@@ -119,7 +125,9 @@ export function EditGoalDialog({
119125

120126
const removeFilter = useCallback(
121127
(index: number) => {
122-
if (!formData) return;
128+
if (!formData) {
129+
return;
130+
}
123131
setFormData((prev) =>
124132
prev
125133
? {
@@ -134,7 +142,9 @@ export function EditGoalDialog({
134142

135143
const updateFilter = useCallback(
136144
(index: number, field: keyof any, value: string) => {
137-
if (!formData) return;
145+
if (!formData) {
146+
return;
147+
}
138148
setFormData((prev) =>
139149
prev
140150
? {
@@ -173,7 +183,9 @@ export function EditGoalDialog({
173183

174184
const getSuggestions = useCallback(
175185
(field: string): string[] => {
176-
if (!autocompleteData) return [];
186+
if (!autocompleteData) {
187+
return [];
188+
}
177189

178190
switch (field) {
179191
case 'browser_name':
@@ -199,7 +211,9 @@ export function EditGoalDialog({
199211

200212
const getStepSuggestions = useCallback(
201213
(stepType: string): string[] => {
202-
if (!autocompleteData) return [];
214+
if (!autocompleteData) {
215+
return [];
216+
}
203217

204218
if (stepType === 'PAGE_VIEW') {
205219
return autocompleteData.pagePaths || [];
@@ -222,7 +236,9 @@ export function EditGoalDialog({
222236

223237
// Memoize form validation
224238
const isFormValid = useMemo(() => {
225-
if (!formData) return false;
239+
if (!formData) {
240+
return false;
241+
}
226242
return (
227243
formData.name &&
228244
formData.target &&
@@ -253,7 +269,9 @@ export function EditGoalDialog({
253269
}
254270
};
255271

256-
if (!formData) return null;
272+
if (!formData) {
273+
return null;
274+
}
257275

258276
return (
259277
<Sheet onOpenChange={handleClose} open={isOpen}>

apps/dashboard/app/(main)/websites/[id]/goals/_components/goal-analytics.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function GoalAnalytics({
2727
return (
2828
<div className="space-y-4">
2929
<div className="grid grid-cols-1 gap-4 md:grid-cols-3">
30-
{[...Array(3)].map((_, i) => (
30+
{[...new Array(3)].map((_, i) => (
3131
<Card className="animate-pulse rounded" key={i}>
3232
<CardContent className="p-6">
3333
<div className="mb-2 h-4 w-24 rounded bg-muted" />
@@ -79,8 +79,12 @@ export function GoalAnalytics({
7979
}
8080

8181
const formatNumber = (num: number) => {
82-
if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`;
83-
if (num >= 1000) return `${(num / 1000).toFixed(1)}K`;
82+
if (num >= 1_000_000) {
83+
return `${(num / 1_000_000).toFixed(1)}M`;
84+
}
85+
if (num >= 1000) {
86+
return `${(num / 1000).toFixed(1)}K`;
87+
}
8488
return num.toLocaleString();
8589
};
8690

apps/dashboard/app/(main)/websites/[id]/goals/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { TrendDownIcon } from '@phosphor-icons/react';
44
import { useAtom } from 'jotai';
55
import { useParams } from 'next/navigation';
66
import {
7-
lazy,
87
Suspense,
98
useCallback,
109
useEffect,
@@ -33,7 +32,7 @@ import { GoalsList } from './_components/goals-list';
3332

3433
const GoalsListSkeleton = () => (
3534
<div className="space-y-3">
36-
{[...Array(3)].map((_, i) => (
35+
{[...new Array(3)].map((_, i) => (
3736
<Card className="animate-pulse rounded-xl" key={`goal-skeleton-${i + 1}`}>
3837
<div className="p-6">
3938
<div className="mb-4 flex items-start justify-between">

0 commit comments

Comments
 (0)