fix: enable profile auto-save for all verification statuses including approved

This commit is contained in:
pradeepkumar
2026-06-12 07:42:14 +05:30
parent dca0d54e2e
commit 8f0becb53a

View File

@@ -48,9 +48,7 @@ export default function EditProfilePage() {
const repeatableDataRef = useRef<Record<string, RepeatableEntryData[]>>({});
// Dirty (unsaved) field slugs; repeatable sections tracked as `${slug}_entries`
const dirtySlugsRef = useRef<Set<string>>(new Set());
// Server auto-save stays off for APPROVED profiles — their field values are
// live, so changes only go out via the explicit Save button. Local drafts
// still work for everyone.
// Set once the profile loads; guards flushes from firing before then
const autoSaveEnabledRef = useRef(false);
const draftKeyRef = useRef<string | null>(null);
const autoSaveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -233,12 +231,9 @@ export default function EditProfilePage() {
return;
}
// APPROVED profiles are live — keep their changes behind the explicit
// Save button. Everyone else gets server auto-save while they build.
autoSaveEnabledRef.current =
!profile.verificationStatus ||
profile.verificationStatus === 'NONE' ||
profile.verificationStatus === 'REJECTED';
// Auto-save for all statuses. Note: APPROVED profiles are live, so
// auto-saved edits update the public profile immediately.
autoSaveEnabledRef.current = true;
draftKeyRef.current = `agent-profile-draft:${profile.userId}`;
if (!profile.agentTypeId) {
@@ -656,9 +651,7 @@ export default function EditProfilePage() {
{autoSaveStatus === 'saved' && lastSavedAt && `All changes saved at ${formatTime(lastSavedAt)}`}
{autoSaveStatus === 'error' && 'Auto-save failed — retrying'}
{autoSaveStatus === 'dirty' &&
(autoSaveEnabledRef.current
? 'Unsaved changes'
: 'Unsaved changes — remember to save')}
(lastSavedAt ? `Last saved at ${formatTime(lastSavedAt)}` : 'Unsaved changes')}
{autoSaveStatus === 'idle' && lastSavedAt && `Last saved at ${formatTime(lastSavedAt)}`}
</span>
</div>
@@ -675,9 +668,7 @@ export default function EditProfilePage() {
hour: 'numeric',
minute: '2-digit',
})}
{autoSaveEnabledRef.current
? '. Keep editing — your progress is saved automatically.'
: '. Review them and press Save Changes to keep them.'}
. Keep editing your progress is saved automatically.
</p>
<button
onClick={() => setDraftRestoredAt(null)}