Migrate orders and addresses to split layout
All checks were successful
Build Docker Image / build (push) Successful in 4m20s
All checks were successful
Build Docker Image / build (push) Successful in 4m20s
- Use ListMapLayout for two-column list+map view - Orders: show source locations on map - Addresses: show address locations on map - Remove preview map links (map is now inline) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,27 +1,48 @@
|
|||||||
<template>
|
<template>
|
||||||
<Section variant="plain" paddingY="md">
|
<div class="flex flex-col flex-1 min-h-0">
|
||||||
<Stack gap="6">
|
<!-- Loading state -->
|
||||||
<Card v-if="isLoading" padding="lg">
|
<div v-if="isLoading" class="flex-1 flex items-center justify-center">
|
||||||
<Stack align="center" gap="3">
|
<Card padding="lg">
|
||||||
|
<Stack align="center" justify="center" gap="3">
|
||||||
<Spinner />
|
<Spinner />
|
||||||
<Text tone="muted">{{ t('profileAddresses.states.loading') }}</Text>
|
<Text tone="muted">{{ t('profileAddresses.states.loading') }}</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
<template v-else-if="items.length">
|
<!-- ListMapLayout -->
|
||||||
<NuxtLink :to="localePath('/clientarea/addresses/map')" class="block h-48 rounded-lg overflow-hidden cursor-pointer">
|
<ListMapLayout
|
||||||
<ClientOnly>
|
v-else-if="items.length"
|
||||||
<MapboxGlobe
|
:items="itemsForMap"
|
||||||
|
:selected-item-id="selectedAddressId"
|
||||||
map-id="addresses-map"
|
map-id="addresses-map"
|
||||||
:locations="itemsWithCoords"
|
point-color="#10b981"
|
||||||
:height="192"
|
@select-item="onSelectAddress"
|
||||||
/>
|
>
|
||||||
</ClientOnly>
|
<template #list>
|
||||||
|
<Stack gap="4">
|
||||||
|
<!-- Add new address button -->
|
||||||
|
<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>
|
</NuxtLink>
|
||||||
|
|
||||||
<Grid :cols="1" :md="2" :gap="4">
|
<!-- Address cards -->
|
||||||
<NuxtLink v-for="addr in items" :key="addr.uuid" :to="localePath(`/clientarea/addresses/${addr.uuid}`)" class="block">
|
<Stack gap="3">
|
||||||
<Card padding="small" interactive>
|
<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)"
|
||||||
|
>
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<Text size="base" weight="semibold" class="truncate">{{ addr.name }}</Text>
|
<Text size="base" weight="semibold" class="truncate">{{ addr.name }}</Text>
|
||||||
<Text tone="muted" size="sm" class="line-clamp-2">{{ addr.address }}</Text>
|
<Text tone="muted" size="sm" class="line-clamp-2">{{ addr.address }}</Text>
|
||||||
@@ -31,11 +52,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</Grid>
|
</Stack>
|
||||||
</template>
|
|
||||||
|
|
||||||
|
<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
|
||||||
v-else
|
|
||||||
icon="📍"
|
icon="📍"
|
||||||
:title="t('profileAddresses.empty.title')"
|
:title="t('profileAddresses.empty.title')"
|
||||||
:description="t('profileAddresses.empty.description')"
|
:description="t('profileAddresses.empty.description')"
|
||||||
@@ -43,8 +71,8 @@
|
|||||||
:action-to="localePath('/clientarea/addresses/new')"
|
:action-to="localePath('/clientarea/addresses/new')"
|
||||||
action-icon="lucide:plus"
|
action-icon="lucide:plus"
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</div>
|
||||||
</Section>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -59,10 +87,26 @@ const localePath = useLocalePath()
|
|||||||
const {
|
const {
|
||||||
items,
|
items,
|
||||||
isLoading,
|
isLoading,
|
||||||
itemsWithCoords,
|
|
||||||
isoToEmoji,
|
isoToEmoji,
|
||||||
init
|
init
|
||||||
} = useTeamAddresses()
|
} = useTeamAddresses()
|
||||||
|
|
||||||
|
const selectedAddressId = ref<string>()
|
||||||
|
|
||||||
|
// Map items for ListMapLayout
|
||||||
|
const itemsForMap = computed(() => {
|
||||||
|
return items.value.map(addr => ({
|
||||||
|
uuid: addr.uuid,
|
||||||
|
name: addr.name,
|
||||||
|
latitude: addr.latitude,
|
||||||
|
longitude: addr.longitude,
|
||||||
|
country: addr.countryCode
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const onSelectAddress = (uuid: string) => {
|
||||||
|
selectedAddressId.value = uuid
|
||||||
|
}
|
||||||
|
|
||||||
await init()
|
await init()
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,31 +1,48 @@
|
|||||||
<template>
|
<template>
|
||||||
<Section variant="plain" paddingY="md">
|
<div class="flex flex-col flex-1 min-h-0">
|
||||||
<Stack gap="6">
|
<!-- Loading state -->
|
||||||
<Alert v-if="hasError" variant="error">
|
<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('ordersList.states.loading') }}</Text>
|
||||||
|
</Stack>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Error state -->
|
||||||
|
<div v-else-if="hasError" class="flex-1 flex items-center justify-center">
|
||||||
|
<Alert variant="error">
|
||||||
<Stack gap="2">
|
<Stack gap="2">
|
||||||
<Heading :level="4" weight="semibold">{{ $t('common.error') }}</Heading>
|
<Heading :level="4" weight="semibold">{{ $t('common.error') }}</Heading>
|
||||||
<Text tone="muted">{{ error }}</Text>
|
<Text tone="muted">{{ error }}</Text>
|
||||||
<Button @click="load">{{ t('ordersList.errors.retry') }}</Button>
|
<Button @click="load">{{ t('ordersList.errors.retry') }}</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Stack v-else-if="isLoading" align="center" justify="center" gap="3">
|
<!-- ListMapLayout -->
|
||||||
<Spinner />
|
<ListMapLayout
|
||||||
<Text tone="muted">{{ t('ordersList.states.loading') }}</Text>
|
v-else-if="items.length"
|
||||||
</Stack>
|
:items="itemsForMap"
|
||||||
|
:selected-item-id="selectedOrderId"
|
||||||
<template v-else>
|
map-id="orders-map"
|
||||||
<template v-if="items.length">
|
point-color="#6366f1"
|
||||||
<NuxtLink :to="localePath('/clientarea/orders/map')" class="block h-48 rounded-lg overflow-hidden cursor-pointer">
|
@select-item="onSelectOrder"
|
||||||
<ClientOnly>
|
>
|
||||||
<OrdersRoutesPreview :routes="routesForMap" :height="192" />
|
<template #list>
|
||||||
</ClientOnly>
|
<Stack gap="4">
|
||||||
</NuxtLink>
|
|
||||||
|
|
||||||
<CatalogFilters :filters="filters" v-model="selectedFilter" />
|
<CatalogFilters :filters="filters" v-model="selectedFilter" />
|
||||||
|
|
||||||
<Stack gap="4">
|
<Stack gap="4">
|
||||||
<Card v-for="order in filteredItems" :key="order.uuid" padding="lg" class="cursor-pointer" @click="openOrder(order)">
|
<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)"
|
||||||
|
>
|
||||||
<Stack gap="4">
|
<Stack gap="4">
|
||||||
<Stack direction="row" justify="between" align="center">
|
<Stack direction="row" justify="between" align="center">
|
||||||
<Stack gap="1">
|
<Stack gap="1">
|
||||||
@@ -69,10 +86,17 @@
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</Card>
|
||||||
</Stack>
|
</Stack>
|
||||||
</template>
|
|
||||||
|
|
||||||
|
<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
|
||||||
v-else
|
|
||||||
icon="📦"
|
icon="📦"
|
||||||
:title="$t('orders.no_orders')"
|
:title="$t('orders.no_orders')"
|
||||||
:description="$t('orders.no_orders_desc')"
|
:description="$t('orders.no_orders_desc')"
|
||||||
@@ -80,9 +104,8 @@
|
|||||||
:action-to="localePath('/clientarea')"
|
:action-to="localePath('/clientarea')"
|
||||||
action-icon="lucide:plus"
|
action-icon="lucide:plus"
|
||||||
/>
|
/>
|
||||||
</template>
|
</div>
|
||||||
</Stack>
|
</div>
|
||||||
</Section>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -100,7 +123,6 @@ const {
|
|||||||
isLoading,
|
isLoading,
|
||||||
filters,
|
filters,
|
||||||
selectedFilter,
|
selectedFilter,
|
||||||
routesForMap,
|
|
||||||
load,
|
load,
|
||||||
init,
|
init,
|
||||||
getStatusVariant,
|
getStatusVariant,
|
||||||
@@ -109,6 +131,22 @@ const {
|
|||||||
|
|
||||||
const hasError = ref(false)
|
const hasError = ref(false)
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
|
const selectedOrderId = ref<string>()
|
||||||
|
|
||||||
|
// Map items for ListMapLayout (use source location coordinates)
|
||||||
|
const itemsForMap = computed(() => {
|
||||||
|
return items.value.map(order => ({
|
||||||
|
uuid: order.uuid,
|
||||||
|
name: order.name || `#${order.uuid.slice(0, 8)}`,
|
||||||
|
latitude: order.sourceLatitude,
|
||||||
|
longitude: order.sourceLongitude,
|
||||||
|
country: order.sourceLocationName
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const onSelectOrder = (uuid: string) => {
|
||||||
|
selectedOrderId.value = uuid
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await init()
|
await init()
|
||||||
@@ -117,10 +155,6 @@ try {
|
|||||||
error.value = err.message || t('ordersDetail.errors.load_failed')
|
error.value = err.message || t('ordersDetail.errors.load_failed')
|
||||||
}
|
}
|
||||||
|
|
||||||
const openOrder = (order: any) => {
|
|
||||||
navigateTo(localePath(`/clientarea/orders/${order.uuid}`))
|
|
||||||
}
|
|
||||||
|
|
||||||
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')
|
||||||
return formatDate(order.createdAt)
|
return formatDate(order.createdAt)
|
||||||
|
|||||||
Reference in New Issue
Block a user