diff --git a/apps/dokploy/components/dashboard/settings/web-server/license-key.tsx b/apps/dokploy/components/dashboard/settings/web-server/license-key.tsx index 7ba5aadcd..ed02180e9 100644 --- a/apps/dokploy/components/dashboard/settings/web-server/license-key.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server/license-key.tsx @@ -10,9 +10,9 @@ import { api } from "@/utils/api"; export function LicenseKeySettings() { const utils = api.useUtils(); - const { data, isLoading } = api.organization.getEnterpriseSettings.useQuery(); + const { data, isLoading } = api.licenseKey.getEnterpriseSettings.useQuery(); const { mutateAsync: updateEnterpriseSettings, isLoading: isSaving } = - api.organization.updateEnterpriseSettings.useMutation(); + api.licenseKey.updateEnterpriseSettings.useMutation(); const [licenseKey, setLicenseKey] = useState(""); @@ -45,7 +45,7 @@ export function LicenseKeySettings() { await updateEnterpriseSettings({ enableEnterpriseFeatures: next, }); - await utils.organization.getEnterpriseSettings.invalidate(); + await utils.licenseKey.getEnterpriseSettings.invalidate(); toast.success("Enterprise features updated"); } catch (error) { console.error(error); @@ -57,7 +57,8 @@ export function LicenseKeySettings() {

- To unlock extra features you need an enterprise license key. Contact us{" "} + To unlock extra features you need an enterprise license key. Contact + us{" "} { try { await updateEnterpriseSettings({ licenseKey }); - await utils.organization.getEnterpriseSettings.invalidate(); + await utils.licenseKey.getEnterpriseSettings.invalidate(); toast.success("License key saved"); } catch (error) { console.error(error); diff --git a/apps/dokploy/server/api/routers/organization.ts b/apps/dokploy/server/api/routers/organization.ts index c46c43c83..834c8a399 100644 --- a/apps/dokploy/server/api/routers/organization.ts +++ b/apps/dokploy/server/api/routers/organization.ts @@ -4,51 +4,9 @@ import { and, desc, eq, exists } from "drizzle-orm"; import { nanoid } from "nanoid"; import { z } from "zod"; import { db } from "@/server/db"; -import { invitation, member, organization, user } from "@/server/db/schema"; +import { invitation, member, organization } from "@/server/db/schema"; import { adminProcedure, createTRPCRouter, protectedProcedure } from "../trpc"; export const organizationRouter = createTRPCRouter({ - getEnterpriseSettings: adminProcedure.query(async ({ ctx }) => { - const currentUserId = ctx.user.id; - const currentUser = await db.query.user.findFirst({ - where: eq(user.id, currentUserId), - }); - - if (!currentUser) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "User not found", - }); - } - - return { - enableEnterpriseFeatures: !!currentUser.enableEnterpriseFeatures, - licenseKey: currentUser.licenseKey ?? "", - }; - }), - - updateEnterpriseSettings: adminProcedure - .input( - z.object({ - enableEnterpriseFeatures: z.boolean().optional(), - licenseKey: z.string().optional(), - }), - ) - .mutation(async ({ ctx, input }) => { - const currentUserId = ctx.user.id; - - await db - .update(user) - .set({ - ...(input.enableEnterpriseFeatures === undefined - ? {} - : { enableEnterpriseFeatures: input.enableEnterpriseFeatures }), - ...(input.licenseKey === undefined ? {} : { licenseKey: input.licenseKey }), - }) - .where(eq(user.id, currentUserId)); - - return true; - }), - create: protectedProcedure .input( z.object({