feat: refine data retention adjustment logic in SiteSettingsPage to snap to nearest valid option upon subscription load
This commit is contained in:
@@ -109,7 +109,7 @@ export default function SiteSettingsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// * Clamp data_retention_months when subscription loads: if current value exceeds plan max, sync to max
|
// * Snap data_retention_months to nearest valid option when subscription loads
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!subscription) return
|
if (!subscription) return
|
||||||
const opts = getRetentionOptionsForPlan(subscription.plan_id)
|
const opts = getRetentionOptionsForPlan(subscription.plan_id)
|
||||||
@@ -117,7 +117,8 @@ export default function SiteSettingsPage() {
|
|||||||
const maxVal = Math.max(...values)
|
const maxVal = Math.max(...values)
|
||||||
setFormData(prev => {
|
setFormData(prev => {
|
||||||
if (values.includes(prev.data_retention_months)) return prev
|
if (values.includes(prev.data_retention_months)) return prev
|
||||||
return { ...prev, data_retention_months: Math.min(prev.data_retention_months, maxVal) }
|
const bestFit = values.filter(v => v <= prev.data_retention_months).pop() ?? maxVal
|
||||||
|
return { ...prev, data_retention_months: Math.min(bestFit, maxVal) }
|
||||||
})
|
})
|
||||||
}, [subscription])
|
}, [subscription])
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export function generatePrivacySnippet(site: Site): string {
|
|||||||
const screen = site.collect_screen_resolution ?? true
|
const screen = site.collect_screen_resolution ?? true
|
||||||
const perf = site.enable_performance_insights ?? false
|
const perf = site.enable_performance_insights ?? false
|
||||||
const filterBots = site.filter_bots ?? true
|
const filterBots = site.filter_bots ?? true
|
||||||
const retentionMonths = site.data_retention_months ?? 12
|
const retentionMonths = site.data_retention_months ?? 6
|
||||||
|
|
||||||
const parts: string[] = []
|
const parts: string[] = []
|
||||||
if (paths) parts.push('which pages are viewed')
|
if (paths) parts.push('which pages are viewed')
|
||||||
|
|||||||
Reference in New Issue
Block a user