Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ency07/B2B/llms.txt

Use this file to discover all available pages before exploring further.

ERP B2B Premium supports complete white-label branding per tenant. Each tenant’s public site displays their own logo, primary color, favicon, and company name — loaded dynamically from tenant_settings at request time. No redeployment is required to change branding.

How Branding Is Applied

The public layout calls getPublicTenantSettings(tenantCode) server-side during rendering. Because this action requires no authentication, it runs safely inside Next.js generateMetadata and root layout Server Components. The returned branding object is passed to the layout as CSS variables and page metadata. When a tenant has not yet configured branding settings, getBrandingDefaults(tenantCode) in src/platform/branding/branding-defaults.ts supplies hardcoded fallback values for known tenant codes. This prevents blank pages and broken layouts during initial tenant provisioning. The full branding write path (used by the admin UI) goes through saveTenantBranding in src/web/actions/branding.ts, which:
  1. Upserts all changed keys into tenant_settings with is_public: true, automatically assigning each key to its correct module (EMPRESA, IDENTIDAD, LOCALIZACION, or DOCUMENTOS).
  2. Takes a full branding snapshot and stores it as a new row in tenant_branding_version.
This gives every tenant a complete version history that can be rolled back via restoreBrandingVersion.

Branding Server Actions

All branding actions live in src/web/actions/branding.ts and are marked "use server".
ActionPermission RequiredDescription
getTenantBranding(tenantCode?)Return the consolidated BrandingConfig for a tenant
saveTenantBranding(tenantCode, data, description?)branding.manageUpsert branding keys and snapshot to version history
getBrandingHistory(tenantCode?)List all BrandingVersion snapshots, newest first
restoreBrandingVersion(tenantCode, versionId)branding.manageRe-apply a historical snapshot and log a new version entry
uploadBrandingLogo(tenantCode, fileType, base64Data, fileName, mimeType)branding.manageUpload an image to the tenant-logos Storage bucket and return its public URL
getPublicBranding(tenantCode?)Alias for getTenantBranding; safe for unauthenticated contexts

saveTenantBranding

saveTenantBranding(
  tenantCode: string | null,
  data: Partial<BrandingConfig>,
  versionDescription?: string
): Promise<{ success: boolean; error?: string }>
Accepts a partial BrandingConfig object. Only the keys present in data are upserted — other keys are left unchanged. After the upsert, a full snapshot of the active branding config is written to tenant_branding_version.

getBrandingHistory

getBrandingHistory(tenantCode?: string | null): Promise<BrandingVersion[]>
Returns an array of BrandingVersion objects ordered newest-first:
interface BrandingVersion {
  id: string;
  version_number: number;
  config_values: BrandingConfig;
  description: string;
  created_at: string;
}

restoreBrandingVersion

restoreBrandingVersion(
  tenantCode: string | null,
  versionId: string
): Promise<{ success: boolean; error?: string }>
Re-applies a historical snapshot by upserting all keys from config_values back into tenant_settings, then creates a new version entry with a description referencing the restored version number.
uploadBrandingLogo(
  tenantCode: string | null,
  fileType: string,      // e.g. "logo_url", "favicon_url"
  base64Data: string,    // base64-encoded file contents
  fileName: string,
  mimeType: string
): Promise<{ success: boolean; url?: string; error?: string }>
Uploads to the tenant-logos Storage bucket (created automatically if it does not exist) and returns the public URL. Store the returned url value in the matching config_key row via saveTenantBranding.

Branding Configuration Checklist

1

Set the commercial name

Call saveTenantBranding with { nombre_comercial: "..." }. This key is stored under module EMPRESA and is the display name shown in the navigation header and page titles.
2

Upload and set logos

Call uploadBrandingLogo with your image data, then pass the returned URL to saveTenantBranding as { logo_url: "..." } (light background) and/or { logo_secondary_url: "..." } (dark background).
3

Upload and set the favicon

Upload a .ico, .png, or .svg file with uploadBrandingLogo, then save the URL as { favicon_url: "..." }. This appears in the browser tab and bookmarks.
4

Set brand colors

Call saveTenantBranding with { primary_color: "#1A2B3C", secondary_color: "#F59E0B" }. These are injected as CSS custom properties and control buttons, highlights, and accent elements across the UI.
5

Set browser metadata

Set titulo_navegador for the <title> tag and descripcion_sitio for the <meta name="description"> tag. Both are used by Next.js generateMetadata at request time.
6

Verify rows are public

When using saveTenantBranding, all rows are automatically written with is_public: true, allowing unauthenticated reads via the tenant_settings_read_anon RLS policy. If you write rows manually via updateTenantSettings, you must set is_public = true explicitly.

Branding Keys Reference

These are the nine keys fetched by getPublicTenantSettings and used by the public layout. The Module column reflects how saveTenantBranding categorises each key internally.
KeyModuleDescriptionExample
nombre_comercialEMPRESADisplay name shown in the UI"Acerías del Caribe"
razon_socialEMPRESALegal name used on documents and invoices"Acerías del Caribe S.A."
logo_urlIDENTIDADPrimary logo for light backgroundsSupabase Storage public URL
logo_secondary_urlIDENTIDADSecondary logo for dark backgroundsSupabase Storage public URL
favicon_urlIDENTIDADBrowser tab faviconSupabase Storage public URL
primary_colorIDENTIDADPrimary brand color#1A2B3C
secondary_colorIDENTIDADAccent / secondary brand color#F59E0B
titulo_navegadorIDENTIDADBrowser <title> tag content"Acerías B2B Portal"
descripcion_sitioIDENTIDADPage <meta name="description"> content"Portal industrial..."

Branding Version History

Every call to saveTenantBranding automatically snapshots the full active branding config into the tenant_branding_version table. You can retrieve the version list with getBrandingHistory(tenantCode) and roll back any version with restoreBrandingVersion(tenantCode, versionId). A rollback itself creates a new version entry describing the restoration, preserving a complete audit trail.

Fallback Behavior

If a tenant has no rows in tenant_settings for branding keys, getBrandingDefaults(tenantCode) returns hardcoded defaults for known tenant codes defined in src/platform/branding/branding-defaults.ts. This ensures the layout renders correctly before a tenant has completed their branding setup. Once real settings are saved, they take precedence over the defaults on every subsequent request.
After updating branding via saveTenantBranding or updateTenantSettings, clear the Next.js data cache by redeploying or by calling revalidateTag('branding-<tenantCode>') if you have instrumented the branding fetcher with unstable_cache. Without cache invalidation, the old branding may continue to be served until the cache entry expires.

Build docs developers (and LLMs) love