Skip to content

Commit ce15444

Browse files
committed
fix: vercel sdk return domains, favicons, schemmam fix
1 parent c0f14ac commit ce15444

File tree

6 files changed

+174
-152
lines changed

6 files changed

+174
-152
lines changed

apps/dashboard/app/(main)/settings/integrations/vercel/_components/create-website-dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function CreateWebsiteDialog({
5959
name: '', // Start with empty name, will use placeholder
6060
target: isMultipleMode
6161
? inferTargetFromDomain(domain)
62-
: (['production', 'preview', 'development'] as string[]),
62+
: (['production', 'preview'] as string[]),
6363
}));
6464
setWebsiteConfigs(configs);
6565
}
@@ -198,7 +198,7 @@ export function CreateWebsiteDialog({
198198
Target Environments
199199
</Label>
200200
<div className="flex flex-wrap gap-2">
201-
{['production', 'preview', 'development'].map((env) => (
201+
{['production', 'preview'].map((env) => (
202202
<Button
203203
className="h-8 rounded text-xs transition-colors"
204204
key={env}

apps/dashboard/app/(main)/settings/integrations/vercel/_components/project-row.tsx

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@phosphor-icons/react';
88
import { AnimatePresence, motion } from 'framer-motion';
99
import { useState } from 'react';
10+
import { FaviconImage } from '@/components/analytics/favicon-image';
1011
import { Badge } from '@/components/ui/badge';
1112
import { Button } from '@/components/ui/button';
1213
import { Checkbox } from '@/components/ui/checkbox';
@@ -134,25 +135,44 @@ export function ProjectRow({
134135
<CaretRightIcon className="h-4 w-4 text-muted-foreground" />
135136
</motion.div>
136137

137-
<div className="mr-3 flex h-8 w-8 items-center justify-center rounded bg-muted font-medium text-muted-foreground text-sm">
138-
{project.name.charAt(0).toUpperCase()}
139-
</div>
138+
{project.primaryDomain ? (
139+
<div className="mr-3">
140+
<FaviconImage
141+
className="size-8"
142+
domain={project.primaryDomain}
143+
fallbackIcon={
144+
<div className="flex h-8 w-8 items-center justify-center rounded bg-muted font-medium text-muted-foreground text-sm">
145+
{project.name.charAt(0).toUpperCase()}
146+
</div>
147+
}
148+
size={32}
149+
/>
150+
</div>
151+
) : (
152+
<div className="mr-3 flex h-8 w-8 items-center justify-center rounded bg-muted font-medium text-muted-foreground text-sm">
153+
{project.name.charAt(0).toUpperCase()}
154+
</div>
155+
)}
140156

141-
<div className="flex items-center">
142-
<span className="font-medium text-foreground">{project.name}</span>
143-
{project.framework && (
144-
<Badge className="ml-2 text-xs" variant="secondary">
145-
{project.framework}
146-
</Badge>
147-
)}
148-
{project.live && (
149-
<Badge
150-
className="ml-2 bg-green-100 text-green-800 text-xs dark:bg-green-900 dark:text-green-100"
151-
variant="default"
152-
>
153-
Live
154-
</Badge>
155-
)}
157+
<div className="flex flex-col">
158+
<div className="flex items-center">
159+
<span className="font-medium text-foreground">
160+
{project.name}
161+
</span>
162+
{project.framework && (
163+
<Badge className="ml-2 text-xs" variant="secondary">
164+
{project.framework}
165+
</Badge>
166+
)}
167+
{project.live && (
168+
<Badge
169+
className="ml-2 bg-green-100 text-green-800 text-xs dark:bg-green-900 dark:text-green-100"
170+
variant="default"
171+
>
172+
Live
173+
</Badge>
174+
)}
175+
</div>
156176
</div>
157177
</div>
158178

apps/dashboard/app/(main)/settings/integrations/vercel/_components/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export interface Project {
88
live?: boolean;
99
createdAt?: number;
1010
updatedAt?: number;
11+
primaryDomain?: string;
12+
productionUrl?: string;
1113
link?: {
1214
type: string;
1315
repo?: string;

apps/dashboard/app/(main)/settings/integrations/vercel/_components/utils.ts

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,16 @@ export const generateWebsitePlaceholder = (domainName: string) => {
1111
};
1212

1313
export const inferTargetFromDomain = (domain: Domain): string[] => {
14-
const name = domain.name.toLowerCase();
15-
16-
if (name.endsWith('.vercel.app')) {
17-
return ['preview'];
18-
}
19-
20-
if (domain.customEnvironmentId) {
21-
return ['preview', 'development'];
22-
}
23-
24-
if (
25-
name.includes('staging') ||
26-
name.includes('stage') ||
27-
name.includes('dev') ||
28-
name.includes('preview') ||
29-
name.includes('test')
30-
) {
31-
return ['preview', 'development'];
14+
// BOOOOOM: No redirect status code = production
15+
if (!domain.redirectStatusCode) {
16+
return ['production'];
3217
}
3318

34-
if (
35-
domain.gitBranch &&
36-
domain.gitBranch !== 'main' &&
37-
domain.gitBranch !== 'master'
38-
) {
19+
// BOOOOOOOOOM: Has redirect status = not production (preview only)
20+
if (domain.redirectStatusCode) {
3921
return ['preview'];
4022
}
4123

42-
if (!(name.endsWith('.vercel.app') || domain.customEnvironmentId)) {
43-
return ['production'];
44-
}
45-
24+
// Fallback (should not reach here, but just in case)
4625
return ['production'];
4726
};

0 commit comments

Comments
 (0)