Skip to content

Commit a3548f8

Browse files
committed
fix: edit website
1 parent 8181e09 commit a3548f8

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

apps/dashboard/components/layout/navigation/navigation-config.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ export const websiteNavigation: NavigationSection[] = [
277277
alpha: true,
278278
rootLevel: false,
279279
}),
280-
createNavItem("Databunny AI", RobotIcon, "/assistant", {
281-
alpha: true,
282-
hideFromDemo: true,
283-
rootLevel: false,
284-
}),
280+
// createNavItem("Databunny AI", RobotIcon, "/assistant", {
281+
// alpha: true,
282+
// hideFromDemo: true,
283+
// rootLevel: false,
284+
// }),
285285
]),
286286
];
287287

apps/dashboard/components/website-dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export function WebsiteDialog({
131131
};
132132

133133
try {
134-
if (isEditing) {
134+
if (website?.id) {
135135
const updateData: UpdateWebsiteInput = {
136136
id: website.id,
137137
name: formData.name,
@@ -151,7 +151,7 @@ export function WebsiteDialog({
151151
}
152152
onOpenChange(false);
153153
} catch (error: unknown) {
154-
const message = getErrorMessage(error, isEditing);
154+
const message = getErrorMessage(error, !!website?.id);
155155
toast.error(message);
156156
}
157157
});

apps/dashboard/hooks/use-websites.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ const updateWebsiteCache = (
129129
updateWebsiteInList(old, updatedWebsite)
130130
);
131131
queryClient.setQueryData(getByIdKey, updatedWebsite);
132+
133+
queryClient.invalidateQueries({ queryKey: getByIdKey });
134+
queryClient.invalidateQueries({ queryKey: listKey });
132135
};
133136

134137
export function useUpdateWebsite() {

packages/rpc/src/services/website-service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
eq,
55
type InferSelectModel,
66
isNull,
7+
ne,
78
websites,
89
} from "@databuddy/db";
910
import { logger } from "@databuddy/shared/utils/discord-webhook";
@@ -272,16 +273,20 @@ export class WebsiteService {
272273
private validateDomainIfPresentAndFlow(
273274
updates: Updates,
274275
userId: string,
275-
organizationId?: string
276+
organizationId?: string,
277+
excludeWebsiteId?: string
276278
): Effect.Effect<Updates, WebsiteError> {
277279
if (!updates.domain) {
278280
return Effect.succeed(updates);
279281
}
280282
const domainToUpdate = buildFullDomain(updates.domain as string);
281-
const websiteFilter = and(
283+
const baseFilter = and(
282284
eq(websites.domain, domainToUpdate),
283285
buildWebsiteFilter(userId, organizationId)
284286
);
287+
const websiteFilter = excludeWebsiteId
288+
? and(baseFilter, ne(websites.id, excludeWebsiteId))
289+
: baseFilter;
285290
return pipe(
286291
this.performDBOperation<Website | null>(() =>
287292
this.db.query.websites.findFirst({ where: websiteFilter }).then((result) => result ?? null)
@@ -311,7 +316,7 @@ export class WebsiteService {
311316
Effect.succeed(updates),
312317
Effect.flatMap(this.validateNameIfPresentAndFlow),
313318
Effect.flatMap((u) =>
314-
this.validateDomainIfPresentAndFlow(u, userId, organizationId)
319+
this.validateDomainIfPresentAndFlow(u, userId, organizationId, websiteId)
315320
),
316321
Effect.flatMap((finalUpdates) =>
317322
this.performDBOperation<Website | null>(() => updateFn(finalUpdates))

0 commit comments

Comments
 (0)