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();
|
const progress = await getProfileCompletion();
|
||||||
// progress can be percent or object
|
// progress can be percent or object
|
||||||
if (progress && typeof progress === '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 ?? []);
|
setCompletedSteps(progress.completedSteps ?? []);
|
||||||
setAllSteps(progress.steps?.map((s: any) => s.name || s.title || '') ?? []);
|
setAllSteps(progress.steps?.map((s: any) => s.name || s.title || '') ?? []);
|
||||||
} else if (typeof progress === 'number') {
|
} else if (typeof progress === 'number') {
|
||||||
@ -125,6 +129,14 @@ export default function ProfilePage() {
|
|||||||
fetchCompletion();
|
fetchCompletion();
|
||||||
}, [user, router, refreshKey]);
|
}, [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
|
// Use API profile data if available, fallback to mock
|
||||||
const profileData = React.useMemo(() => {
|
const profileData = React.useMemo(() => {
|
||||||
if (!profileDataApi) {
|
if (!profileDataApi) {
|
||||||
@ -289,10 +301,15 @@ export default function ProfilePage() {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</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 */}
|
{/* Profile Completion Progress Bar */}
|
||||||
<ProfileCompletion
|
<ProfileCompletion
|
||||||
profileComplete={profileData.profileComplete}
|
profileComplete={profileData.profileComplete}
|
||||||
// You can pass more props if needed
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Basic Info + Sidebar */}
|
{/* Basic Info + Sidebar */}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user