Skip to content

Commit 78151ad

Browse files
fix ui flash for data retention settings
1 parent a7ea18c commit 78151ad

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

apps/sim/ee/data-retention/components/data-retention-settings.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { createLogger } from '@sim/logger'
55
import { toError } from '@sim/utils/errors'
66
import { Button, Combobox, toast } from '@/components/emcn'
77
import { useSession } from '@/lib/auth/auth-client'
8-
import { getSubscriptionAccessState } from '@/lib/billing/client/utils'
98
import { isBillingEnabled } from '@/lib/core/config/feature-flags'
109
import { getUserRole } from '@/lib/workspaces/organization/utils'
1110
import { SettingRow } from '@/ee/components/setting-row'
@@ -15,7 +14,6 @@ import {
1514
useUpdateOrganizationRetention,
1615
} from '@/ee/data-retention/hooks/data-retention'
1716
import { useOrganizations } from '@/hooks/queries/organization'
18-
import { useSubscriptionData } from '@/hooks/queries/subscription'
1917

2018
const logger = createLogger('DataRetentionSettings')
2119

@@ -71,21 +69,18 @@ function RetentionSelect({ value, onChange }: RetentionSelectProps) {
7169
}
7270

7371
export function DataRetentionSettings() {
74-
const { data: session } = useSession()
75-
const { data: orgsData } = useOrganizations()
76-
const { data: subscriptionData } = useSubscriptionData()
72+
const { data: session, isPending: sessionPending } = useSession()
73+
const { data: orgsData, isLoading: orgsLoading } = useOrganizations()
7774

7875
const activeOrganization = orgsData?.activeOrganization
7976
const orgId = activeOrganization?.id
8077

81-
const { data, isLoading } = useOrganizationRetention(orgId)
78+
const { data, isLoading: retentionLoading } = useOrganizationRetention(orgId)
8279
const updateMutation = useUpdateOrganizationRetention()
8380

8481
const userEmail = session?.user?.email
8582
const userRole = getUserRole(activeOrganization, userEmail)
8683
const canManage = userRole === 'owner' || userRole === 'admin'
87-
const subscriptionAccess = getSubscriptionAccessState(subscriptionData?.data)
88-
const hasEnterprisePlan = subscriptionAccess.hasUsableEnterpriseAccess
8984

9085
const [logDays, setLogDays] = useState('')
9186
const [softDeleteDays, setSoftDeleteDays] = useState('')
@@ -136,6 +131,10 @@ export function DataRetentionSettings() {
136131
}
137132
}
138133

134+
if (sessionPending || orgsLoading || (orgId && retentionLoading)) {
135+
return <DataRetentionSkeleton />
136+
}
137+
139138
if (!orgId) {
140139
return (
141140
<div className='flex h-full items-center justify-center text-[var(--text-muted)] text-sm'>
@@ -144,8 +143,6 @@ export function DataRetentionSettings() {
144143
)
145144
}
146145

147-
if (isLoading) return <DataRetentionSkeleton />
148-
149146
if (!data) {
150147
return (
151148
<div className='flex h-full items-center justify-center text-[var(--text-muted)] text-sm'>
@@ -154,7 +151,7 @@ export function DataRetentionSettings() {
154151
)
155152
}
156153

157-
if (isBillingEnabled && !hasEnterprisePlan) {
154+
if (isBillingEnabled && !data.isEnterprise) {
158155
return (
159156
<div className='flex h-full items-center justify-center text-[var(--text-muted)] text-sm'>
160157
Data retention is available on Enterprise plans only.

0 commit comments

Comments
 (0)