diff --git a/src/app/admin/user-verify/page.tsx b/src/app/admin/user-verify/page.tsx index 2f9bc8a..431e02f 100644 --- a/src/app/admin/user-verify/page.tsx +++ b/src/app/admin/user-verify/page.tsx @@ -13,6 +13,8 @@ import { PendingUser } from '../../utils/api' type UserType = 'personal' | 'company' type UserRole = 'user' | 'admin' +type VerificationReadyFilter = 'all' | 'ready' | 'not_ready' +type StatusFilter = 'all' | 'pending' | 'verifying' | 'active' export default function AdminUserVerifyPage() { const { @@ -31,6 +33,8 @@ export default function AdminUserVerifyPage() { const [search, setSearch] = useState('') const [fType, setFType] = useState<'all' | UserType>('all') const [fRole, setFRole] = useState<'all' | UserRole>('all') + const [fReady, setFReady] = useState('all') + const [fStatus, setFStatus] = useState('all') const [perPage, setPerPage] = useState(10) const [page, setPage] = useState(1) @@ -41,10 +45,18 @@ export default function AdminUserVerifyPage() { const lastName = u.last_name || '' const companyName = u.company_name || '' const fullName = u.user_type === 'company' ? companyName : `${firstName} ${lastName}` + const isReadyToVerify = u.email_verified === 1 && u.profile_completed === 1 && + u.documents_uploaded === 1 && u.contract_signed === 1 return ( (fType === 'all' || u.user_type === fType) && (fRole === 'all' || u.role === fRole) && + (fStatus === 'all' || u.status === fStatus) && + ( + fReady === 'all' || + (fReady === 'ready' && isReadyToVerify) || + (fReady === 'not_ready' && !isReadyToVerify) + ) && ( !search.trim() || u.email.toLowerCase().includes(search.toLowerCase()) || @@ -52,7 +64,7 @@ export default function AdminUserVerifyPage() { ) ) }) - }, [pendingUsers, search, fType, fRole]) + }, [pendingUsers, search, fType, fRole, fReady, fStatus]) const totalPages = Math.max(1, Math.ceil(filtered.length / perPage)) const current = filtered.slice((page - 1) * perPage, page * perPage) @@ -175,9 +187,9 @@ export default function AdminUserVerifyPage() {

Search & Filter Pending Users

-
-
- +
+
+
+
+
+ + +
+
+ + +
+
+
-
- -
@@ -355,6 +387,9 @@ export default function AdminUserVerifyPage() { setSelectedUserId(null) }} userId={selectedUserId} + onUserUpdated={() => { + fetchPendingUsers() + }} /> ) diff --git a/src/app/components/UserDetailModal.tsx b/src/app/components/UserDetailModal.tsx index 974a472..4bfe706 100644 --- a/src/app/components/UserDetailModal.tsx +++ b/src/app/components/UserDetailModal.tsx @@ -47,7 +47,6 @@ export default function UserDetailModal({ isOpen, onClose, userId, onUserUpdated const token = useAuthStore(state => state.accessToken) // Contract preview state (lazy-loaded, per contract type) - const [previewLoading, setPreviewLoading] = useState(false) const [activePreviewTab, setActivePreviewTab] = useState<'contract' | 'gdpr'>('contract') const [previewState, setPreviewState] = useState({ contract: { loading: false, html: null as string | null, error: null as string | null }, @@ -88,17 +87,6 @@ export default function UserDetailModal({ isOpen, onClose, userId, onUserUpdated } } - // Load both contract and GDPR previews when modal opens after user is known - useEffect(() => { - if (!isOpen || !userId || !token || !userDetails) return - setPreviewLoading(true) - Promise.all([ - loadContractPreview('contract'), - loadContractPreview('gdpr') - ]).finally(() => setPreviewLoading(false)) - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isOpen, userId, token, userDetails]) - const handleStatusChange = async (newStatus: UserStatus) => { if (!userId || !token || newStatus === selectedStatus) return @@ -439,11 +427,11 @@ export default function UserDetailModal({ isOpen, onClose, userId, onUserUpdated