fix: remove card wrapping from bare inputs + fix privacy false-dirty on load

This commit is contained in:
Usman Baig
2026-03-25 22:49:25 +01:00
parent 095b68d769
commit d819b4bd17
4 changed files with 31 additions and 31 deletions

View File

@@ -69,8 +69,8 @@ export default function AccountProfileTab({ onDirtyChange, onRegisterSave }: { o
</div> </div>
{/* Display Name */} {/* Display Name */}
<div className="space-y-3"> <div className="space-y-4">
<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">Display Name</label> <label className="block text-sm font-medium text-neutral-300 mb-1.5">Display Name</label>
<Input <Input
value={displayName} value={displayName}
@@ -79,8 +79,7 @@ export default function AccountProfileTab({ onDirtyChange, onRegisterSave }: { o
/> />
</div> </div>
{/* Email — read-only display */} <div>
<div className="p-4 rounded-xl border border-neutral-800 bg-neutral-800/30">
<label className="block text-sm font-medium text-neutral-300 mb-1.5">Email Address</label> <label className="block text-sm font-medium text-neutral-300 mb-1.5">Email Address</label>
<Input value={user.email} disabled className="opacity-60" /> <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> <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>

View File

@@ -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> <p className="text-sm text-neutral-400">Update your site details and tracking script.</p>
</div> </div>
<div className="space-y-3"> <div className="space-y-4">
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-2 gap-4">
<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">Site Name</label> <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" /> <Input value={name} onChange={e => setName(e.target.value)} placeholder="My Website" />
</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">Domain</label> <label className="block text-sm font-medium text-neutral-300 mb-1.5">Domain</label>
<Input value={site.domain} disabled className="opacity-60" /> <Input value={site.domain} disabled className="opacity-60" />
<p className="text-xs text-neutral-500 mt-1">Cannot be changed.</p> <p className="text-xs text-neutral-500 mt-1">Cannot be changed.</p>
</div> </div>
</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> <label className="block text-sm font-medium text-neutral-300 mb-1.5">Timezone</label>
<Select <Select
value={timezone} value={timezone}

View File

@@ -44,7 +44,7 @@ export default function SitePrivacyTab({ siteId, onDirtyChange, onRegisterSave }
const [snippetCopied, setSnippetCopied] = useState(false) const [snippetCopied, setSnippetCopied] = useState(false)
const initialRef = useRef('') 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) const hasInitialized = useRef(false)
useEffect(() => { useEffect(() => {
if (!site || hasInitialized.current) return if (!site || hasInitialized.current) return
@@ -56,34 +56,35 @@ export default function SitePrivacyTab({ siteId, onDirtyChange, onRegisterSave }
setHideUnknownLocations(site.hide_unknown_locations ?? false) setHideUnknownLocations(site.hide_unknown_locations ?? false)
setDataRetention(site.data_retention_months ?? 6) setDataRetention(site.data_retention_months ?? 6)
setExcludedPaths((site.excluded_paths || []).join('\n')) 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 hasInitialized.current = true
}, [site]) }, [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) const psiInitialized = useRef(false)
useEffect(() => { useEffect(() => {
if (!psiConfig || psiInitialized.current) return 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 psiInitialized.current = true
}, [psiConfig]) }, [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 // Track dirty state
useEffect(() => { useEffect(() => {
if (!initialRef.current) return if (!initialRef.current) return

View File

@@ -91,12 +91,12 @@ export default function WorkspaceGeneralTab({ onDirtyChange, onRegisterSave }: {
<p className="text-sm text-neutral-400">Basic details about your organization.</p> <p className="text-sm text-neutral-400">Basic details about your organization.</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">Organization Name</label> <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" /> <Input value={name} onChange={e => setName(e.target.value)} placeholder="Acme Corp" />
</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">Organization Slug</label> <label className="block text-sm font-medium text-neutral-300 mb-1.5">Organization Slug</label>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span className="text-sm text-neutral-500">pulse.ciphera.net/</span> <span className="text-sm text-neutral-500">pulse.ciphera.net/</span>