feat(clientarea): modernize orders and addresses pages with new map layout
All checks were successful
Build Docker Image / build (push) Successful in 6m13s

- Create ClientAreaMapPage component for client area pages with glass effect
- Update orders page to use new ClientAreaMapPage with filter dropdown
- Update addresses page to use new ClientAreaMapPage with add button
- Remove Profile and Team tabs from MainNavigation (already in user menu)
This commit is contained in:
Ruslan Bakiev
2026-01-28 09:11:18 +07:00
parent f5b95c27ef
commit 63e8d47b79
4 changed files with 407 additions and 275 deletions

View File

@@ -75,20 +75,6 @@
> >
{{ $t('cabinetNav.addresses') }} {{ $t('cabinetNav.addresses') }}
</NuxtLink> </NuxtLink>
<NuxtLink
:to="localePath('/clientarea/profile')"
class="px-4 py-2 rounded-full text-sm font-medium transition-colors whitespace-nowrap"
:class="isClientAreaTabActive('/clientarea/profile') ? 'bg-primary text-primary-content' : 'text-base-content/70 hover:text-base-content hover:bg-base-200/50'"
>
{{ $t('cabinetNav.profile') }}
</NuxtLink>
<NuxtLink
:to="localePath('/clientarea/team')"
class="px-4 py-2 rounded-full text-sm font-medium transition-colors whitespace-nowrap"
:class="isClientAreaTabActive('/clientarea/team') ? 'bg-primary text-primary-content' : 'text-base-content/70 hover:text-base-content hover:bg-base-200/50'"
>
{{ $t('cabinetNav.team') }}
</NuxtLink>
</div> </div>
</template> </template>

View File

