feat: Enable agents to set a custom headline and manage location via distinct city, state, and country fields, and enhance contract count display logic.

This commit is contained in:
pradeepkumar
2026-03-18 13:04:10 +05:30
parent 772e1024cc
commit fcfb3827ba
3 changed files with 42 additions and 22 deletions

View File

@@ -78,10 +78,10 @@ export function ProfileSettingsForm({
const profileData = {
firstName: profile.firstName || '',
lastName: profile.lastName || '',
career: profile.agentType?.name || 'Real Estate Agent',
career: profile.headline || profile.agentType?.name || 'Real Estate Agent',
email: profile.email || session?.user?.email || '',
phone: profile.phone || '',
location: profile.serviceAreas?.[0] || '',
location: [profile.city, profile.state, profile.country].filter(Boolean).join(', '),
};
setFormData(profileData);
setOriginalData(profileData); // Store original for cancel
@@ -287,16 +287,20 @@ export function ProfileSettingsForm({
const role = (session?.user as any)?.role;
// Update profile based on role (email is not editable - tied to auth)
// Parse location into city, state, country
const locationParts = formData.location.split(',').map(s => s.trim());
if (role === 'AGENT') {
await agentsService.updateProfile({
firstName: formData.firstName,
lastName: formData.lastName,
phone: formData.phone,
serviceAreas: formData.location ? [formData.location] : [],
headline: formData.career,
city: locationParts[0] || '',
state: locationParts[1] || '',
country: locationParts[2] || '',
});
} else {
// Parse location into city, state, country for users
const locationParts = formData.location.split(',').map(s => s.trim());
await usersService.updateProfile({
firstName: formData.firstName,
lastName: formData.lastName,
@@ -307,15 +311,15 @@ export function ProfileSettingsForm({
});
}
// Update session with new name
const fullName = `${formData.firstName} ${formData.lastName}`.trim();
await updateSession({
...session,
user: {
...session?.user,
name: fullName,
},
});
// Update session name without causing a page refresh
try {
const fullName = `${formData.firstName} ${formData.lastName}`.trim();
await updateSession({
user: { name: fullName },
});
} catch {
// Session update can fail silently - profile is already saved
}
// Dispatch event to notify header and other components to refresh profile data
window.dispatchEvent(new Event('profile-updated'));