Skip to content

Commit a3dc000

Browse files
committed
ts pmo
1 parent 36d7e27 commit a3dc000

File tree

4 files changed

+13
-30
lines changed

4 files changed

+13
-30
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import {
55
ClipboardIcon,
66
DownloadIcon,
77
InfoIcon,
8+
UserIcon,
89
WarningCircleIcon,
910
} from '@phosphor-icons/react';
1011
import dayjs from 'dayjs';
1112
import { useRouter } from 'next/navigation';
1213
import { useCallback, useState } from 'react';
1314
import type { DateRange as DayPickerRange } from 'react-day-picker';
1415
import { toast } from 'sonner';
16+
import { FaviconImage } from '@/components/analytics/favicon-image';
1517
import { DateRangePicker } from '@/components/date-range-picker';
1618
import {
1719
AlertDialog,
@@ -31,7 +33,6 @@ import { WebsiteDialog } from '@/components/website-dialog';
3133
import { useDataExport } from '@/hooks/use-data-export';
3234
import { useDeleteWebsite, useTogglePublicWebsite } from '@/hooks/use-websites';
3335
import { SETTINGS_TABS, TOAST_MESSAGES } from '../shared/tracking-constants';
34-
3536
import type {
3637
DeleteWebsiteDialogProps,
3738
ExportFormat,

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,27 @@ import type {
44
Website,
55
} from '@databuddy/shared';
66

7-
// Extended date range with granularity
87
export interface DateRange extends BaseDateRange {
98
granularity?: 'daily' | 'hourly';
109
}
1110

12-
// Settings tab specific types
13-
export type SettingsTab =
14-
| 'tracking'
15-
| 'basic'
16-
| 'advanced'
17-
| 'optimization'
18-
| 'privacy'
19-
| 'export';
11+
export type SettingsTab = 'privacy' | 'export';
2012

21-
// Base tab props shared across all tabs
2213
export interface BaseTabProps {
2314
websiteId: string;
2415
dateRange: DateRange;
2516
}
2617

27-
// Tab props with refresh functionality
2818
export interface RefreshableTabProps extends BaseTabProps {
2919
isRefreshing: boolean;
3020
setIsRefreshing: (value: boolean) => void;
3121
}
3222

33-
// Tab props with website data
3423
export interface WebsiteDataTabProps extends BaseTabProps {
3524
websiteData: Website | undefined;
3625
onWebsiteUpdated?: () => void;
3726
}
3827

39-
// Combined tab props that include all features
4028
export interface FullTabProps extends BaseTabProps {
4129
websiteData: Website | undefined;
4230
isRefreshing: boolean;
@@ -45,7 +33,6 @@ export interface FullTabProps extends BaseTabProps {
4533
addFilter: (filter: DynamicQueryFilter) => void;
4634
}
4735

48-
// Common analytics data types
4936
export interface MetricPoint {
5037
date: string;
5138
pageviews?: number;
@@ -67,48 +54,40 @@ export interface TableColumn {
6754
className?: string;
6855
}
6956

70-
// Settings-related types
7157
export interface WebsiteFormData {
7258
name?: string;
7359
domain?: string;
7460
}
7561

7662
export interface TrackingOptions {
77-
// Core tracking
7863
disabled: boolean;
7964
trackScreenViews: boolean;
8065
trackHashChanges: boolean;
8166
trackSessions: boolean;
8267

83-
// Interaction tracking
8468
trackAttributes: boolean;
8569
trackOutgoingLinks: boolean;
8670
trackInteractions: boolean;
8771

88-
// Advanced tracking
8972
trackEngagement: boolean;
9073
trackScrollDepth: boolean;
9174
trackExitIntent: boolean;
9275
trackBounceRate: boolean;
9376

94-
// Performance tracking
9577
trackPerformance: boolean;
9678
trackWebVitals: boolean;
9779
trackErrors: boolean;
9880

99-
// Optimization
10081
samplingRate: number;
10182
enableRetries: boolean;
10283
maxRetries: number;
10384
initialRetryDelay: number;
10485

105-
// Batching
10686
enableBatching: boolean;
10787
batchSize: number;
10888
batchTimeout: number;
10989
}
11090

111-
// Component-specific prop interfaces
11291
export interface WebsiteHeaderProps {
11392
websiteData: Website;
11493
websiteId: string;

apps/dashboard/hooks/use-website-transfer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import { trpc } from '@/lib/trpc';
44

5-
export function useWebsiteTransfer(organizationId: string) {
5+
export function useWebsiteTransfer(organizationId?: string) {
66
// Fetch personal websites (no organizationId)
77
const { data: personalWebsites, isLoading: isLoadingPersonal } =
88
trpc.websites.list.useQuery({
99
organizationId: undefined,
1010
});
1111

12-
// Fetch organization websites
12+
// Fetch organization websites (only if organizationId is provided)
1313
const { data: organizationWebsites, isLoading: isLoadingOrg } =
1414
trpc.websites.list.useQuery(
1515
{
@@ -23,10 +23,10 @@ export function useWebsiteTransfer(organizationId: string) {
2323
const utils = trpc.useUtils();
2424

2525
const transferMutation = trpc.websites.transfer.useMutation({
26-
onSuccess: () => {
27-
// Invalidate both queries to refresh the data
28-
utils.websites.list.invalidate({ organizationId: undefined });
29-
utils.websites.list.invalidate({ organizationId });
26+
onSuccess: (_, variables) => {
27+
utils.websites.list.invalidate();
28+
utils.websites.listWithCharts.invalidate();
29+
utils.websites.getById.invalidate({ id: variables.websiteId });
3030
},
3131
});
3232

packages/rpc/src/routers/websites.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ export const websitesRouter = createTRPCRouter({
365365
if (input.organizationId) {
366366
const { success } = await websitesApi.hasPermission({
367367
headers: ctx.headers,
368-
body: { permissions: { website: ['create'] } },
368+
body: {
369+
organizationId: input.organizationId,
370+
permissions: { website: ['create'] },
371+
},
369372
});
370373
if (!success) {
371374
throw new TRPCError({

0 commit comments

Comments
 (0)