@@ -0,0 +1,294 @@
<template>
<div class="fixed inset-0 flex flex-col">
<!-- Loading state -->
<div v-if="loading" class="absolute inset-0 z-50 flex items-center justify-center bg-base-100/80">
<Card padding="lg">
<Stack align="center" justify="center" gap="3">
<Spinner />
<Text tone="muted">{{ $t('catalogLanding.states.loading') }}</Text>
</Stack>
</Card>
</div>
<!-- Fullscreen Map -->
<div class="absolute inset-0">
<ClientOnly>
<CatalogMap
ref="mapRef"
:map-id="mapId"
:items="itemsWithCoords"
:use-server-clustering="false"
:point-color="pointColor"
:hovered-item-id="hoveredId"
:hovered-item="hoveredItem"
@select-item="onMapSelect"
@bounds-change="onBoundsChange"
/>
</ClientOnly>
</div>
<!-- List button (LEFT, opens panel) - hide when panel is open -->
<button
v-if="!isPanelOpen"
class="absolute top-[116px] left-4 z-20 hidden lg:flex items-center gap-2 bg-black/30 backdrop-blur-md rounded-lg px-3 py-1.5 border border-white/10 text-white text-sm hover:bg-black/40 transition-colors"
@click="isPanelOpen = true"
>
<Icon name="lucide:menu" size="16" />
<span>{{ $t('catalog.list') }}</span>
</button>
<!-- Left panel (slides from left when isPanelOpen is true) -->
<Transition name="slide-left">
<div
v-if="isPanelOpen"
class="absolute top-[116px] left-4 bottom-4 z-30 w-96 max-w-[calc(100vw-2rem)] hidden lg:block"
>
<div class="bg-black/50 backdrop-blur-md rounded-xl shadow-lg border border-white/10 h-full flex flex-col text-white overflow-hidden">
<!-- Panel header -->
<div class="p-4 border-b border-white/10 flex-shrink-0">
<div class="flex items-center justify-between mb-3">
<Text weight="semibold">{{ title }}</Text>
<button
class="btn btn-ghost btn-xs btn-circle text-white/70 hover:text-white"
@click="isPanelOpen = false"
>
<Icon name="lucide:x" size="16" />
</button>
</div>
<!-- Search bar -->
<div v-if="showSearch" class="relative">
<input
:value="searchQuery"
type="text"
:placeholder="$t('common.search')"
class="input input-sm w-full bg-white/10 border-white/20 text-white placeholder:text-white/50"
@input="$emit('update:search-query', ($event.target as HTMLInputElement).value)"
/>
<Icon name="lucide:search" size="16" class="absolute right-3 top-1/2 -translate-y-1/2 text-white/50" />
</div>
<!-- Header slot for extra actions -->
<div v-if="$slots.header" class="mt-3">
<slot name="header" />
</div>
</div>
<!-- Items list -->
<div class="flex-1 overflow-y-auto p-4 space-y-3">
<template v-if="displayItems.length > 0">
<div
v-for="item in displayItems"
:key="item.uuid"
class="cursor-pointer"
@mouseenter="$emit('update:hovered-id', item.uuid)"
@mouseleave="$emit('update:hovered-id', undefined)"
@click="$emit('select', item)"
>
<slot name="card" :item="item" />
</div>
</template>
<template v-else>
<slot name="empty" />
</template>
</div>
<!-- Panel footer with count -->
<div class="p-3 border-t border-white/10 flex-shrink-0">
<Text size="sm" tone="muted">
{{ $t('catalog.showing') }} {{ displayItems.length }} {{ $t('catalog.of') }} {{ totalCount }}
</Text>
</div>
</div>
</div>
</Transition>
<!-- Mobile bottom sheet -->
<div class="lg:hidden absolute bottom-0 left-0 right-0 z-20">
<!-- Mobile controls: List button -->
<div class="flex justify-start px-4 mb-2">
<button
class="flex items-center gap-2 bg-black/30 backdrop-blur-md rounded-lg px-3 py-2 border border-white/10 text-white text-sm"
@click="isPanelOpen = true"
>
<Icon name="lucide:menu" size="16" />
<span>{{ $t('catalog.list') }}</span>
</button>
</div>
<!-- Mobile panel (collapsible) -->
<Transition name="slide-up">
<div
v-if="isPanelOpen"
class="bg-black/50 backdrop-blur-md rounded-t-xl shadow-lg border border-white/10 transition-all duration-300 text-white h-[60vh]"
>
<!-- Drag handle / close -->
<div
class="flex justify-center py-2 cursor-pointer"
@click="isPanelOpen = false"
>
<div class="w-10 h-1 bg-white/30 rounded-full" />
</div>
<div class="px-4 pb-4 overflow-y-auto h-[calc(60vh-2rem)]">
<!-- Search bar -->
<div v-if="showSearch" class="relative mb-3">
<input
:value="searchQuery"
type="text"
:placeholder="$t('common.search')"
class="input input-sm w-full bg-white/10 border-white/20 text-white placeholder:text-white/50"
@input="$emit('update:search-query', ($event.target as HTMLInputElement).value)"
/>
<Icon name="lucide:search" size="16" class="absolute right-3 top-1/2 -translate-y-1/2 text-white/50" />
</div>
<!-- Header slot -->
<div v-if="$slots.header" class="mb-3">
<slot name="header" />
</div>
<!-- Items list -->
<div class="space-y-3">
<template v-if="displayItems.length > 0">
<div
v-for="item in displayItems"
:key="item.uuid"
@click="$emit('select', item)"
>
<slot name="card" :item="item" />
</div>
</template>
<template v-else>
<slot name="empty" />
</template>
</div>
</div>
</div>
</Transition>
</div>
</div>
</template>
<script setup lang="ts">
import type { MapBounds } from '~/components/catalog/CatalogMap.vue'
interface MapItem {
uuid?: string | null
latitude?: number | null
longitude?: number | null
name?: string | null
[key: string]: unknown
}
const props = withDefaults(defineProps<{
items: MapItem[]
loading?: boolean
mapId?: string
pointColor?: string
hoveredId?: string
selectedId?: string
totalCount?: number
title?: string
showSearch?: boolean
searchQuery?: string
}>(), {
loading: false,
mapId: 'client-area-map',
pointColor: '#6366f1',
totalCount: 0,
title: '',
showSearch: true,
searchQuery: ''
})
const emit = defineEmits<{
'select': [item: MapItem]
'bounds-change': [bounds: MapBounds]
'update:hovered-id': [uuid: string | undefined]
'update:search-query': [value: string]
}>()
// Panel state
const isPanelOpen = ref(true)
// Map ref
const mapRef = ref<{ flyTo: (lat: number, lng: number, zoom?: number) => void } | null>(null)
// Filter items with search query
const displayItems = computed(() => {
if (!props.searchQuery) return props.items
const query = props.searchQuery.toLowerCase()
return props.items.filter(item => {
const name = (item.name as string || '').toLowerCase()
return name.includes(query)
})
})
// Filter items with valid coordinates for map
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)
}))
)
// Hovered item with coordinates for map highlight
const hoveredItem = computed(() => {
if (!props.hoveredId) return null
const item = props.items.find(i => i.uuid === props.hoveredId)
if (!item?.latitude || !item?.longitude) return null
return { latitude: Number(item.latitude), longitude: Number(item.longitude) }
})
const onBoundsChange = (bounds: MapBounds) => {
emit('bounds-change', bounds)
}
const onMapSelect = (uuid: string) => {
const item = props.items.find(i => i.uuid === uuid)
if (item) {
emit('select', item)
}
}
// Expose flyTo for external use
const flyTo = (lat: number, lng: number, zoom = 8) => {
mapRef.value?.flyTo(lat, lng, zoom)
}
defineExpose({ flyTo })
</script>
<style scoped>
/* Drawer slide animation (desktop - left) */
.slide-left-enter-active,
.slide-left-leave-active {
transition: transform 0.3s ease, opacity 0.3s ease;
}
.slide-left-enter-from,
.slide-left-leave-to {
transform: translateX(-100%);
opacity: 0;
}
/* Drawer slide animation (mobile - up) */
.slide-up-enter-active,
.slide-up-leave-active {
transition: transform 0.3s ease, opacity 0.3s ease;
}
.slide-up-enter-from,
.slide-up-leave-to {
transform: translateY(100%);
opacity: 0;
}
</style>

