From 7bd4aa37bd823f401658306165917276ed53036e Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Tue, 27 Jan 2026 10:49:58 +0700 Subject: [PATCH] Redesign SupplierCard and ProductCard, unify components - SupplierCard: horizontal layout with logo left, verified badge before name, chips at bottom - ProductCard: add optional sparkline background, trend indicator, and price display - Replace HubProductCard usage with ProductCard in hub detail page - Remove HubProductCard.vue and PriceSparkline.vue (unified into ProductCard) --- app/components/catalog/HubProductCard.vue | 112 ---------------------- app/components/catalog/PriceSparkline.vue | 61 ------------ app/components/catalog/ProductCard.vue | 109 +++++++++++++++++++-- app/components/catalog/SupplierCard.vue | 50 ++++++---- app/pages/catalog/hubs/[id]/index.vue | 5 +- 5 files changed, 134 insertions(+), 203 deletions(-) delete mode 100644 app/components/catalog/HubProductCard.vue delete mode 100644 app/components/catalog/PriceSparkline.vue diff --git a/app/components/catalog/HubProductCard.vue b/app/components/catalog/HubProductCard.vue deleted file mode 100644 index 657f71b..0000000 --- a/app/components/catalog/HubProductCard.vue +++ /dev/null @@ -1,112 +0,0 @@ - - - diff --git a/app/components/catalog/PriceSparkline.vue b/app/components/catalog/PriceSparkline.vue deleted file mode 100644 index b1afb82..0000000 --- a/app/components/catalog/PriceSparkline.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - diff --git a/app/components/catalog/ProductCard.vue b/app/components/catalog/ProductCard.vue index fbcc594..1dcb63a 100644 --- a/app/components/catalog/ProductCard.vue +++ b/app/components/catalog/ProductCard.vue @@ -9,17 +9,49 @@ - - {{ product.name }} - - {{ product.offersCount }} {{ t('catalog.offers', product.offersCount) }} + +
+ + + +
+ + +
+
+ {{ product.name }} + + {{ trend > 0 ? '↑' : '↓' }} {{ Math.abs(trend) }}% + +
+ +
+ + {{ product.offersCount }} {{ t('catalog.offers', product.offersCount) }} + + + {{ formattedPrice }} + +
+ + + {{ product.description }} - {{ product.description }} - +
@@ -34,12 +66,17 @@ interface Product { offersCount?: number | null } -const props = defineProps<{ +const props = withDefaults(defineProps<{ product: Product selectable?: boolean isSelected?: boolean compact?: boolean -}>() + priceHistory?: number[] + currentPrice?: number | null + currency?: string | null +}>(), { + priceHistory: () => [] +}) defineEmits<{ (e: 'select'): void @@ -49,4 +86,60 @@ const localePath = useLocalePath() const { t } = useI18n() const linkable = computed(() => !props.selectable && !!props.product.uuid) + +// Price formatting +const formattedPrice = computed(() => { + if (!props.currentPrice) return '' + const symbol = getCurrencySymbol(props.currency) + return `${symbol}${props.currentPrice.toLocaleString()}` +}) + +const getCurrencySymbol = (currency?: string | null) => { + switch (currency?.toUpperCase()) { + case 'USD': return '$' + case 'EUR': return '€' + case 'RUB': return '₽' + case 'CNY': return '¥' + default: return '$' + } +} + +// Calculate trend from price history +const trend = computed(() => { + if (!props.priceHistory || props.priceHistory.length < 2) return 0 + const first = props.priceHistory[0] + const last = props.priceHistory[props.priceHistory.length - 1] + if (!first || first === 0 || !last) return 0 + return Math.round(((last - first) / first) * 100) +}) + +// Chart configuration +const chartOptions = computed(() => ({ + chart: { + type: 'area', + sparkline: { enabled: true }, + animations: { enabled: false } + }, + stroke: { + curve: 'smooth', + width: 2 + }, + fill: { + type: 'gradient', + gradient: { + shadeIntensity: 1, + opacityFrom: 0.4, + opacityTo: 0.1 + } + }, + colors: [trend.value >= 0 ? '#22c55e' : '#ef4444'], + tooltip: { enabled: false }, + xaxis: { labels: { show: false } }, + yaxis: { labels: { show: false } } +})) + +const chartSeries = computed(() => [{ + name: 'Price', + data: props.priceHistory && props.priceHistory.length > 0 ? props.priceHistory : [0] +}]) diff --git a/app/components/catalog/SupplierCard.vue b/app/components/catalog/SupplierCard.vue index e305e8c..31ba939 100644 --- a/app/components/catalog/SupplierCard.vue +++ b/app/components/catalog/SupplierCard.vue @@ -9,35 +9,45 @@ - - - {{ t('catalogSupplier.badges.verified') }} - -
- -
- +
+ +
+ +
+ +
+
+ {{ supplier.name?.charAt(0) }} +
+ + +
+ +
+ + + + + + {{ supplier.name }} +
+ + + {{ countryFlag }} {{ supplier.country || t('catalogMap.labels.country_unknown') }} + +
-
- {{ supplier.name?.charAt(0) }} -
- - {{ supplier.name }} - + +
- + {{ reliabilityLabel }}
- - - {{ countryFlag }} {{ supplier.country || t('catalogMap.labels.country_unknown') }} -
diff --git a/app/pages/catalog/hubs/[id]/index.vue b/app/pages/catalog/hubs/[id]/index.vue index 6fec7e1..e22dc36 100644 --- a/app/pages/catalog/hubs/[id]/index.vue +++ b/app/pages/catalog/hubs/[id]/index.vue @@ -26,9 +26,10 @@