refactor: adjust profile completion logic based on admin verification status
This commit is contained in:
parent
09673fd8a9
commit
05f1773d87
@ -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() {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Pending admin verification notice (above progress) */}
|
||||
{profileDataApi?.userStatus && profileDataApi.userStatus.is_admin_verified === 0 && (
|
||||
<div className="rounded-md bg-yellow-50 border border-yellow-200 p-3 text-sm text-yellow-800 mb-2">
|
||||
Your account is fully submitted. Our team will verify your account shortly.
|
||||
</div>
|
||||
)}
|
||||
{/* Profile Completion Progress Bar */}
|
||||
<ProfileCompletion
|
||||
profileComplete={profileData.profileComplete}
|
||||
// You can pass more props if needed
|
||||
/>
|
||||
|
||||
{/* Basic Info + Sidebar */}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user