Unify layouts and create CatalogPage component
All checks were successful
Build Docker Image / build (push) Successful in 3m45s

- MainNavigation: center tabs on page (absolute positioning)
- SubNavigation: align left instead of center
- Create CatalogPage universal component for list+map pages
- Migrate catalog pages (offers, suppliers, hubs) to CatalogPage
- Remove PageHeader from clientarea pages (redundant with navigation)
- Add topnav layout to supplier detail page

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ruslan Bakiev
2026-01-08 09:38:53 +07:00
parent f34c484561
commit b8de322dd2
9 changed files with 355 additions and 172 deletions

View File

@@ -1,62 +1,37 @@
<template>
<div class="flex flex-col flex-1 min-h-0">
<!-- Header -->
<div class="py-4">
<PageHeader :title="t('catalogHubsSection.header.title')" />
</div>
<CatalogPage
:items="items"
:loading="isLoading"
map-id="hubs-map"
point-color="#10b981"
:selected-id="selectedHubId"
@select="onSelectHub"
>
<template #filters>
<CatalogFilters :filters="filters" v-model="selectedFilter" />
</template>
<!-- Loading state -->
<div v-if="isLoading" class="flex-1 flex items-center justify-center">
<Card padding="lg">
<Stack align="center" justify="center" gap="3">
<Spinner />
<Text tone="muted">{{ t('catalogLanding.states.loading') }}</Text>
</Stack>
</Card>
</div>
<!-- ListMapLayout -->
<ListMapLayout
v-else
ref="listMapRef"
:items="items"
:selected-item-id="selectedHubId"
map-id="hubs-map"
point-color="#10b981"
@select-item="onSelectHub"
>
<template #list>
<Stack gap="4">
<CatalogFilters :filters="filters" v-model="selectedFilter" />
<div v-for="country in itemsByCountry" :key="country.name" class="space-y-3">
<Text weight="semibold">{{ country.name }}</Text>
<Stack gap="3">
<HubCard
v-for="hub in country.hubs"
:key="hub.uuid"
:hub="hub"
:class="{ 'ring-2 ring-primary': hub.uuid === selectedHubId }"
@click="onSelectHub(hub.uuid)"
/>
</Stack>
</div>
<PaginationLoadMore
:shown="items.length"
:total="total"
:can-load-more="canLoadMore"
:loading="isLoadingMore"
@load-more="loadMore"
/>
<Stack v-if="items.length === 0" align="center" gap="2">
<Text tone="muted">{{ t('catalogHubsSection.empty.no_hubs') }}</Text>
</Stack>
</Stack>
<template #card="{ item }">
<template v-for="country in getCountryForHub(item)" :key="country.name">
<Text v-if="isFirstInCountry(item)" weight="semibold" class="mb-2">{{ country.name }}</Text>
</template>
</ListMapLayout>
</div>
<HubCard :hub="item" />
</template>
<template #pagination>
<PaginationLoadMore
:shown="items.length"
:total="total"
:can-load-more="canLoadMore"
:loading="isLoadingMore"
@load-more="loadMore"
/>
</template>
<template #empty>
<Text tone="muted">{{ t('catalogHubsSection.empty.no_hubs') }}</Text>
</template>
</CatalogPage>
</template>
<script setup lang="ts">
@@ -81,10 +56,22 @@ const {
// Selected hub for map highlighting
const selectedHubId = ref<string>()
const listMapRef = ref<{ flyToItem: (uuid: string) => void } | null>(null)
const onSelectHub = (uuid: string) => {
selectedHubId.value = uuid
const onSelectHub = (hub: any) => {
selectedHubId.value = hub.uuid
}
// Helper to get country for hub
const getCountryForHub = (hub: any) => {
return itemsByCountry.value.filter(c => c.hubs.some(h => h.uuid === hub.uuid))
}
// Check if this hub is first in its country group
const isFirstInCountry = (hub: any) => {
for (const country of itemsByCountry.value) {
if (country.hubs[0]?.uuid === hub.uuid) return true
}
return false
}
await init()

View File

@@ -1,17 +1,5 @@
<template>
<div class="flex flex-col flex-1 min-h-0">
<!-- Header -->
<div class="py-4">
<PageHeader :title="pageTitle">
<template v-if="selectedProduct" #actions>
<NuxtLink :to="localePath('/catalog/offers')" class="btn btn-ghost btn-sm">
<Icon name="lucide:arrow-left" size="16" />
{{ t('common.back') }}
</NuxtLink>
</template>
</PageHeader>
</div>
<!-- Loading state -->
<div v-if="isLoading || productsLoading" class="flex-1 flex items-center justify-center">
<Card padding="lg">
@@ -46,30 +34,33 @@
</Stack>
</div>
<!-- Offers for selected product - ListMapLayout -->
<ListMapLayout
v-else
ref="listMapRef"
:items="items"
:selected-item-id="selectedOfferId"
map-id="offers-map"
point-color="#f59e0b"
@select-item="onSelectOffer"
>
<template #list>
<Stack gap="4">
<!-- Offers for selected product -->
<template v-else>
<!-- Back button -->
<div class="py-2 px-4 lg:px-0">
<NuxtLink :to="localePath('/catalog/offers')" class="btn btn-ghost btn-sm gap-2">
<Icon name="lucide:arrow-left" size="16" />
{{ t('common.back') }}
</NuxtLink>
</div>
<CatalogPage
:items="items"
:loading="isLoading"
map-id="offers-map"
point-color="#f59e0b"
:selected-id="selectedOfferId"
@select="onSelectOffer"
>
<template #filters>
<CatalogFilters :filters="filters" v-model="selectedFilter" />
</template>
<Stack gap="3">
<OfferCard
v-for="offer in items"
:key="offer.uuid"
:offer="offer"
:class="{ 'ring-2 ring-primary': offer.uuid === selectedOfferId }"
@click="onSelectOffer(offer.uuid)"
/>
</Stack>
<template #card="{ item }">
<OfferCard :offer="item" />
</template>
<template #pagination>
<PaginationLoadMore
:shown="items.length"
:total="total"
@@ -77,13 +68,13 @@
:loading="isLoadingMore"
@load-more="loadMore"
/>
</template>
<Stack v-if="total === 0" align="center" gap="2">
<Text tone="muted">{{ t('catalogOffersSection.empty.no_offers') }}</Text>
</Stack>
</Stack>
</template>
</ListMapLayout>
<template #empty>
<Text tone="muted">{{ t('catalogOffersSection.empty.no_offers') }}</Text>
</template>
</CatalogPage>
</template>
</div>
</template>
@@ -143,11 +134,9 @@ const selectProduct = (product: any) => {
// Selected offer for map highlighting
const selectedOfferId = ref<string>()
const listMapRef = ref<{ flyToItem: (uuid: string) => void } | null>(null)
const onSelectOffer = (uuid: string) => {
selectedOfferId.value = uuid
// flyToItem will be triggered by ListMapLayout watch
const onSelectOffer = (offer: any) => {
selectedOfferId.value = offer.uuid
}
// Initialize

View File

@@ -107,6 +107,10 @@ import {
GetOffersDocument,
} from '~/composables/graphql/public/exchange-generated'
definePageMeta({
layout: 'topnav'
})
const route = useRoute()
const localePath = useLocalePath()
const { t } = useI18n()

View File

@@ -1,59 +1,34 @@
<template>
<div class="flex flex-col flex-1 min-h-0">
<!-- Header -->
<div class="py-4">
<PageHeader :title="t('catalogSuppliersSection.header.title')" />
</div>
<CatalogPage
:items="items"
:loading="isLoading"
map-id="suppliers-map"
point-color="#3b82f6"
:selected-id="selectedSupplierId"
@select="onSelectSupplier"
>
<template #filters>
<CatalogFilters :filters="filters" v-model="selectedFilter" />
</template>
<!-- Loading state -->
<div v-if="isLoading" class="flex-1 flex items-center justify-center">
<Card padding="lg">
<Stack align="center" justify="center" gap="3">
<Spinner />
<Text tone="muted">{{ t('catalogLanding.states.loading') }}</Text>
</Stack>
</Card>
</div>
<template #card="{ item }">
<SupplierCard :supplier="item" />
</template>
<!-- ListMapLayout -->
<ListMapLayout
v-else
ref="listMapRef"
:items="items"
:selected-item-id="selectedSupplierId"
map-id="suppliers-map"
point-color="#3b82f6"
@select-item="onSelectSupplier"
>
<template #list>
<Stack gap="4">
<CatalogFilters :filters="filters" v-model="selectedFilter" />
<template #pagination>
<PaginationLoadMore
:shown="items.length"
:total="total"
:can-load-more="canLoadMore"
:loading="isLoadingMore"
@load-more="loadMore"
/>
</template>
<Stack gap="3">
<SupplierCard
v-for="supplier in items"
:key="supplier.uuid || supplier.teamUuid"
:supplier="supplier"
:class="{ 'ring-2 ring-primary': (supplier.uuid || supplier.teamUuid) === selectedSupplierId }"
@click="onSelectSupplier(supplier.uuid || supplier.teamUuid)"
/>
</Stack>
<PaginationLoadMore
:shown="items.length"
:total="total"
:can-load-more="canLoadMore"
:loading="isLoadingMore"
@load-more="loadMore"
/>
<Stack v-if="total === 0" align="center" gap="2">
<Text tone="muted">{{ t('catalogSuppliersSection.empty.no_suppliers') }}</Text>
</Stack>
</Stack>
</template>
</ListMapLayout>
</div>
<template #empty>
<Text tone="muted">{{ t('catalogSuppliersSection.empty.no_suppliers') }}</Text>
</template>
</CatalogPage>
</template>
<script setup lang="ts">
@@ -77,10 +52,9 @@ const {
// Selected supplier for map highlighting
const selectedSupplierId = ref<string>()
const listMapRef = ref<{ flyToItem: (uuid: string) => void } | null>(null)
const onSelectSupplier = (uuid: string) => {
selectedSupplierId.value = uuid
const onSelectSupplier = (supplier: any) => {
selectedSupplierId.value = supplier.uuid || supplier.teamUuid
}
await init()

View File

@@ -1,11 +1,6 @@
<template>
<Section variant="plain" paddingY="md">
<Stack gap="6">
<PageHeader
:title="t('profileAddresses.header.title')"
:actions="[{ label: t('profileAddresses.actions.add'), icon: 'lucide:plus', to: localePath('/clientarea/addresses/new') }]"
/>
<Card v-if="isLoading" padding="lg">
<Stack align="center" gap="3">
<Spinner />

View File

@@ -1,11 +1,6 @@
<template>
<Section variant="plain" paddingY="md">
<Stack gap="6">
<PageHeader
:title="$t('dashboard.orders')"
:actions="[{ label: t('ordersList.actions.new_calc'), icon: 'lucide:plus', to: localePath('/clientarea') }]"
/>
<Alert v-if="hasError" variant="error">
<Stack gap="2">
<Heading :level="4" weight="semibold">{{ $t('common.error') }}</Heading>