fix
This commit is contained in:
@@ -473,32 +473,12 @@ export default function UserDetailPage() {
|
|||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
{/* Agent Details Grid */}
|
{/* Agent Details Grid */}
|
||||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-6">
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-6">
|
||||||
{/* Agent Type - Editable */}
|
{/* Agent Type - Read Only */}
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm text-[#666666] mb-1">Agent Type</p>
|
<p className="text-sm text-[#666666]">Agent Type</p>
|
||||||
<div className="flex items-center space-x-2">
|
<p className="text-sm font-medium text-[#00293d]">
|
||||||
<select
|
{user.agentProfile.agentType?.name || 'Not assigned'}
|
||||||
value={selectedAgentTypeId}
|
</p>
|
||||||
onChange={(e) => setSelectedAgentTypeId(e.target.value)}
|
|
||||||
className="w-full max-w-[160px] px-2 py-1 text-sm border border-[#e5e7eb] rounded-lg focus:outline-none focus:border-[#f5a623] text-[#00293d] bg-white"
|
|
||||||
>
|
|
||||||
<option value="">Select...</option>
|
|
||||||
{agentTypes.map((type) => (
|
|
||||||
<option key={type.id} value={type.id}>
|
|
||||||
{type.name}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
{selectedAgentTypeId && selectedAgentTypeId !== user.agentProfile?.agentTypeId && (
|
|
||||||
<button
|
|
||||||
onClick={handleUpdateAgentType}
|
|
||||||
disabled={isUpdatingAgentType}
|
|
||||||
className="px-2 py-1 bg-[#f5a623] hover:bg-[#e09620] text-white text-xs font-medium rounded transition-colors disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{isUpdatingAgentType ? '...' : 'Save'}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm text-[#666666]">Slug</p>
|
<p className="text-sm text-[#666666]">Slug</p>
|
||||||
@@ -566,6 +546,43 @@ export default function UserDetailPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Dynamic Profile Data (only for AGENT role) */}
|
||||||
|
{user.role === 'AGENT' && agentFieldValues.length > 0 && (
|
||||||
|
<div className="bg-white rounded-xl shadow-sm border border-[#e5e7eb] mb-6">
|
||||||
|
<div className="px-6 py-4 border-b border-[#e5e7eb]">
|
||||||
|
<h2 className="text-lg font-semibold text-[#00293d] font-fractul">Profile Details</h2>
|
||||||
|
</div>
|
||||||
|
<div className="p-6 space-y-5">
|
||||||
|
{Object.entries(
|
||||||
|
agentFieldValues
|
||||||
|
.filter((fv) => fv.sectionSlug !== 'upload-documents')
|
||||||
|
.reduce((acc, fv) => {
|
||||||
|
if (!acc[fv.sectionName]) acc[fv.sectionName] = [];
|
||||||
|
acc[fv.sectionName].push(fv);
|
||||||
|
return acc;
|
||||||
|
}, {} as Record<string, AgentFieldValue[]>)
|
||||||
|
).map(([sectionName, fields]) => (
|
||||||
|
<div key={sectionName}>
|
||||||
|
<h3 className="text-xs font-semibold text-[#00293d] uppercase tracking-wide mb-3 pb-2 border-b border-[#e5e7eb]">{sectionName}</h3>
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{fields.map((fv) => (
|
||||||
|
<div key={fv.fieldSlug}>
|
||||||
|
<p className="text-xs text-[#666666] mb-0.5">{fv.fieldName}</p>
|
||||||
|
<p className="text-sm font-medium text-[#00293d]">
|
||||||
|
{fv.value === null || fv.value === undefined ? <span className="text-gray-400">-</span> :
|
||||||
|
Array.isArray(fv.value) ? fv.value.map((v: any) => typeof v === 'object' ? (v.label || v.name || JSON.stringify(v)) : String(v)).join(', ') :
|
||||||
|
typeof fv.value === 'object' ? JSON.stringify(fv.value) :
|
||||||
|
String(fv.value)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Verification Section (only for AGENT role) */}
|
{/* Verification Section (only for AGENT role) */}
|
||||||
{user.role === 'AGENT' && user.agentProfile && (
|
{user.role === 'AGENT' && user.agentProfile && (
|
||||||
<div className="bg-white rounded-xl shadow-sm border border-[#e5e7eb] mb-6">
|
<div className="bg-white rounded-xl shadow-sm border border-[#e5e7eb] mb-6">
|
||||||
@@ -592,41 +609,6 @@ export default function UserDetailPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Agent Profile Data */}
|
|
||||||
{agentFieldValues.length > 0 && (
|
|
||||||
<div className="mb-6">
|
|
||||||
<h3 className="text-sm font-medium text-[#00293d] mb-3">Profile Data</h3>
|
|
||||||
<div className="space-y-4">
|
|
||||||
{Object.entries(
|
|
||||||
agentFieldValues
|
|
||||||
.filter((fv) => fv.sectionSlug !== 'upload-documents')
|
|
||||||
.reduce((acc, fv) => {
|
|
||||||
if (!acc[fv.sectionName]) acc[fv.sectionName] = [];
|
|
||||||
acc[fv.sectionName].push(fv);
|
|
||||||
return acc;
|
|
||||||
}, {} as Record<string, AgentFieldValue[]>)
|
|
||||||
).map(([sectionName, fields]) => (
|
|
||||||
<div key={sectionName} className="p-3 bg-gray-50 rounded-lg">
|
|
||||||
<h4 className="text-xs font-semibold text-[#00293d] uppercase tracking-wide mb-2">{sectionName}</h4>
|
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
|
||||||
{fields.map((fv) => (
|
|
||||||
<div key={fv.fieldSlug} className="text-sm">
|
|
||||||
<span className="text-gray-500">{fv.fieldName}: </span>
|
|
||||||
<span className="text-gray-900 font-medium">
|
|
||||||
{fv.value === null || fv.value === undefined ? '-' :
|
|
||||||
Array.isArray(fv.value) ? fv.value.map((v: any) => typeof v === 'object' ? (v.label || v.name || JSON.stringify(v)) : String(v)).join(', ') :
|
|
||||||
typeof fv.value === 'object' ? JSON.stringify(fv.value) :
|
|
||||||
String(fv.value)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Uploaded Documents */}
|
{/* Uploaded Documents */}
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<h3 className="text-sm font-medium text-[#00293d] mb-3">Uploaded Documents</h3>
|
<h3 className="text-sm font-medium text-[#00293d] mb-3">Uploaded Documents</h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user