Files
CRM_Montzar/apps/web/src/components/dashboard/HomeTopCustomers.vue
T

106 lines
1.9 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { toFaDigits } from '@/lib/jalali';
import type { HomeDashboardTopCustomerDto } from '@mento/shared';
defineProps<{
customers: HomeDashboardTopCustomerDto[];
}>();
function trophy(rank: number) {
if (rank === 1) return '🥇';
if (rank === 2) return '🥈';
if (rank === 3) return '🥉';
return `#${toFaDigits(rank)}`;
}
</script>
<template>
<article class="panel">
<header class="panel-head">
<h2>مشتریان برتر</h2>
</header>
<ul v-if="customers.length" class="top-list">
<li v-for="row in customers" :key="row.id">
<span class="cust-avatar">{{ row.name.slice(0, 1) }}</span>
<div>
<strong>{{ row.name }}</strong>
<span>{{ toFaDigits(row.dealCount) }} معامله</span>
</div>
<span class="rank">{{ trophy(row.rank) }}</span>
</li>
</ul>
<p v-else class="muted">هنوز داده کافی برای رتبه‌بندی نیست.</p>
</article>
</template>
<style scoped>
.panel {
background: #fff;
border-radius: 22px;
padding: 1.05rem 1.1rem;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
border: 1px solid #eef2f7;
min-width: 0;
}
.panel-head {
margin-bottom: 0.85rem;
}
h2 {
margin: 0;
font-size: 0.98rem;
}
.top-list {
list-style: none;
margin: 0;
padding: 0;
display: grid;
gap: 0.75rem;
}
.top-list li {
display: flex;
align-items: center;
gap: 0.7rem;
}
.cust-avatar {
width: 40px;
height: 40px;
border-radius: 14px;
background: linear-gradient(145deg, #ccfbf1, #99f6e4);
color: #0f766e;
display: grid;
place-items: center;
font-weight: 800;
flex-shrink: 0;
}
.top-list div {
flex: 1;
min-width: 0;
display: grid;
gap: 0.12rem;
}
.top-list strong {
font-size: 0.88rem;
}
.top-list span {
color: #94a3b8;
font-size: 0.74rem;
}
.rank {
font-size: 1.2rem;
}
.muted {
color: #94a3b8;
}
</style>