From 05f1773d87c2f8dba7ce94f3639aa3dbe6271be6 Mon Sep 17 00:00:00 2001 From: seaznCode Date: Sun, 30 Nov 2025 19:48:31 +0100 Subject: [PATCH] refactor: adjust profile completion logic based on admin verification status --- src/app/profile/page.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/app/profile/page.tsx b/src/app/profile/page.tsx index 13f7319..93226d8 100644 --- a/src/app/profile/page.tsx +++ b/src/app/profile/page.tsx @@ -114,7 +114,11 @@ export default function ProfilePage() { const progress = await getProfileCompletion(); // progress can be percent or object if (progress && typeof progress === 'object') { - setProgressPercent(progress.progressPercent ?? 0); + // If not admin-verified, cap progress below 100 to reflect pending verification + const pct = progress.progressPercent ?? 0; + // Try to read admin verification from profileDataApi if available; otherwise assume false until data loads + const isAdminVerified = Boolean(profileDataApi?.userStatus?.is_admin_verified); + setProgressPercent(isAdminVerified ? pct : Math.min(pct, 95)); setCompletedSteps(progress.completedSteps ?? []); setAllSteps(progress.steps?.map((s: any) => s.name || s.title || '') ?? []); } else if (typeof progress === 'number') { @@ -125,6 +129,14 @@ export default function ProfilePage() { fetchCompletion(); }, [user, router, refreshKey]); + // If admin verification flips to true, ensure progress shows 100% + useEffect(() => { + const verified = Boolean(profileDataApi?.userStatus?.is_admin_verified); + if (verified) { + setProgressPercent(prev => (prev < 100 ? 100 : prev)); + } + }, [profileDataApi?.userStatus?.is_admin_verified]); + // Use API profile data if available, fallback to mock const profileData = React.useMemo(() => { if (!profileDataApi) { @@ -289,10 +301,15 @@ export default function ProfilePage() {

+ {/* Pending admin verification notice (above progress) */} + {profileDataApi?.userStatus && profileDataApi.userStatus.is_admin_verified === 0 && ( +
+ Your account is fully submitted. Our team will verify your account shortly. +
+ )} {/* Profile Completion Progress Bar */} {/* Basic Info + Sidebar */}