From 7ea96a97b3d97fe028bc2e4a291046946ab77dbe Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Thu, 15 Jan 2026 10:49:40 +0700 Subject: [PATCH] Refactor catalog layout: replace Teleport with provide/inject - Create useCatalogLayout composable for data transfer from pages to layout - Layout now owns SearchBar and CatalogMap components directly - Pages provide data via provideCatalogLayout() - Fixes navigation glitches (multiple SearchBars) when switching tabs - Support custom subNavItems for clientarea pages - Unify 6 pages to use catalog layout: - catalog/offers, suppliers, hubs - clientarea/orders, addresses, offers --- app/composables/useCatalogLayout.ts | 71 ++++++ app/layouts/catalog.vue | 94 +++++++- app/pages/catalog/hubs/index.vue | 139 +++++------ app/pages/catalog/offers/index.vue | 104 ++++---- app/pages/catalog/suppliers/index.vue | 67 ++---- app/pages/clientarea/addresses/index.vue | 179 ++++++++++---- app/pages/clientarea/offers/index.vue | 293 +++++++++++++++++------ app/pages/clientarea/orders/index.vue | 268 +++++++++++++++------ 8 files changed, 828 insertions(+), 387 deletions(-) create mode 100644 app/composables/useCatalogLayout.ts diff --git a/app/composables/useCatalogLayout.ts b/app/composables/useCatalogLayout.ts new file mode 100644 index 0000000..0c05b72 --- /dev/null +++ b/app/composables/useCatalogLayout.ts @@ -0,0 +1,71 @@ +import type { Ref, ComputedRef, Component, VNode } from 'vue' + +export interface CatalogFilter { + id: string + label: string +} + +export interface CatalogMapItem { + uuid: string + name?: string + latitude: number + longitude: number + [key: string]: any +} + +export interface CatalogHoveredItem { + latitude: number + longitude: number +} + +export interface SubNavItem { + label: string + path: string +} + +export interface CatalogLayoutData { + // SubNavigation (optional - if provided, overrides default catalog nav) + subNavItems?: SubNavItem[] + + // SearchBar + searchQuery: Ref + activeFilters: ComputedRef | Ref + displayedCount: ComputedRef | Ref + totalCount: ComputedRef | Ref + onSearch: () => void + onRemoveFilter: (id: string) => void + // Filter slot - can be a component, render function, or VNode + filterComponent?: Component | (() => VNode | VNode[]) + // Header slot - optional component to render above the list (e.g. "Add" button) + headerComponent?: Component | (() => VNode | VNode[]) + + // Map + mapItems: ComputedRef | Ref + mapId: string + pointColor: string + hoveredItemId: Ref + hoveredItem: ComputedRef | Ref + onMapSelect: (uuid: string) => void + onBoundsChange?: (bounds: any) => void + searchWithMap: Ref + + // Clustering (optional) + useServerClustering?: boolean + clusteredNodes?: ComputedRef | Ref +} + +const CATALOG_LAYOUT_KEY = Symbol('catalogLayout') + +/** + * Provide catalog layout data from page to layout + */ +export const provideCatalogLayout = (data: CatalogLayoutData) => { + provide(CATALOG_LAYOUT_KEY, data) +} + +/** + * Inject catalog layout data in layout from page + */ +export const useCatalogLayoutData = (): CatalogLayoutData | undefined => { + return inject(CATALOG_LAYOUT_KEY) +} diff --git a/app/layouts/catalog.vue b/app/layouts/catalog.vue index 172ee90..1b1d757 100644 --- a/app/layouts/catalog.vue +++ b/app/layouts/catalog.vue @@ -37,7 +37,7 @@ - +
- - - +
- +
+ > +
+ + + + + +
+
diff --git a/app/pages/clientarea/offers/index.vue b/app/pages/clientarea/offers/index.vue index 66d3b00..92900c5 100644 --- a/app/pages/clientarea/offers/index.vue +++ b/app/pages/clientarea/offers/index.vue @@ -1,17 +1,17 @@