View File

@@ -1,66 +1,57 @@
<template> <template>
<CatalogPage <ClientAreaMapPage
:items="displayItems" :items="items"
:map-items="itemsWithCoords"
:loading="isLoading" :loading="isLoading"
with-map
map-id="addresses-map" map-id="addresses-map"
point-color="#10b981" point-color="#10b981"
:selected-id="selectedAddressId"
:hovered-id="hoveredAddressId" :hovered-id="hoveredAddressId"
:total-count="items.length" :total-count="items.length"
:title="t('cabinetNav.addresses')"
:search-query="searchQuery"
@select="onSelectAddress" @select="onSelectAddress"
@update:hovered-id="hoveredAddressId = $event" @update:hovered-id="hoveredAddressId = $event"
@update:search-query="searchQuery = $event"
> >
<template #searchBar="{ displayedCount, totalCount }">
<CatalogSearchBar
v-model:search-query="searchQuery"
:active-filters="[]"
:displayed-count="displayedCount"
:total-count="totalCount"
@search="onSearch"
/>
</template>
<template #header> <template #header>
<NuxtLink :to="localePath('/clientarea/addresses/new')"> <NuxtLink :to="localePath('/clientarea/addresses/new')">
<Button variant="outline" class="w-full"> <button class="btn btn-sm w-full bg-white/10 border-white/20 text-white hover:bg-white/20">
<Icon name="lucide:plus" size="16" class="mr-2" /> <Icon name="lucide:plus" size="14" class="mr-1" />
{{ t('profileAddresses.actions.add') }} {{ t('profileAddresses.actions.add') }}
</Button> </button>
</NuxtLink> </NuxtLink>
</template> </template>
<template #card="{ item }"> <template #card="{ item }">
<NuxtLink :to="localePath(`/clientarea/addresses/${item.uuid}`)" class="block"> <NuxtLink :to="localePath(`/clientarea/addresses/${item.uuid}`)" class="block">
<Card padding="sm" interactive> <div class="bg-white/10 rounded-lg p-4 hover:bg-white/20 transition-colors">
<div class="flex flex-col gap-1"> <div class="flex items-start gap-3">
<Text size="base" weight="semibold" class="truncate">{{ item.name }}</Text> <span class="text-2xl">{{ isoToEmoji(item.countryCode) }}</span>
<Text tone="muted" size="sm" class="line-clamp-2">{{ item.address }}</Text> <div class="flex-1 min-w-0">
<div class="flex items-center mt-1"> <div class="font-semibold truncate">{{ item.name }}</div>
<span class="text-lg">{{ isoToEmoji(item.countryCode) }}</span> <div class="text-sm text-white/60 line-clamp-2">{{ item.address }}</div>
</div>
</div> </div>
</div> </div>
</Card>
</NuxtLink> </NuxtLink>
</template> </template>
<template #empty> <template #empty>
<EmptyState <div class="text-center py-8">
icon="📍" <div class="text-4xl mb-2">📍</div>
:title="t('profileAddresses.empty.title')" <div class="font-semibold mb-1">{{ t('profileAddresses.empty.title') }}</div>
:description="t('profileAddresses.empty.description')" <div class="text-sm text-white/60 mb-4">{{ t('profileAddresses.empty.description') }}</div>
:action-label="t('profileAddresses.empty.cta')" <NuxtLink :to="localePath('/clientarea/addresses/new')">
:action-to="localePath('/clientarea/addresses/new')" <button class="btn btn-sm bg-white/10 border-white/20 text-white hover:bg-white/20">
action-icon="lucide:plus" <Icon name="lucide:plus" size="14" class="mr-1" />
/> {{ t('profileAddresses.empty.cta') }}
</button>
</NuxtLink>
</div>
</template> </template>
</CatalogPage> </ClientAreaMapPage>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { MapBounds } from '~/components/catalog/CatalogMap.vue'
definePageMeta({ definePageMeta({
layout: 'topnav', layout: 'topnav',
middleware: ['auth-oidc'] middleware: ['auth-oidc']
@@ -76,51 +67,12 @@ const {
init init
} = useTeamAddresses() } = useTeamAddresses()
const selectedAddressId = ref<string>()
const hoveredAddressId = ref<string>() const hoveredAddressId = ref<string>()
// Search bar
const searchQuery = ref('') const searchQuery = ref('')
// Search with map checkbox
const searchWithMap = ref(false)
const currentBounds = ref<MapBounds | null>(null)
// Map items
const itemsWithCoords = computed(() => {
return items.value.filter(addr =>
addr.latitude != null &&
addr.longitude != null &&
!isNaN(Number(addr.latitude)) &&
!isNaN(Number(addr.longitude))
).map(addr => ({
uuid: addr.uuid,
name: addr.name,
latitude: Number(addr.latitude),
longitude: Number(addr.longitude)
}))
})
// Filtered items when searchWithMap is enabled
const displayItems = computed(() => {
if (!searchWithMap.value || !currentBounds.value) return items.value
return items.value.filter(item => {
if (item.latitude == null || item.longitude == null) return false
const { west, east, north, south } = currentBounds.value!
const lng = Number(item.longitude)
const lat = Number(item.latitude)
return lng >= west && lng <= east && lat >= south && lat <= north
})
})
// Search handler
const onSearch = () => {
// TODO: Implement search
}
const onSelectAddress = (item: { uuid?: string | null }) => { const onSelectAddress = (item: { uuid?: string | null }) => {
if (item.uuid) { if (item.uuid) {
selectedAddressId.value = item.uuid navigateTo(localePath(`/clientarea/addresses/${item.uuid}`))
} }
} }

View File

@@ -1,31 +1,25 @@
<template> <template>
<CatalogPage <ClientAreaMapPage
:items="displayItems" :items="listItems"
:map-items="mapPoints"
:loading="isLoading" :loading="isLoading"
with-map
map-id="orders-map" map-id="orders-map"
point-color="#6366f1" point-color="#6366f1"
:selected-id="selectedOrderId"
:hovered-id="hoveredOrderId" :hovered-id="hoveredOrderId"
:total-count="filteredItems.length" :total-count="filteredItems.length"
:title="t('cabinetNav.orders')"
:search-query="searchQuery"
@select="onSelectOrder" @select="onSelectOrder"
@update:hovered-id="hoveredOrderId = $event" @update:hovered-id="hoveredOrderId = $event"
@update:search-query="searchQuery = $event"
> >
<template #searchBar="{ displayedCount, totalCount }"> <template #header>
<CatalogSearchBar <!-- Filter dropdown -->
v-model:search-query="searchQuery" <div class="dropdown dropdown-end">
:active-filters="activeFilterBadges" <label tabindex="0" class="btn btn-sm bg-white/10 border-white/20 text-white hover:bg-white/20">
:displayed-count="displayedCount" <Icon name="lucide:filter" size="14" />
:total-count="totalCount" {{ selectedFilterLabel }}
@remove-filter="onRemoveFilter" </label>
@search="onSearch" <ul tabindex="0" class="dropdown-content menu menu-sm z-50 p-2 shadow bg-base-200 rounded-box w-52 mt-2">
>
<template #filters>
<div class="p-2 space-y-3">
<div>
<div class="text-xs font-semibold mb-1 text-base-content/70">{{ t('ordersList.filters.status') }}</div>
<ul class="menu menu-compact">
<li v-for="filter in filters" :key="filter.id"> <li v-for="filter in filters" :key="filter.id">
<a <a
:class="{ 'active': selectedFilter === filter.id }" :class="{ 'active': selectedFilter === filter.id }"
@@ -34,76 +28,61 @@
</li> </li>
</ul> </ul>
</div> </div>
</div>
</template>
</CatalogSearchBar>
</template> </template>
<template #card="{ item }"> <template #card="{ item }">
<Card padding="lg" class="cursor-pointer"> <div class="bg-white/10 rounded-lg p-4 hover:bg-white/20 transition-colors">
<Stack gap="4"> <div class="flex items-center justify-between mb-2">
<Stack direction="row" justify="between" align="center"> <div>
<Stack gap="1"> <div class="text-xs text-white/60">{{ t('ordersList.card.order_label') }}</div>
<Text size="sm" tone="muted">{{ t('ordersList.card.order_label') }}</Text> <div class="font-semibold">#{{ item.name }}</div>
<Heading :level="3">#{{ item.name }}</Heading> </div>
</Stack> <div class="badge badge-outline text-xs text-white/80 border-white/30">
<div class="badge badge-outline"> {{ getOrderStartDate(item) }}
{{ getOrderStartDate(item) }} {{ getOrderEndDate(item) }} </div>
</div> </div>
</Stack>
<div class="divider my-0"></div> <div class="border-t border-white/10 my-2" />
<Grid :cols="1" :md="3" :gap="3"> <div class="grid grid-cols-2 gap-2 text-sm">
<Stack gap="1"> <div>
<Text size="sm" tone="muted">{{ t('ordersList.card.route') }}</Text> <div class="text-xs text-white/60">{{ t('ordersList.card.route') }}</div>
<Text weight="semibold">{{ item.sourceLocationName }} {{ item.destinationLocationName }}</Text> <div class="truncate">{{ item.sourceLocationName }} {{ item.destinationLocationName }}</div>
</Stack> </div>
<div>
<Stack gap="1"> <div class="text-xs text-white/60">{{ t('ordersList.card.status') }}</div>
<Text size="sm" tone="muted">{{ t('ordersList.card.product') }}</Text> <div class="badge badge-sm" :class="getStatusBadgeClass(item.status)">
<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) }} {{ getStatusText(item.status) }}
</Badge> </div>
<Text tone="muted" size="sm">{{ t('ordersList.card.stages_completed', { done: getCompletedStages(item), total: item.stages?.length || 0 }) }}</Text> </div>
</Stack> </div>
</Grid>
</Stack> <div v-if="item.orderLines?.[0]" class="mt-2 text-sm">
</Card> <div class="text-xs text-white/60">{{ t('ordersList.card.product') }}</div>
<div>
{{ item.orderLines[0].productName }}
<span v-if="item.orderLines.length > 1" class="badge badge-ghost badge-xs ml-1">
+{{ item.orderLines.length - 1 }}
</span>
</div>
</div>
</div>
</template> </template>
<template #empty> <template #empty>
<EmptyState <div class="text-center py-8">
icon="📦" <div class="text-4xl mb-2">📦</div>
:title="t('orders.no_orders')" <div class="font-semibold mb-1">{{ t('orders.no_orders') }}</div>
:description="t('orders.no_orders_desc')" <div class="text-sm text-white/60">{{ t('orders.no_orders_desc') }}</div>
:action-label="t('orders.create_new')" </div>
:action-to="localePath('/clientarea')"
action-icon="lucide:plus"
/>
</template> </template>
</CatalogPage> </ClientAreaMapPage>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { MapBounds } from '~/components/catalog/CatalogMap.vue'
import type { GetTeamOrdersQueryResult } from '~/composables/graphql/team/orders-generated' import type { GetTeamOrdersQueryResult } from '~/composables/graphql/team/orders-generated'
type TeamOrder = NonNullable<NonNullable<GetTeamOrdersQueryResult['getTeamOrders']>[number]> type TeamOrder = NonNullable<NonNullable<GetTeamOrdersQueryResult['getTeamOrders']>[number]>
type TeamOrderStage = NonNullable<NonNullable<TeamOrder['stages']>[number]>
definePageMeta({ definePageMeta({
layout: 'topnav', layout: 'topnav',
@@ -123,19 +102,18 @@ const {
getStatusText getStatusText
} = useTeamOrders() } = useTeamOrders()
const selectedOrderId = ref<string>()
const hoveredOrderId = ref<string>() const hoveredOrderId = ref<string>()
// Search bar
const searchQuery = ref('') const searchQuery = ref('')
// Search with map checkbox // Selected filter label
const searchWithMap = ref(false) const selectedFilterLabel = computed(() => {
const currentBounds = ref<MapBounds | null>(null) const filter = filters.value.find(f => f.id === selectedFilter.value)
return filter?.label || t('ordersList.filters.status')
})
// List items - one per order // List items - one per order
const listItems = computed(() => { const listItems = computed(() => {
return filteredItems.value let items = filteredItems.value
.filter(order => order.uuid) .filter(order => order.uuid)
.map(order => ({ .map(order => ({
...order, ...order,
@@ -145,79 +123,22 @@ const listItems = computed(() => {
longitude: order.sourceLongitude, longitude: order.sourceLongitude,
country: order.sourceLocationName country: order.sourceLocationName
})) }))
})
// Map points - two per order (source + destination) // Apply search filter
interface MapPoint { if (searchQuery.value) {
uuid: string const query = searchQuery.value.toLowerCase()
name: string items = items.filter(item =>
latitude: number item.name?.toLowerCase().includes(query) ||
longitude: number item.sourceLocationName?.toLowerCase().includes(query) ||
item.destinationLocationName?.toLowerCase().includes(query)
)
} }
const mapPoints = computed(() => { return items
const result: MapPoint[] = []
filteredItems.value.forEach(order => {
// Source point
if (order.sourceLatitude && order.sourceLongitude) {
result.push({
uuid: `${order.uuid}-source`,
name: `📦 ${order.sourceLocationName}`,
latitude: order.sourceLatitude,
longitude: order.sourceLongitude
}) })
}
// Destination point - get from last stage
const lastStage = order.stages?.[order.stages.length - 1]
if (lastStage?.destinationLatitude && lastStage?.destinationLongitude) {
result.push({
uuid: `${order.uuid}-dest`,
name: `🏁 ${order.destinationLocationName}`,
latitude: lastStage.destinationLatitude,
longitude: lastStage.destinationLongitude
})
}
})
return result
})
// Filtered items when searchWithMap is enabled
const displayItems = computed(() => {
if (!searchWithMap.value || !currentBounds.value) return listItems.value
return listItems.value.filter(item => {
if (item.latitude == null || item.longitude == null) return false
const { west, east, north, south } = currentBounds.value!
const lng = Number(item.longitude)
const lat = Number(item.latitude)
return lng >= west && lng <= east && lat >= south && lat <= north
})
})
// Active filter badges
const activeFilterBadges = computed(() => {
const badges: { id: string; label: string }[] = []
if (selectedFilter.value && selectedFilter.value !== 'all') {
const filter = filters.value.find(f => f.id === selectedFilter.value)
if (filter) badges.push({ id: `status:${filter.id}`, label: filter.label })
}
return badges
})
// Remove filter badge
const onRemoveFilter = (id: string) => {
if (id.startsWith('status:')) {
selectedFilter.value = 'all'
}
}
// Search handler
const onSearch = () => {
// TODO: Implement search
}
const onSelectOrder = (item: { uuid?: string | null }) => { const onSelectOrder = (item: { uuid?: string | null }) => {
if (item.uuid) { if (item.uuid) {
selectedOrderId.value = item.uuid
navigateTo(localePath(`/clientarea/orders/${item.uuid}`)) navigateTo(localePath(`/clientarea/orders/${item.uuid}`))
} }
} }
@@ -229,35 +150,15 @@ const getOrderStartDate = (order: TeamOrder) => {
return formatDate(order.createdAt) return formatDate(order.createdAt)
} }
const getOrderEndDate = (order: TeamOrder) => { const getStatusBadgeClass = (status?: string) => {
let latestDate: Date | null = null const variant = getStatusVariant(status)
order.stages?.forEach((stage) => { switch (variant) {
if (!stage) return case 'success': return 'badge-success'
stage.trips?.forEach((trip) => { case 'warning': return 'badge-warning'
if (!trip) return case 'error': return 'badge-error'
const endDate = trip.actualUnloadingDate || trip.plannedUnloadingDate default: return 'badge-ghost'
if (endDate) {
const date = new Date(endDate)
if (!latestDate || date > latestDate) {
latestDate = date
} }
} }
})
})
if (latestDate) return formatDate((latestDate as Date).toISOString())
if (order.createdAt) {
const fallbackDate = new Date(order.createdAt)
fallbackDate.setMonth(fallbackDate.getMonth() + 1)
return formatDate(fallbackDate.toISOString())
}
return t('ordersDetail.labels.dates_undefined')
}
const getCompletedStages = (order: TeamOrder) => {
if (!order.stages?.length) return 0
// Note: StageType doesn't have a status field, count all stages for now
return order.stages.filter((stage): stage is TeamOrderStage => stage !== null).length
}
const formatDate = (date: string) => { const formatDate = (date: string) => {
if (!date) return t('ordersDetail.labels.dates_undefined') if (!date) return t('ordersDetail.labels.dates_undefined')
@@ -266,8 +167,7 @@ const formatDate = (date: string) => {
if (isNaN(dateObj.getTime())) return t('ordersDetail.labels.dates_undefined') if (isNaN(dateObj.getTime())) return t('ordersDetail.labels.dates_undefined')
return new Intl.DateTimeFormat('ru-RU', { return new Intl.DateTimeFormat('ru-RU', {
day: 'numeric', day: 'numeric',
month: 'long', month: 'short'
year: 'numeric'
}).format(dateObj) }).format(dateObj)
} catch { } catch {
return t('ordersDetail.labels.dates_undefined') return t('ordersDetail.labels.dates_undefined')