fix: remove card wrapping from bare inputs + fix privacy false-dirty on load
This commit is contained in:
@@ -69,8 +69,8 @@ export default function AccountProfileTab({ onDirtyChange, onRegisterSave }: { o
|
||||
</div>
|
||||
|
||||
{/* Display Name */}
|
||||
<div className="space-y-3">
|
||||
<div className="p-4 rounded-xl border border-neutral-800 bg-neutral-800/30">
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-neutral-300 mb-1.5">Display Name</label>
|
||||
<Input
|
||||
value={displayName}
|
||||
@@ -79,8 +79,7 @@ export default function AccountProfileTab({ onDirtyChange, onRegisterSave }: { o
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Email — read-only display */}
|
||||
<div className="p-4 rounded-xl border border-neutral-800 bg-neutral-800/30">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-neutral-300 mb-1.5">Email Address</label>
|
||||
<Input value={user.email} disabled className="opacity-60" />
|
||||
<p className="text-xs text-neutral-500 mt-1">Email changes require password verification. Use <a href="https://auth.ciphera.net/settings" target="_blank" rel="noopener noreferrer" className="text-brand-orange hover:underline">Ciphera Auth</a> to change your email.</p>
|
||||
|
||||
@@ -104,20 +104,20 @@ export default function SiteGeneralTab({ siteId, onDirtyChange, onRegisterSave }
|
||||
<p className="text-sm text-neutral-400">Update your site details and tracking script.</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="p-4 rounded-xl border border-neutral-800 bg-neutral-800/30">
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-neutral-300 mb-1.5">Site Name</label>
|
||||
<Input value={name} onChange={e => setName(e.target.value)} placeholder="My Website" />
|
||||
</div>
|
||||
<div className="p-4 rounded-xl border border-neutral-800 bg-neutral-800/30">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-neutral-300 mb-1.5">Domain</label>
|
||||
<Input value={site.domain} disabled className="opacity-60" />
|
||||
<p className="text-xs text-neutral-500 mt-1">Cannot be changed.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-4 rounded-xl border border-neutral-800 bg-neutral-800/30">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-neutral-300 mb-1.5">Timezone</label>
|
||||
<Select
|
||||
value={timezone}
|
||||
|
||||
@@ -44,7 +44,7 @@ export default function SitePrivacyTab({ siteId, onDirtyChange, onRegisterSave }
|
||||
const [snippetCopied, setSnippetCopied] = useState(false)
|
||||
const initialRef = useRef('')
|
||||
|
||||
// Sync form state from site data — only on first load, not on SWR revalidation
|
||||
// Sync form state — only on first load, skip dirty tracking until ready
|
||||
const hasInitialized = useRef(false)
|
||||
useEffect(() => {
|
||||
if (!site || hasInitialized.current) return
|
||||
@@ -56,34 +56,35 @@ export default function SitePrivacyTab({ siteId, onDirtyChange, onRegisterSave }
|
||||
setHideUnknownLocations(site.hide_unknown_locations ?? false)
|
||||
setDataRetention(site.data_retention_months ?? 6)
|
||||
setExcludedPaths((site.excluded_paths || []).join('\n'))
|
||||
initialRef.current = JSON.stringify({
|
||||
collectPagePaths: site.collect_page_paths ?? true,
|
||||
collectReferrers: site.collect_referrers ?? true,
|
||||
collectDeviceInfo: site.collect_device_info ?? true,
|
||||
collectScreenRes: site.collect_screen_resolution ?? true,
|
||||
collectGeoData: site.collect_geo_data ?? 'full',
|
||||
hideUnknownLocations: site.hide_unknown_locations ?? false,
|
||||
dataRetention: site.data_retention_months ?? 6,
|
||||
excludedPaths: (site.excluded_paths || []).join('\n'),
|
||||
psiFrequency: 'weekly',
|
||||
})
|
||||
hasInitialized.current = true
|
||||
}, [site])
|
||||
|
||||
// Sync PSI frequency separately (comes from a different SWR hook)
|
||||
// Sync PSI frequency separately — update both state AND snapshot when it first loads
|
||||
const psiInitialized = useRef(false)
|
||||
useEffect(() => {
|
||||
if (!psiConfig || psiInitialized.current) return
|
||||
setPsiFrequency(psiConfig.frequency || 'weekly')
|
||||
const freq = psiConfig.frequency || 'weekly'
|
||||
setPsiFrequency(freq)
|
||||
// Update the snapshot to include the real PSI frequency so it doesn't show as dirty
|
||||
if (initialRef.current) {
|
||||
const snap = JSON.parse(initialRef.current)
|
||||
snap.psiFrequency = freq
|
||||
initialRef.current = JSON.stringify(snap)
|
||||
}
|
||||
psiInitialized.current = true
|
||||
}, [psiConfig])
|
||||
|
||||
// Build initial snapshot once both site + psi are loaded
|
||||
useEffect(() => {
|
||||
if (!hasInitialized.current || !initialRef.current && site) {
|
||||
initialRef.current = JSON.stringify({
|
||||
collectPagePaths: site?.collect_page_paths ?? true,
|
||||
collectReferrers: site?.collect_referrers ?? true,
|
||||
collectDeviceInfo: site?.collect_device_info ?? true,
|
||||
collectScreenRes: site?.collect_screen_resolution ?? true,
|
||||
collectGeoData: site?.collect_geo_data ?? 'full',
|
||||
hideUnknownLocations: site?.hide_unknown_locations ?? false,
|
||||
dataRetention: site?.data_retention_months ?? 6,
|
||||
excludedPaths: (site?.excluded_paths || []).join('\n'),
|
||||
psiFrequency: psiConfig?.frequency || 'weekly',
|
||||
})
|
||||
}
|
||||
}, [site, psiConfig])
|
||||
|
||||
// Track dirty state
|
||||
useEffect(() => {
|
||||
if (!initialRef.current) return
|
||||
|
||||
@@ -91,12 +91,12 @@ export default function WorkspaceGeneralTab({ onDirtyChange, onRegisterSave }: {
|
||||
<p className="text-sm text-neutral-400">Basic details about your organization.</p>
|
||||
</div>
|
||||
|
||||
<div className="p-4 rounded-xl border border-neutral-800 bg-neutral-800/30">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-neutral-300 mb-1.5">Organization Name</label>
|
||||
<Input value={name} onChange={e => setName(e.target.value)} placeholder="Acme Corp" />
|
||||
</div>
|
||||
|
||||
<div className="p-4 rounded-xl border border-neutral-800 bg-neutral-800/30">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-neutral-300 mb-1.5">Organization Slug</label>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-sm text-neutral-500">pulse.ciphera.net/</span>
|
||||
|
||||
Reference in New Issue
Block a user