feat: implement URL-based listing type selection and update footer navigation links
This commit is contained in:
@@ -409,6 +409,7 @@ function ProfilesPageContent() {
|
||||
const nameFromUrl = searchParams.get('name') || '';
|
||||
const locationFromUrl = searchParams.get('location') || '';
|
||||
const filtersFromUrl = searchParams.get('filters') || '';
|
||||
const listingFromUrl = searchParams.get('listing') as 'agents' | 'lenders' | null;
|
||||
|
||||
// State for API data
|
||||
const [agents, setAgents] = useState<PublicAgentProfile[]>([]);
|
||||
@@ -424,7 +425,7 @@ function ProfilesPageContent() {
|
||||
// State for search and filters - initialize from URL params
|
||||
const [searchQuery, setSearchQuery] = useState(nameFromUrl);
|
||||
const [activeTypeId, setActiveTypeId] = useState<string | null>(typeFromUrl);
|
||||
const [listingType, setListingType] = useState<'agents' | 'lenders'>('agents');
|
||||
const [listingType, setListingType] = useState<'agents' | 'lenders'>(listingFromUrl || 'agents');
|
||||
const [isFilterModalOpen, setIsFilterModalOpen] = useState(false);
|
||||
const [filters, setFilters] = useState<FilterState>(() => {
|
||||
if (filtersFromUrl) {
|
||||
@@ -460,6 +461,15 @@ function ProfilesPageContent() {
|
||||
]);
|
||||
setAgentTypes(types);
|
||||
|
||||
// If listing param is set, auto-select the matching agent type
|
||||
if (listingFromUrl && !typeFromUrl) {
|
||||
const typeName = listingFromUrl === 'lenders' ? 'Lender' : 'Professional';
|
||||
const matchedType = types.find((t: AgentType) => t.name === typeName);
|
||||
if (matchedType) {
|
||||
setActiveTypeId(matchedType.id);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert FilterableField to FilterField format
|
||||
const filterFieldsData: FilterField[] = fields.map((f: FilterableField) => ({
|
||||
slug: f.slug,
|
||||
|
||||
Reference in New Issue
Block a user