[PULSE-58] Data retention settings in Site Settings #33
@@ -101,11 +101,23 @@ export default function SiteSettingsPage() {
|
|||||||
try {
|
try {
|
||||||
const sub = await getSubscription()
|
const sub = await getSubscription()
|
||||||
setSubscription(sub)
|
setSubscription(sub)
|
||||||
} catch {
|
} catch (e) {
|
||||||
// * Non-critical; free tier assumed if billing unavailable
|
toast.error(getAuthErrorMessage(e as Error) || 'Could not load plan limits. Showing default options.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// * Clamp data_retention_months when subscription loads: if current value exceeds plan max, sync to max
|
||||||
|
useEffect(() => {
|
||||||
|
if (!subscription) return
|
||||||
|
const opts = getRetentionOptionsForPlan(subscription.plan_id)
|
||||||
|
const values = opts.map(o => o.value)
|
||||||
|
const maxVal = Math.max(...values)
|
||||||
|
setFormData(prev => {
|
||||||
|
if (values.includes(prev.data_retention_months)) return prev
|
||||||
|
return { ...prev, data_retention_months: Math.min(prev.data_retention_months, maxVal) }
|
||||||
|
})
|
||||||
|
}, [subscription])
|
||||||
|
|
||||||
const loadSite = async () => {
|
const loadSite = async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user