@@ -7,10 +7,8 @@ import { createLogger } from '@sim/logger'
77import { getErrorMessage , toError } from '@sim/utils/errors'
88import Image from 'next/image'
99import { saveDiscardActions } from '@/components/settings/save-discard-actions'
10- import { isEnterprise } from '@/lib/billing/plan-helpers'
1110import { HEX_COLOR_REGEX } from '@/lib/branding'
1211import type { OrganizationWhitelabelSettings } from '@/lib/branding/types'
13- import { useDeploymentShape } from '@/lib/core/config/deployment-shape'
1412import { DropZone } from '@/app/workspace/[workspaceId]/components/drop-zone'
1513import { SettingsEmptyState } from '@/app/workspace/[workspaceId]/settings/components/settings-empty-state'
1614import { SettingsPanel } from '@/app/workspace/[workspaceId]/settings/components/settings-panel'
@@ -23,7 +21,6 @@ import {
2321 useWhitelabelSettings ,
2422 type WhitelabelSettingsPayload ,
2523} from '@/ee/whitelabeling/hooks/whitelabel'
26- import { useOrganizationBilling } from '@/hooks/queries/organization'
2724import { useWorkspacesQuery } from '@/hooks/queries/workspace'
2825
2926const logger = createLogger ( 'WhitelabelingSettings' )
@@ -407,18 +404,13 @@ function WhitelabelingForm({ initialSettings, orgId, uploadWorkspaceId }: Whitel
407404 )
408405}
409406
407+ /** Gates on the entitlement returned by the whitelabel read — the same check saving enforces. */
410408export function WhitelabelingSettings ( { organizationId : orgId } : WhitelabelingSettingsProps ) {
411- const { billingEnabled } = useDeploymentShape ( )
412- const {
413- data : organizationBillingData ,
414- isPending : organizationBillingLoading ,
415- error : organizationBillingError ,
416- } = useOrganizationBilling ( orgId , { enabled : billingEnabled } )
417409 const { data : workspaces } = useWorkspacesQuery ( true )
418410 const uploadWorkspaceId = workspaces ?. find ( ( workspace ) => workspace . organizationId === orgId ) ?. id
419- const { data : savedSettings , error : settingsError , isLoading } = useWhitelabelSettings ( orgId )
411+ const { data : whitelabel , error : settingsError , isLoading } = useWhitelabelSettings ( orgId )
420412
421- if ( isLoading || ( billingEnabled && organizationBillingLoading ) ) {
413+ if ( isLoading ) {
422414 return (
423415 < SettingsPanel
424416 actions = { saveDiscardActions ( {
@@ -432,32 +424,24 @@ export function WhitelabelingSettings({ organizationId: orgId }: WhitelabelingSe
432424 )
433425 }
434426
435- if ( ! savedSettings ) {
427+ if ( ! whitelabel ) {
436428 return (
437429 < SettingsEmptyState tone = 'error' >
438430 { getErrorMessage ( settingsError , 'Failed to load whitelabeling settings' ) }
439431 </ SettingsEmptyState >
440432 )
441433 }
442434
443- if ( billingEnabled && organizationBillingData === undefined && organizationBillingError ) {
435+ if ( ! whitelabel . isEnterprise ) {
444436 return (
445- < SettingsEmptyState tone = 'error' >
446- { getErrorMessage ( organizationBillingError , 'Failed to load organization billing' ) }
447- </ SettingsEmptyState >
448- )
449- }
450-
451- if ( billingEnabled && ! isEnterprise ( organizationBillingData ?. data ?. subscriptionPlan ) ) {
452- return (
453- < SettingsEmptyState > Whitelabeling is available on Enterprise plans only.</ SettingsEmptyState >
437+ < SettingsEmptyState > Whitelabeling requires an active Enterprise plan.</ SettingsEmptyState >
454438 )
455439 }
456440
457441 return (
458442 < WhitelabelingForm
459443 key = { orgId }
460- initialSettings = { savedSettings }
444+ initialSettings = { whitelabel . settings }
461445 orgId = { orgId }
462446 uploadWorkspaceId = { uploadWorkspaceId }
463447 />
0 commit comments