fix
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
import { agentsService, AgentProfile, FieldValueResponse } from '@/services/agents.service';
|
||||
import { connectionRequestsService } from '@/services/connection-requests.service';
|
||||
import { uploadService } from '@/services/upload.service';
|
||||
import { usersService } from '@/services/users.service';
|
||||
import { testimonialsService, Testimonial } from '@/services/testimonials.service';
|
||||
import { mapFieldValuesToExperience, mapFieldValuesToProfileCard, mapFieldValuesToAvailability, mapFieldValuesToSpecializationFields, mapFieldValuesToContactInfo, ExperienceData, ProfileCardData, AvailabilityData, SpecializationFieldsData, ContactInfoData } from '@/utils/profileDataMapper';
|
||||
|
||||
@@ -81,6 +82,7 @@ export default function AgentDashboard() {
|
||||
const [isTogglingAvailability, setIsTogglingAvailability] = useState(false);
|
||||
const [pendingRequestCount, setPendingRequestCount] = useState(0);
|
||||
const [testimonials, setTestimonials] = useState<{ id: string; text: string; author: string; role: string; rating: number }[]>([]);
|
||||
const [isSubmittingVerification, setIsSubmittingVerification] = useState(false);
|
||||
|
||||
const defaultImage = '/assets/demo_images/8f017153a7b4a239a4f0691234ef97dd55092282.jpg';
|
||||
|
||||
@@ -287,6 +289,32 @@ export default function AgentDashboard() {
|
||||
}
|
||||
};
|
||||
|
||||
// Check if agent has uploaded documents
|
||||
const hasDocuments = fieldValues.some(
|
||||
(fv) => fv.sectionSlug === 'upload-documents' && fv.value && (Array.isArray(fv.value) ? fv.value.length > 0 : true)
|
||||
);
|
||||
|
||||
const handleSubmitVerification = async () => {
|
||||
setIsSubmittingVerification(true);
|
||||
try {
|
||||
await usersService.submitForVerification();
|
||||
// Update local state
|
||||
if (agentProfile) {
|
||||
setAgentProfile({ ...agentProfile, verificationStatus: 'PENDING_REVIEW', verificationNote: null } as AgentProfile);
|
||||
}
|
||||
} catch (err: any) {
|
||||
const data = err?.response?.data;
|
||||
if (data?.missingFields && Array.isArray(data.missingFields)) {
|
||||
const fieldList = data.missingFields.map((f: any) => `• ${f.sectionName} → ${f.fieldName}`).join('\n');
|
||||
alert(`Please fill in all required fields:\n\n${fieldList}`);
|
||||
} else {
|
||||
alert(data?.message || 'Failed to submit for verification');
|
||||
}
|
||||
} finally {
|
||||
setIsSubmittingVerification(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Verification Status Banner */}
|
||||
@@ -300,9 +328,18 @@ export default function AgentDashboard() {
|
||||
<p className="font-serif text-[13px] text-red-700 mt-1">Reason: {agentProfile.verificationNote}</p>
|
||||
)}
|
||||
<p className="font-serif text-[13px] text-red-600 mt-2">Please update your profile and documents, then resubmit for verification.</p>
|
||||
<Link href="/agent/edit" className="inline-block mt-2 px-4 py-1.5 bg-[#e58625] text-white rounded-[10px] font-serif text-[13px] hover:bg-[#d47920] transition-colors">
|
||||
Update & Resubmit
|
||||
<div className="flex gap-2 mt-2">
|
||||
<Link href="/agent/edit" className="inline-block px-4 py-1.5 border border-[#e58625] text-[#e58625] rounded-[10px] font-serif text-[13px] hover:bg-[#e58625]/5 transition-colors">
|
||||
Edit Profile
|
||||
</Link>
|
||||
<button
|
||||
onClick={handleSubmitVerification}
|
||||
disabled={isSubmittingVerification}
|
||||
className="px-4 py-1.5 bg-[#e58625] text-white rounded-[10px] font-serif text-[13px] hover:bg-[#d47920] transition-colors disabled:opacity-50"
|
||||
>
|
||||
{isSubmittingVerification ? 'Submitting...' : 'Submit for Review'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -321,9 +358,18 @@ export default function AgentDashboard() {
|
||||
<Image src="/assets/icons/caution-icon.svg" alt="Info" width={20} height={20} className="flex-shrink-0" />
|
||||
<div className="flex-1">
|
||||
<p className="font-fractul font-bold text-[14px] text-blue-800">Complete your profile and upload verification documents to get verified.</p>
|
||||
<Link href="/agent/edit" className="inline-block mt-2 px-4 py-1.5 bg-[#e58625] text-white rounded-[10px] font-serif text-[13px] hover:bg-[#d47920] transition-colors">
|
||||
<div className="flex gap-2 mt-2">
|
||||
<Link href="/agent/edit" className="inline-block px-4 py-1.5 border border-[#e58625] text-[#e58625] rounded-[10px] font-serif text-[13px] hover:bg-[#e58625]/5 transition-colors">
|
||||
Complete Profile
|
||||
</Link>
|
||||
<button
|
||||
onClick={handleSubmitVerification}
|
||||
disabled={isSubmittingVerification}
|
||||
className="px-4 py-1.5 bg-[#e58625] text-white rounded-[10px] font-serif text-[13px] hover:bg-[#d47920] transition-colors disabled:opacity-50"
|
||||
>
|
||||
{isSubmittingVerification ? 'Submitting...' : 'Submit for Review'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -47,4 +47,12 @@ export const usersService = {
|
||||
const response = await api.patch<ApiResponse<UserProfile>>('/users/profile/me', data);
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Submit or resubmit profile for verification (agent only)
|
||||
*/
|
||||
async submitForVerification(): Promise<{ message: string; status: string }> {
|
||||
const response = await api.post<ApiResponse<{ message: string; status: string }>>('/users/me/verification/submit');
|
||||
return response.data.data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user