Bernt Christian Egeland 7 місяців тому
батько
коміт
8b3e120301

+ 21 - 0
src/app/(authenticated)/settings/invoice-template/page.tsx

@@ -1,8 +1,29 @@
 import { getSettings } from "@/features/settings/Actions/settingsActions";
 import { SETTING_KEYS } from "@/features/settings/Schema/settingsSchema";
 import { TemplateSettings } from "./template-settings";
+import { getLayoutData } from "@/lib/get-layout-data";
+import { getFeatures, isCloudMode } from "@/lib/features";
+import { FeatureLockedMessage } from "../feature-locked-message";
+import { redirect } from "next/navigation";
 
 export default async function InvoiceTemplatePage() {
+  const data = await getLayoutData();
+
+  if (data.status === "unauthenticated") redirect("/auth/sign-in");
+  if (data.status === "no-organization") redirect("/onboarding");
+
+  const features = await getFeatures(data.organizationId);
+
+  if (!features.customTemplates) {
+    return (
+      <FeatureLockedMessage
+        feature="Invoice Templates"
+        description="Choose from pre-built invoice templates and customize colors, fonts, and header layouts for your PDF invoices and quotes."
+        isCloud={isCloudMode()}
+      />
+    );
+  }
+
   const result = await getSettings([
     SETTING_KEYS.INVOICE_PRIMARY_COLOR,
     SETTING_KEYS.INVOICE_FONT_FAMILY,

+ 1 - 0
src/app/(authenticated)/settings/settings-nav.tsx

@@ -69,6 +69,7 @@ const settingsNav: SettingsNavItem[] = [
     href: "/settings/invoice-template",
     icon: Layout,
     description: "Invoice styling & colors",
+    gate: "customTemplates",
   },
   {
     title: "Payment",

+ 5 - 0
src/lib/features.ts

@@ -7,6 +7,7 @@ export type PlanFeatures = {
   maxCustomers: number
   maxUsers: number
   templates: number
+  customTemplates: boolean
   reports: boolean
   smtp: boolean
   api: boolean
@@ -21,6 +22,7 @@ export const PLAN_FEATURES: Record<Plan, PlanFeatures> = {
     maxCustomers: 5,
     maxUsers: 1,
     templates: 2,
+    customTemplates: false,
     reports: true,
     smtp: false,
     api: false,
@@ -33,6 +35,7 @@ export const PLAN_FEATURES: Record<Plan, PlanFeatures> = {
     maxCustomers: 999999,
     maxUsers: 5,
     templates: 999999,
+    customTemplates: true,
     reports: true,
     smtp: true,
     api: true,
@@ -45,6 +48,7 @@ export const PLAN_FEATURES: Record<Plan, PlanFeatures> = {
     maxCustomers: 999999,
     maxUsers: 50,
     templates: 999999,
+    customTemplates: true,
     reports: true,
     smtp: true,
     api: true,
@@ -57,6 +61,7 @@ export const PLAN_FEATURES: Record<Plan, PlanFeatures> = {
     maxCustomers: 999999,
     maxUsers: 999999,
     templates: 999999,
+    customTemplates: true,
     reports: true,
     smtp: true,
     api: true,