feat(ui): redesign GlobalSearchBar, split layouts, and remove hero section
All checks were successful
Build Docker Image / build (push) Successful in 5m25s

- Make GlobalSearchBar functional with searchStore integration
- Add destination search using hubs/nodes GraphQL query
- Navigate to /request page instead of /catalog/offers
- Remove hero section from index.vue (search is now in header)
- Add padding (px-3 lg:px-6) to topnav layout
- Implement split layout for catalog pages (offers, hubs, suppliers)
  - Left side: filters + scrollable card list (40%)
  - Right side: map (60%, hidden on mobile)
This commit is contained in:
Ruslan Bakiev
2026-01-08 08:13:22 +07:00
parent 1e179ab04c
commit 1a2693bcd6
6 changed files with 194 additions and 254 deletions

View File

@@ -68,10 +68,10 @@
@input="searchDestinations"
/>
<ul
v-if="showDestinationDropdown && destinations.length > 0"
v-if="showDestinationDropdown && filteredDestinations.length > 0"
class="dropdown-content menu bg-base-100 rounded-box z-50 w-64 max-h-60 overflow-auto p-2 shadow-lg border border-base-300 mt-2"
>
<li v-for="dest in destinations" :key="dest.uuid">
<li v-for="dest in filteredDestinations" :key="dest.uuid">
<a @click="selectDestination(dest)">
{{ dest.name }}
<span class="text-xs text-base-content/50">{{ dest.country }}</span>
@@ -101,6 +101,8 @@ const emit = defineEmits<{
const router = useRouter()
const localePath = useLocalePath()
const searchStore = useSearchStore()
const { execute } = useGraphQL()
// Product search
const productQuery = ref('')
@@ -125,53 +127,74 @@ const selectProduct = (product: typeof selectedProduct.value) => {
selectedProduct.value = product
productQuery.value = product?.name || ''
showProductDropdown.value = false
// Sync to searchStore
searchStore.setProduct(product?.name || '')
searchStore.setProductUuid(product?.uuid || '')
}
// Quantity
const quantity = ref<number | undefined>()
const unit = ref('t')
// Destination search
// Destination search (using hubs/nodes)
const destinationQuery = ref('')
const selectedDestination = ref<{ uuid: string; name: string; country?: string } | null>(null)
const showDestinationDropdown = ref(false)
const destinations = ref<Array<{ uuid: string; name: string; country?: string }>>([])
const allDestinations = ref<Array<{ uuid: string; name: string; country?: string }>>([])
const searchDestinations = async () => {
const filteredDestinations = computed(() => {
if (!destinationQuery.value) return allDestinations.value.slice(0, 10)
const q = destinationQuery.value.toLowerCase()
return allDestinations.value.filter(d =>
d.name?.toLowerCase().includes(q) ||
d.country?.toLowerCase().includes(q)
).slice(0, 10)
})
const searchDestinations = () => {
showDestinationDropdown.value = true
// TODO: implement destination search via GraphQL
}
const selectDestination = (dest: typeof selectedDestination.value) => {
selectedDestination.value = dest
destinationQuery.value = dest?.name || ''
showDestinationDropdown.value = false
// Sync to searchStore
searchStore.setLocation(dest?.name || '')
searchStore.setLocationUuid(dest?.uuid || '')
}
// Can search
// Can search - need at least product selected
const canSearch = computed(() => {
return !!selectedProduct.value
})
// Search handler
// Search handler - navigate to /request like the old search form
const handleSearch = () => {
if (!canSearch.value) return
const params: Record<string, string> = {}
if (selectedProduct.value?.uuid) {
params.product = selectedProduct.value.uuid
}
// Sync quantity to store
if (quantity.value) {
params.quantity = String(quantity.value)
params.unit = unit.value
}
if (selectedDestination.value?.uuid) {
params.destination = selectedDestination.value.uuid
searchStore.setQuantity(String(quantity.value))
searchStore.setUnit(unit.value)
}
const query: Record<string, string | undefined> = {
productUuid: selectedProduct.value?.uuid,
product: selectedProduct.value?.name,
quantity: quantity.value ? String(quantity.value) : undefined,
locationUuid: selectedDestination.value?.uuid,
location: selectedDestination.value?.name
}
// Remove undefined values
Object.keys(query).forEach(key => {
if (query[key] === undefined) delete query[key]
})
router.push({
path: localePath('/catalog/offers'),
query: params
path: localePath('/request'),
query: query as Record<string, string>
})
emit('search', {
@@ -185,15 +208,29 @@ const handleSearch = () => {
// Load products on mount
onMounted(async () => {
try {
const { query } = useGraphQL()
const { GetProductsDocument } = await import('~/composables/graphql/public/exchange-generated')
const result = await query(GetProductsDocument, {}, 'exchange', 'public')
allProducts.value = result.getProducts || []
const result = await execute(GetProductsDocument, {}, 'public', 'exchange')
allProducts.value = result?.getProducts || []
} catch (error) {
console.error('Failed to load products:', error)
}
})
// Load destinations (hubs/nodes) on mount
onMounted(async () => {
try {
const { GetNodesDocument } = await import('~/composables/graphql/public/geo-generated')
const result = await execute(GetNodesDocument, { limit: 100, offset: 0 }, 'public', 'geo')
allDestinations.value = (result?.nodes || []).filter((n: any) => n?.uuid && n?.name).map((n: any) => ({
uuid: n.uuid,
name: n.name,
country: n.country
}))
} catch (error) {
console.error('Failed to load destinations:', error)
}
})
// Close dropdowns on click outside
onMounted(() => {
const handler = (e: MouseEvent) => {