Files
webapp/app/components/catalog/CatalogOffersSection.vue
Ruslan Bakiev e4f81dba7c
All checks were successful
Build Docker Image / build (push) Successful in 4m53s
Redesign offer result card layout
2026-02-06 17:07:38 +07:00

85 lines
2.5 KiB
Vue

<template>
<Section variant="plain" paddingY="md">
<Stack gap="4">
<Stack direction="row" align="center" justify="between">
<Heading :level="2">{{ t('catalogOffersSection.header.title') }}</Heading>
<NuxtLink
:to="localePath('/catalog?select=product')"
class="btn btn-sm btn-ghost"
>
<span>{{ t('catalogOffersSection.actions.view_all') }}</span>
<Icon name="lucide:arrow-right" size="16" />
</NuxtLink>
</Stack>
<Grid :cols="1" :md="2" :lg="3" :gap="4">
<OfferResultCard
v-for="(offer, index) in offersWithPrice"
:key="offer.uuid ?? index"
:supplier-name="offer.supplierName"
:location-name="offer.locationName"
:product-name="offer.title || undefined"
:price-per-unit="offer.pricePerUnit ? Number(offer.pricePerUnit) : null"
:quantity="offer.quantity"
:currency="offer.currency"
:unit="offer.unit"
:stages="[]"
/>
</Grid>
<Stack v-if="totalOffers > 0" direction="row" align="center" justify="between">
<Text tone="muted">
{{ t('common.pagination.showing', { shown: offersWithPrice.length, total: totalOffers }) }}
</Text>
<Button v-if="canLoadMore" variant="outline" @click="loadMore">
{{ t('common.actions.load_more') }}
</Button>
</Stack>
<Stack v-if="offersWithPrice.length === 0" align="center" gap="2">
<Text tone="muted">{{ t('catalogOffersSection.empty.no_offers') }}</Text>
</Stack>
</Stack>
</Section>
</template>
<script setup lang="ts">
interface OfferLine {
uuid?: string | null
productName?: string | null
}
interface Offer {
uuid?: string | null
title?: string | null
locationName?: string | null
supplierName?: string | null
status?: string | null
validUntil?: string | null
lines?: (OfferLine | null)[] | null
quantity?: number | string | null
pricePerUnit?: number | string | null
currency?: string | null
unit?: string | null
}
const props = defineProps<{
offers: Offer[]
total?: number
canLoadMore?: boolean
onLoadMore?: () => void
}>()
const localePath = useLocalePath()
const { t } = useI18n()
const offersWithPrice = computed(() =>
(props.offers || []).filter(o => o?.pricePerUnit != null)
)
const totalOffers = computed(() => props.total ?? offersWithPrice.value.length)
const canLoadMore = computed(() => props.canLoadMore ?? false)
const loadMore = () => {
props.onLoadMore?.()
}
</script>