Unify CatalogPage: fixed map, hover support, delete ListMapLayout
All checks were successful
Build Docker Image / build (push) Successful in 4m31s
All checks were successful
Build Docker Image / build (push) Successful in 4m31s
This commit is contained in:
@@ -1,151 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="flex flex-col flex-1 min-h-0">
|
|
||||||
<!-- Desktop: side-by-side layout -->
|
|
||||||
<div class="hidden lg:flex flex-1 gap-4 min-h-0">
|
|
||||||
<!-- Left side: List (scrollable) -->
|
|
||||||
<div class="w-2/5 overflow-y-auto pr-2">
|
|
||||||
<slot name="list" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Right side: Map (fixed position, full height) -->
|
|
||||||
<div class="w-3/5 relative">
|
|
||||||
<div class="fixed top-28 right-6 w-[calc(60%-3rem)] h-[calc(100vh-8rem)] rounded-lg overflow-hidden">
|
|
||||||
<ClientOnly>
|
|
||||||
<CatalogMap
|
|
||||||
ref="mapRef"
|
|
||||||
:map-id="mapId"
|
|
||||||
:items="itemsWithCoords"
|
|
||||||
:point-color="pointColor"
|
|
||||||
@select-item="onMapSelectItem"
|
|
||||||
/>
|
|
||||||
</ClientOnly>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Mobile: toggle between list and map -->
|
|
||||||
<div class="lg:hidden flex-1 flex flex-col min-h-0">
|
|
||||||
<!-- Content area -->
|
|
||||||
<div class="flex-1 overflow-y-auto" v-show="mobileView === 'list'">
|
|
||||||
<slot name="list" />
|
|
||||||
</div>
|
|
||||||
<div class="flex-1" v-show="mobileView === 'map'">
|
|
||||||
<ClientOnly>
|
|
||||||
<CatalogMap
|
|
||||||
ref="mobileMapRef"
|
|
||||||
:map-id="`${mapId}-mobile`"
|
|
||||||
:items="itemsWithCoords"
|
|
||||||
:point-color="pointColor"
|
|
||||||
@select-item="onMapSelectItem"
|
|
||||||
/>
|
|
||||||
</ClientOnly>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Mobile toggle buttons -->
|
|
||||||
<div class="fixed bottom-4 left-1/2 -translate-x-1/2 z-30">
|
|
||||||
<div class="btn-group shadow-lg">
|
|
||||||
<button
|
|
||||||
class="btn btn-sm"
|
|
||||||
:class="{ 'btn-active': mobileView === 'list' }"
|
|
||||||
@click="mobileView = 'list'"
|
|
||||||
>
|
|
||||||
{{ $t('common.list') }}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="btn btn-sm"
|
|
||||||
:class="{ 'btn-active': mobileView === 'map' }"
|
|
||||||
@click="mobileView = 'map'"
|
|
||||||
>
|
|
||||||
{{ $t('common.map') }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
interface MapItem {
|
|
||||||
uuid: string
|
|
||||||
latitude?: number | null
|
|
||||||
longitude?: number | null
|
|
||||||
name?: string
|
|
||||||
country?: string
|
|
||||||
[key: string]: any
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
|
||||||
items: MapItem[]
|
|
||||||
selectedItemId?: string
|
|
||||||
hoveredItemId?: string
|
|
||||||
mapId: string
|
|
||||||
pointColor?: string
|
|
||||||
}>(), {
|
|
||||||
pointColor: '#3b82f6'
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
'select-item': [uuid: string]
|
|
||||||
'update:selectedItemId': [uuid: string]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
// Filter items with valid coordinates
|
|
||||||
const itemsWithCoords = computed(() =>
|
|
||||||
props.items.filter(item =>
|
|
||||||
item.latitude != null &&
|
|
||||||
item.longitude != null &&
|
|
||||||
!isNaN(Number(item.latitude)) &&
|
|
||||||
!isNaN(Number(item.longitude))
|
|
||||||
).map(item => ({
|
|
||||||
uuid: item.uuid,
|
|
||||||
name: item.name || '',
|
|
||||||
latitude: Number(item.latitude),
|
|
||||||
longitude: Number(item.longitude),
|
|
||||||
country: item.country
|
|
||||||
}))
|
|
||||||
)
|
|
||||||
|
|
||||||
// Mobile view toggle
|
|
||||||
const mobileView = ref<'list' | 'map'>('list')
|
|
||||||
|
|
||||||
// Map refs
|
|
||||||
const mapRef = ref<{ flyTo: (lat: number, lng: number, zoom?: number) => void } | null>(null)
|
|
||||||
const mobileMapRef = ref<{ flyTo: (lat: number, lng: number, zoom?: number) => void } | null>(null)
|
|
||||||
|
|
||||||
// Handle map item selection
|
|
||||||
const onMapSelectItem = (uuid: string) => {
|
|
||||||
emit('select-item', uuid)
|
|
||||||
emit('update:selectedItemId', uuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fly to a specific item
|
|
||||||
const flyTo = (lat: number, lng: number, zoom = 8) => {
|
|
||||||
mapRef.value?.flyTo(lat, lng, zoom)
|
|
||||||
mobileMapRef.value?.flyTo(lat, lng, zoom)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fly to item by uuid
|
|
||||||
const flyToItem = (uuid: string) => {
|
|
||||||
const item = itemsWithCoords.value.find(i => i.uuid === uuid)
|
|
||||||
if (item) {
|
|
||||||
flyTo(item.latitude, item.longitude, 8)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch selectedItemId and fly to it
|
|
||||||
watch(() => props.selectedItemId, (uuid) => {
|
|
||||||
if (uuid) {
|
|
||||||
flyToItem(uuid)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Watch hoveredItemId and fly to it on hover
|
|
||||||
watch(() => props.hoveredItemId, (uuid) => {
|
|
||||||
if (uuid) {
|
|
||||||
flyToItem(uuid)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Expose methods for parent components
|
|
||||||
defineExpose({ flyTo, flyToItem })
|
|
||||||
</script>
|
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
<!-- Left: List (scrollable) -->
|
<!-- Left: List (scrollable) -->
|
||||||
<div class="w-2/5 overflow-y-auto pr-2">
|
<div class="w-2/5 overflow-y-auto pr-2">
|
||||||
<Stack gap="4">
|
<Stack gap="4">
|
||||||
|
<slot name="header" />
|
||||||
<slot name="filters" />
|
<slot name="filters" />
|
||||||
|
|
||||||
<Stack gap="3">
|
<Stack gap="3">
|
||||||
@@ -27,6 +28,8 @@
|
|||||||
:key="item.uuid"
|
:key="item.uuid"
|
||||||
:class="{ 'ring-2 ring-primary rounded-lg': item.uuid === selectedId }"
|
:class="{ 'ring-2 ring-primary rounded-lg': item.uuid === selectedId }"
|
||||||
@click="onItemClick(item)"
|
@click="onItemClick(item)"
|
||||||
|
@mouseenter="emit('update:hoveredId', item.uuid)"
|
||||||
|
@mouseleave="emit('update:hoveredId', undefined)"
|
||||||
>
|
>
|
||||||
<slot name="card" :item="item" />
|
<slot name="card" :item="item" />
|
||||||
</div>
|
</div>
|
||||||
@@ -42,17 +45,19 @@
|
|||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Right: Map -->
|
<!-- Right: Map (fixed position) -->
|
||||||
<div class="w-3/5 rounded-lg overflow-hidden">
|
<div class="w-3/5 relative">
|
||||||
<ClientOnly>
|
<div class="fixed top-28 right-6 w-[calc(60%-3rem)] h-[calc(100vh-8rem)] rounded-lg overflow-hidden">
|
||||||
<CatalogMap
|
<ClientOnly>
|
||||||
ref="mapRef"
|
<CatalogMap
|
||||||
:map-id="mapId"
|
ref="mapRef"
|
||||||
:items="itemsWithCoords"
|
:map-id="mapId"
|
||||||
:point-color="pointColor"
|
:items="itemsWithCoords"
|
||||||
@select-item="onMapSelect"
|
:point-color="pointColor"
|
||||||
/>
|
@select-item="onMapSelect"
|
||||||
</ClientOnly>
|
/>
|
||||||
|
</ClientOnly>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -60,6 +65,7 @@
|
|||||||
<div class="lg:hidden flex-1 flex flex-col min-h-0">
|
<div class="lg:hidden flex-1 flex flex-col min-h-0">
|
||||||
<div class="flex-1 overflow-y-auto py-4" v-show="mobileView === 'list'">
|
<div class="flex-1 overflow-y-auto py-4" v-show="mobileView === 'list'">
|
||||||
<Stack gap="4">
|
<Stack gap="4">
|
||||||
|
<slot name="header" />
|
||||||
<slot name="filters" />
|
<slot name="filters" />
|
||||||
|
|
||||||
<Stack gap="3">
|
<Stack gap="3">
|
||||||
@@ -68,6 +74,8 @@
|
|||||||
:key="item.uuid"
|
:key="item.uuid"
|
||||||
:class="{ 'ring-2 ring-primary rounded-lg': item.uuid === selectedId }"
|
:class="{ 'ring-2 ring-primary rounded-lg': item.uuid === selectedId }"
|
||||||
@click="onItemClick(item)"
|
@click="onItemClick(item)"
|
||||||
|
@mouseenter="emit('update:hoveredId', item.uuid)"
|
||||||
|
@mouseleave="emit('update:hoveredId', undefined)"
|
||||||
>
|
>
|
||||||
<slot name="card" :item="item" />
|
<slot name="card" :item="item" />
|
||||||
</div>
|
</div>
|
||||||
@@ -120,6 +128,7 @@
|
|||||||
<!-- Without Map: Simple List -->
|
<!-- Without Map: Simple List -->
|
||||||
<div v-else class="flex-1 overflow-y-auto py-4">
|
<div v-else class="flex-1 overflow-y-auto py-4">
|
||||||
<Stack gap="4">
|
<Stack gap="4">
|
||||||
|
<slot name="header" />
|
||||||
<slot name="filters" />
|
<slot name="filters" />
|
||||||
|
|
||||||
<Stack gap="3">
|
<Stack gap="3">
|
||||||
@@ -162,6 +171,7 @@ const props = withDefaults(defineProps<{
|
|||||||
mapId?: string
|
mapId?: string
|
||||||
pointColor?: string
|
pointColor?: string
|
||||||
selectedId?: string
|
selectedId?: string
|
||||||
|
hoveredId?: string
|
||||||
}>(), {
|
}>(), {
|
||||||
loading: false,
|
loading: false,
|
||||||
withMap: true,
|
withMap: true,
|
||||||
@@ -172,6 +182,7 @@ const props = withDefaults(defineProps<{
|
|||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
'select': [item: MapItem]
|
'select': [item: MapItem]
|
||||||
'update:selectedId': [uuid: string]
|
'update:selectedId': [uuid: string]
|
||||||
|
'update:hoveredId': [uuid: string | undefined]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
// Filter items with valid coordinates for map
|
// Filter items with valid coordinates for map
|
||||||
@@ -229,6 +240,17 @@ watch(() => props.selectedId, (uuid) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Watch hoveredId and fly to it
|
||||||
|
watch(() => props.hoveredId, (uuid) => {
|
||||||
|
if (uuid && props.withMap) {
|
||||||
|
const item = itemsWithCoords.value.find(i => i.uuid === uuid)
|
||||||
|
if (item) {
|
||||||
|
mapRef.value?.flyTo(item.latitude, item.longitude, 8)
|
||||||
|
mobileMapRef.value?.flyTo(item.latitude, item.longitude, 8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Expose flyTo for external use
|
// Expose flyTo for external use
|
||||||
const flyTo = (lat: number, lng: number, zoom = 8) => {
|
const flyTo = (lat: number, lng: number, zoom = 8) => {
|
||||||
mapRef.value?.flyTo(lat, lng, zoom)
|
mapRef.value?.flyTo(lat, lng, zoom)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
map-id="hubs-map"
|
map-id="hubs-map"
|
||||||
point-color="#10b981"
|
point-color="#10b981"
|
||||||
:selected-id="selectedHubId"
|
:selected-id="selectedHubId"
|
||||||
|
v-model:hovered-id="hoveredHubId"
|
||||||
@select="onSelectHub"
|
@select="onSelectHub"
|
||||||
>
|
>
|
||||||
<template #filters>
|
<template #filters>
|
||||||
@@ -59,8 +60,9 @@ const {
|
|||||||
init
|
init
|
||||||
} = useCatalogHubs()
|
} = useCatalogHubs()
|
||||||
|
|
||||||
// Selected hub for map highlighting
|
// Selected/hovered hub for map highlighting
|
||||||
const selectedHubId = ref<string>()
|
const selectedHubId = ref<string>()
|
||||||
|
const hoveredHubId = ref<string>()
|
||||||
|
|
||||||
const onSelectHub = (hub: any) => {
|
const onSelectHub = (hub: any) => {
|
||||||
selectedHubId.value = hub.uuid
|
selectedHubId.value = hub.uuid
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
map-id="offers-map"
|
map-id="offers-map"
|
||||||
point-color="#f59e0b"
|
point-color="#f59e0b"
|
||||||
:selected-id="selectedOfferId"
|
:selected-id="selectedOfferId"
|
||||||
|
v-model:hovered-id="hoveredOfferId"
|
||||||
@select="onSelectOffer"
|
@select="onSelectOffer"
|
||||||
>
|
>
|
||||||
<template #filters>
|
<template #filters>
|
||||||
@@ -78,8 +79,9 @@ const onProductFilterChange = (value: string) => {
|
|||||||
setProductUuid(value === 'all' ? null : value)
|
setProductUuid(value === 'all' ? null : value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selected offer for map highlighting
|
// Selected/hovered offer for map highlighting
|
||||||
const selectedOfferId = ref<string>()
|
const selectedOfferId = ref<string>()
|
||||||
|
const hoveredOfferId = ref<string>()
|
||||||
|
|
||||||
const onSelectOffer = (offer: any) => {
|
const onSelectOffer = (offer: any) => {
|
||||||
selectedOfferId.value = offer.uuid
|
selectedOfferId.value = offer.uuid
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
map-id="suppliers-map"
|
map-id="suppliers-map"
|
||||||
point-color="#3b82f6"
|
point-color="#3b82f6"
|
||||||
:selected-id="selectedSupplierId"
|
:selected-id="selectedSupplierId"
|
||||||
|
v-model:hovered-id="hoveredSupplierId"
|
||||||
@select="onSelectSupplier"
|
@select="onSelectSupplier"
|
||||||
>
|
>
|
||||||
<template #card="{ item }">
|
<template #card="{ item }">
|
||||||
@@ -44,8 +45,9 @@ const {
|
|||||||
init
|
init
|
||||||
} = useCatalogSuppliers()
|
} = useCatalogSuppliers()
|
||||||
|
|
||||||
// Selected supplier for map highlighting
|
// Selected/hovered supplier for map highlighting
|
||||||
const selectedSupplierId = ref<string>()
|
const selectedSupplierId = ref<string>()
|
||||||
|
const hoveredSupplierId = ref<string>()
|
||||||
|
|
||||||
const onSelectSupplier = (supplier: any) => {
|
const onSelectSupplier = (supplier: any) => {
|
||||||
selectedSupplierId.value = supplier.uuid || supplier.teamUuid
|
selectedSupplierId.value = supplier.uuid || supplier.teamUuid
|
||||||
|
|||||||
@@ -1,71 +1,40 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col flex-1 min-h-0">
|
<CatalogPage
|
||||||
<!-- Loading state -->
|
:items="itemsForMap"
|
||||||
<div v-if="isLoading" class="flex-1 flex items-center justify-center">
|
:loading="isLoading"
|
||||||
<Card padding="lg">
|
map-id="addresses-map"
|
||||||
<Stack align="center" justify="center" gap="3">
|
point-color="#10b981"
|
||||||
<Spinner />
|
:selected-id="selectedAddressId"
|
||||||
<Text tone="muted">{{ t('profileAddresses.states.loading') }}</Text>
|
v-model:hovered-id="hoveredAddressId"
|
||||||
</Stack>
|
@select="onSelectAddress"
|
||||||
</Card>
|
>
|
||||||
</div>
|
<template #header>
|
||||||
|
<NuxtLink :to="localePath('/clientarea/addresses/new')">
|
||||||
|
<Button variant="outline" class="w-full">
|
||||||
|
<Icon name="lucide:plus" size="16" class="mr-2" />
|
||||||
|
{{ t('profileAddresses.actions.add') }}
|
||||||
|
</Button>
|
||||||
|
</NuxtLink>
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- ListMapLayout -->
|
<template #card="{ item }">
|
||||||
<ListMapLayout
|
<NuxtLink
|
||||||
v-else-if="items.length"
|
:to="localePath(`/clientarea/addresses/${item.uuid}`)"
|
||||||
:items="itemsForMap"
|
class="block"
|
||||||
:selected-item-id="selectedAddressId"
|
>
|
||||||
:hovered-item-id="hoveredAddressId"
|
<Card padding="sm" interactive>
|
||||||
map-id="addresses-map"
|
<div class="flex flex-col gap-1">
|
||||||
point-color="#10b981"
|
<Text size="base" weight="semibold" class="truncate">{{ item.name }}</Text>
|
||||||
@select-item="onSelectAddress"
|
<Text tone="muted" size="sm" class="line-clamp-2">{{ item.address }}</Text>
|
||||||
>
|
<div class="flex items-center mt-1">
|
||||||
<template #list>
|
<span class="text-lg">{{ isoToEmoji(item.countryCode) }}</span>
|
||||||
<Stack gap="4">
|
</div>
|
||||||
<!-- Add new address button -->
|
</div>
|
||||||
<NuxtLink :to="localePath('/clientarea/addresses/new')">
|
</Card>
|
||||||
<Button variant="outline" class="w-full">
|
</NuxtLink>
|
||||||
<Icon name="lucide:plus" size="16" class="mr-2" />
|
</template>
|
||||||
{{ t('profileAddresses.actions.add') }}
|
|
||||||
</Button>
|
|
||||||
</NuxtLink>
|
|
||||||
|
|
||||||
<!-- Address cards -->
|
<template #empty>
|
||||||
<Stack gap="3">
|
|
||||||
<NuxtLink
|
|
||||||
v-for="addr in items"
|
|
||||||
:key="addr.uuid"
|
|
||||||
:to="localePath(`/clientarea/addresses/${addr.uuid}`)"
|
|
||||||
class="block"
|
|
||||||
>
|
|
||||||
<Card
|
|
||||||
padding="sm"
|
|
||||||
interactive
|
|
||||||
:class="{ 'ring-2 ring-primary': addr.uuid === selectedAddressId }"
|
|
||||||
@click.prevent="onSelectAddress(addr.uuid)"
|
|
||||||
@mouseenter="hoveredAddressId = addr.uuid"
|
|
||||||
@mouseleave="hoveredAddressId = undefined"
|
|
||||||
>
|
|
||||||
<div class="flex flex-col gap-1">
|
|
||||||
<Text size="base" weight="semibold" class="truncate">{{ addr.name }}</Text>
|
|
||||||
<Text tone="muted" size="sm" class="line-clamp-2">{{ addr.address }}</Text>
|
|
||||||
<div class="flex items-center mt-1">
|
|
||||||
<span class="text-lg">{{ isoToEmoji(addr.countryCode) }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</NuxtLink>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Stack v-if="items.length === 0" align="center" gap="2">
|
|
||||||
<Text tone="muted">{{ t('profileAddresses.empty.title') }}</Text>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
</template>
|
|
||||||
</ListMapLayout>
|
|
||||||
|
|
||||||
<!-- Empty state -->
|
|
||||||
<div v-else class="flex-1 flex items-center justify-center">
|
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon="📍"
|
icon="📍"
|
||||||
:title="t('profileAddresses.empty.title')"
|
:title="t('profileAddresses.empty.title')"
|
||||||
@@ -74,8 +43,8 @@
|
|||||||
:action-to="localePath('/clientarea/addresses/new')"
|
:action-to="localePath('/clientarea/addresses/new')"
|
||||||
action-icon="lucide:plus"
|
action-icon="lucide:plus"
|
||||||
/>
|
/>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
</CatalogPage>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -97,19 +66,21 @@ const {
|
|||||||
const selectedAddressId = ref<string>()
|
const selectedAddressId = ref<string>()
|
||||||
const hoveredAddressId = ref<string>()
|
const hoveredAddressId = ref<string>()
|
||||||
|
|
||||||
// Map items for ListMapLayout
|
// Map items for CatalogPage
|
||||||
const itemsForMap = computed(() => {
|
const itemsForMap = computed(() => {
|
||||||
return items.value.map(addr => ({
|
return items.value.map(addr => ({
|
||||||
uuid: addr.uuid,
|
uuid: addr.uuid,
|
||||||
name: addr.name,
|
name: addr.name,
|
||||||
|
address: addr.address,
|
||||||
latitude: addr.latitude,
|
latitude: addr.latitude,
|
||||||
longitude: addr.longitude,
|
longitude: addr.longitude,
|
||||||
|
countryCode: addr.countryCode,
|
||||||
country: addr.countryCode
|
country: addr.countryCode
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
const onSelectAddress = (uuid: string) => {
|
const onSelectAddress = (item: any) => {
|
||||||
selectedAddressId.value = uuid
|
selectedAddressId.value = item.uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
await init()
|
await init()
|
||||||
|
|||||||
@@ -1,104 +1,64 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col flex-1 min-h-0">
|
<CatalogPage
|
||||||
<!-- Loading state -->
|
:items="itemsForMap"
|
||||||
<div v-if="isLoading" class="flex-1 flex items-center justify-center">
|
:loading="isLoading"
|
||||||
<Card padding="lg">
|
map-id="orders-map"
|
||||||
<Stack align="center" justify="center" gap="3">
|
point-color="#6366f1"
|
||||||
<Spinner />
|
:selected-id="selectedOrderId"
|
||||||
<Text tone="muted">{{ t('ordersList.states.loading') }}</Text>
|
v-model:hovered-id="hoveredOrderId"
|
||||||
|
@select="onSelectOrder"
|
||||||
|
>
|
||||||
|
<template #filters>
|
||||||
|
<CatalogFilterSelect :filters="filters" v-model="selectedFilter" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #card="{ item }">
|
||||||
|
<Card padding="lg" class="cursor-pointer">
|
||||||
|
<Stack gap="4">
|
||||||
|
<Stack direction="row" justify="between" align="center">
|
||||||
|
<Stack gap="1">
|
||||||
|
<Text size="sm" tone="muted">{{ t('ordersList.card.order_label') }}</Text>
|
||||||
|
<Heading :level="3">#{{ item.name }}</Heading>
|
||||||
|
</Stack>
|
||||||
|
<div class="badge badge-outline">
|
||||||
|
{{ getOrderStartDate(item) }} → {{ getOrderEndDate(item) }}
|
||||||
|
</div>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<div class="divider my-0"></div>
|
||||||
|
|
||||||
|
<Grid :cols="1" :md="3" :gap="3">
|
||||||
|
<Stack gap="1">
|
||||||
|
<Text size="sm" tone="muted">{{ t('ordersList.card.route') }}</Text>
|
||||||
|
<Text weight="semibold">{{ item.sourceLocationName }} → {{ item.destinationLocationName }}</Text>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Stack gap="1">
|
||||||
|
<Text size="sm" tone="muted">{{ t('ordersList.card.product') }}</Text>
|
||||||
|
<Text>
|
||||||
|
{{ item.orderLines?.[0]?.productName || t('ordersList.card.product_loading') }}
|
||||||
|
<template v-if="item.orderLines?.length > 1">
|
||||||
|
<span class="badge badge-ghost ml-2">+{{ item.orderLines.length - 1 }}</span>
|
||||||
|
</template>
|
||||||
|
</Text>
|
||||||
|
<Text tone="muted" size="sm">
|
||||||
|
{{ item.orderLines?.[0]?.quantity || 0 }} {{ item.orderLines?.[0]?.unit || t('ordersList.card.unit_tons') }}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Stack gap="1">
|
||||||
|
<Text size="sm" tone="muted">{{ t('ordersList.card.status') }}</Text>
|
||||||
|
<Badge :variant="getStatusVariant(item.status)">
|
||||||
|
{{ getStatusText(item.status) }}
|
||||||
|
</Badge>
|
||||||
|
<Text tone="muted" size="sm">{{ t('ordersList.card.stages_completed', { done: getCompletedStages(item), total: item.stages?.length || 0 }) }}</Text>
|
||||||
|
</Stack>
|
||||||
|
</Grid>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</template>
|
||||||
|
|
||||||
<!-- Error state -->
|
<template #empty>
|
||||||
<div v-else-if="hasError" class="flex-1 flex items-center justify-center">
|
|
||||||
<Alert variant="error">
|
|
||||||
<Stack gap="2">
|
|
||||||
<Heading :level="4" weight="semibold">{{ $t('common.error') }}</Heading>
|
|
||||||
<Text tone="muted">{{ error }}</Text>
|
|
||||||
<Button @click="load">{{ t('ordersList.errors.retry') }}</Button>
|
|
||||||
</Stack>
|
|
||||||
</Alert>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ListMapLayout -->
|
|
||||||
<ListMapLayout
|
|
||||||
v-else-if="items.length"
|
|
||||||
:items="itemsForMap"
|
|
||||||
:selected-item-id="selectedOrderId"
|
|
||||||
:hovered-item-id="hoveredOrderId"
|
|
||||||
map-id="orders-map"
|
|
||||||
point-color="#6366f1"
|
|
||||||
@select-item="onSelectOrder"
|
|
||||||
>
|
|
||||||
<template #list>
|
|
||||||
<Stack gap="4">
|
|
||||||
<CatalogFilters :filters="filters" v-model="selectedFilter" />
|
|
||||||
|
|
||||||
<Stack gap="4">
|
|
||||||
<Card
|
|
||||||
v-for="order in filteredItems"
|
|
||||||
:key="order.uuid"
|
|
||||||
padding="lg"
|
|
||||||
class="cursor-pointer"
|
|
||||||
:class="{ 'ring-2 ring-primary': order.uuid === selectedOrderId }"
|
|
||||||
@click="onSelectOrder(order.uuid)"
|
|
||||||
@mouseenter="hoveredOrderId = order.uuid"
|
|
||||||
@mouseleave="hoveredOrderId = undefined"
|
|
||||||
>
|
|
||||||
<Stack gap="4">
|
|
||||||
<Stack direction="row" justify="between" align="center">
|
|
||||||
<Stack gap="1">
|
|
||||||
<Text size="sm" tone="muted">{{ t('ordersList.card.order_label') }}</Text>
|
|
||||||
<Heading :level="3">#{{ order.name }}</Heading>
|
|
||||||
</Stack>
|
|
||||||
<div class="badge badge-outline">
|
|
||||||
{{ getOrderStartDate(order) }} → {{ getOrderEndDate(order) }}
|
|
||||||
</div>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<div class="divider my-0"></div>
|
|
||||||
|
|
||||||
<Grid :cols="1" :md="3" :gap="3">
|
|
||||||
<Stack gap="1">
|
|
||||||
<Text size="sm" tone="muted">{{ t('ordersList.card.route') }}</Text>
|
|
||||||
<Text weight="semibold">{{ order.sourceLocationName }} → {{ order.destinationLocationName }}</Text>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Stack gap="1">
|
|
||||||
<Text size="sm" tone="muted">{{ t('ordersList.card.product') }}</Text>
|
|
||||||
<Text>
|
|
||||||
{{ order.orderLines?.[0]?.productName || t('ordersList.card.product_loading') }}
|
|
||||||
<template v-if="order.orderLines?.length > 1">
|
|
||||||
<span class="badge badge-ghost ml-2">+{{ order.orderLines.length - 1 }}</span>
|
|
||||||
</template>
|
|
||||||
</Text>
|
|
||||||
<Text tone="muted" size="sm">
|
|
||||||
{{ order.orderLines?.[0]?.quantity || 0 }} {{ order.orderLines?.[0]?.unit || t('ordersList.card.unit_tons') }}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Stack gap="1">
|
|
||||||
<Text size="sm" tone="muted">{{ t('ordersList.card.status') }}</Text>
|
|
||||||
<Badge :variant="getStatusVariant(order.status)">
|
|
||||||
{{ getStatusText(order.status) }}
|
|
||||||
</Badge>
|
|
||||||
<Text tone="muted" size="sm">{{ t('ordersList.card.stages_completed', { done: getCompletedStages(order), total: order.stages?.length || 0 }) }}</Text>
|
|
||||||
</Stack>
|
|
||||||
</Grid>
|
|
||||||
</Stack>
|
|
||||||
</Card>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Stack v-if="filteredItems.length === 0" align="center" gap="2">
|
|
||||||
<Text tone="muted">{{ $t('orders.no_orders') }}</Text>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
</template>
|
|
||||||
</ListMapLayout>
|
|
||||||
|
|
||||||
<!-- Empty state -->
|
|
||||||
<div v-else class="flex-1 flex items-center justify-center">
|
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon="📦"
|
icon="📦"
|
||||||
:title="$t('orders.no_orders')"
|
:title="$t('orders.no_orders')"
|
||||||
@@ -107,8 +67,8 @@
|
|||||||
:action-to="localePath('/clientarea')"
|
:action-to="localePath('/clientarea')"
|
||||||
action-icon="lucide:plus"
|
action-icon="lucide:plus"
|
||||||
/>
|
/>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
</CatalogPage>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -121,25 +81,22 @@ const localePath = useLocalePath()
|
|||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
items,
|
|
||||||
filteredItems,
|
filteredItems,
|
||||||
isLoading,
|
isLoading,
|
||||||
filters,
|
filters,
|
||||||
selectedFilter,
|
selectedFilter,
|
||||||
load,
|
|
||||||
init,
|
init,
|
||||||
getStatusVariant,
|
getStatusVariant,
|
||||||
getStatusText
|
getStatusText
|
||||||
} = useTeamOrders()
|
} = useTeamOrders()
|
||||||
|
|
||||||
const hasError = ref(false)
|
|
||||||
const error = ref('')
|
|
||||||
const selectedOrderId = ref<string>()
|
const selectedOrderId = ref<string>()
|
||||||
const hoveredOrderId = ref<string>()
|
const hoveredOrderId = ref<string>()
|
||||||
|
|
||||||
// Map items for ListMapLayout (use source location coordinates)
|
// Map items for CatalogPage (use source location coordinates)
|
||||||
const itemsForMap = computed(() => {
|
const itemsForMap = computed(() => {
|
||||||
return items.value.map(order => ({
|
return filteredItems.value.map(order => ({
|
||||||
|
...order,
|
||||||
uuid: order.uuid,
|
uuid: order.uuid,
|
||||||
name: order.name || `#${order.uuid.slice(0, 8)}`,
|
name: order.name || `#${order.uuid.slice(0, 8)}`,
|
||||||
latitude: order.sourceLatitude,
|
latitude: order.sourceLatitude,
|
||||||
@@ -148,16 +105,11 @@ const itemsForMap = computed(() => {
|
|||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
const onSelectOrder = (uuid: string) => {
|
const onSelectOrder = (item: any) => {
|
||||||
selectedOrderId.value = uuid
|
selectedOrderId.value = item.uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
await init()
|
||||||
await init()
|
|
||||||
} catch (err: any) {
|
|
||||||
hasError.value = true
|
|
||||||
error.value = err.message || t('ordersDetail.errors.load_failed')
|
|
||||||
}
|
|
||||||
|
|
||||||
const getOrderStartDate = (order: any) => {
|
const getOrderStartDate = (order: any) => {
|
||||||
if (!order.createdAt) return t('ordersDetail.labels.dates_undefined')
|
if (!order.createdAt) return t('ordersDetail.labels.dates_undefined')
|
||||||
|
|||||||
Reference in New Issue
Block a user