Initial commit: fabric-trade-user Vue 3 app with mobile and desktop layouts

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 09:57:24 +02:00
co-authored by Cursor
commit fd3e5e5126
142 changed files with 19798 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useCatalogStore } from '@/stores/catalog'
import { useCartStore } from '@/stores/cart'
import BaseButton from '@/components/ui/BaseButton.vue'
import IconParLogo from '@/components/icons/IconParLogo.vue'
import IconFamBaftLogo from '@/components/icons/IconFamBaftLogo.vue'
import MobileCompanySelect from '@/views/companies/components/MobileCompanySelect.vue'
import DesktopHomeDashboard from '@/views/companies/components/DesktopHomeDashboard.vue'
import type { Company } from '@/types'
const router = useRouter()
const catalogStore = useCatalogStore()
const cartStore = useCartStore()
const companies = catalogStore.getActiveCompanies()
const showSwitchDialog = ref(false)
const pendingCompanyId = ref<string | null>(null)
const switchMessage = ref('')
const displayMeta: Record<string, { description: string; logo: typeof IconParLogo }> = {
par: { description: 'تولید و عرضه انواع پارچه', logo: IconParLogo },
'fam-baft': { description: 'تولید و عرضه انواع پارچه', logo: IconFamBaftLogo },
}
function selectCompany(companyId: string) {
const check = cartStore.canSwitchToCompany(companyId)
if (!check.allowed) {
pendingCompanyId.value = companyId
switchMessage.value = check.message ?? ''
showSwitchDialog.value = true
return
}
goToCompany(companyId)
}
function goToCompany(companyId: string) {
const company = catalogStore.getCompany(companyId)
if (!company) return
cartStore.initCartForCompany(company)
router.push(`/companies/${companyId}/catalogs`)
}
function confirmSwitch() {
if (pendingCompanyId.value) {
goToCompany(pendingCompanyId.value)
}
showSwitchDialog.value = false
}
function cardVariant(slug: string) {
return slug === 'par' ? 'par' : 'fam-baft'
}
function companyDescription(company: Company) {
return displayMeta[company.slug]?.description ?? company.description
}
function companyLogo(slug: string) {
return displayMeta[slug]?.logo ?? IconParLogo
}
</script>
<template>
<MobileCompanySelect
class="mobile-only"
:companies="companies"
:card-variant="cardVariant"
:company-description="companyDescription"
:company-logo="companyLogo"
@select="selectCompany"
/>
<DesktopHomeDashboard
class="desktop-only"
:companies="companies"
:card-variant="cardVariant"
:company-description="companyDescription"
:company-logo="companyLogo"
@select="selectCompany"
/>
<div v-if="showSwitchDialog" class="dialog-overlay" @click.self="showSwitchDialog = false">
<div class="dialog card">
<h3>تغییر شرکت</h3>
<p class="text-sm">{{ switchMessage }}</p>
<div class="dialog-actions">
<BaseButton variant="outline" @click="showSwitchDialog = false">انصراف</BaseButton>
<BaseButton @click="confirmSwitch">سبد جدید</BaseButton>
</div>
</div>
</div>
</template>
<style scoped>
.dialog h3 {
margin: 0 0 12px;
}
@media (min-width: 768px) {
.dialog-actions {
flex-direction: row;
justify-content: flex-end;
}
}
</style>
@@ -0,0 +1,102 @@
<script setup lang="ts">
import type { Company } from '@/types'
import type { Component } from 'vue'
defineProps<{
companies: Company[]
cardVariant: (slug: string) => string
companyDescription: (company: Company) => string
companyLogo: (slug: string) => Component
}>()
defineEmits<{
select: [companyId: string]
}>()
</script>
<template>
<div class="desktop-page company-desktop-page">
<header class="desktop-page__head">
<h1 class="desktop-page__title">انتخاب شرکت</h1>
<p class="desktop-page__subtitle">شرکت مورد نظر خود را انتخاب کنید</p>
</header>
<div class="desktop-company-grid">
<button
v-for="company in companies"
:key="company.id"
type="button"
class="company-brand-card"
:class="`company-brand-card--${cardVariant(company.slug)}`"
@click="$emit('select', company.id)"
>
<span class="company-brand-card__logo">
<component :is="companyLogo(company.slug)" :size="80" />
</span>
<h2 class="company-brand-card__name">{{ company.name }}</h2>
<p class="company-brand-card__desc">{{ companyDescription(company) }}</p>
</button>
</div>
</div>
</template>
<style scoped>
.company-desktop-page {
justify-content: flex-start;
}
.company-brand-card {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 240px;
padding: 36px 28px;
border: none;
border-radius: var(--radius-lg);
cursor: pointer;
text-align: center;
transition: transform 0.15s, box-shadow 0.15s;
}
.company-brand-card:hover {
transform: translateY(-2px);
}
.company-brand-card--par {
background: var(--color-primary);
color: #fff;
box-shadow: var(--shadow-md);
}
.company-brand-card--fam-baft {
background: #f3ece3;
color: #1a202c;
box-shadow: var(--shadow-sm);
}
.company-brand-card__logo {
margin-bottom: 18px;
}
.company-brand-card__name {
margin: 0 0 8px;
font-size: 1.125rem;
font-weight: 700;
}
.company-brand-card__desc {
margin: 0;
font-size: 0.875rem;
max-width: 280px;
line-height: 1.6;
}
.company-brand-card--par .company-brand-card__desc {
color: rgba(255, 255, 255, 0.85);
}
.company-brand-card--fam-baft .company-brand-card__desc {
color: #718096;
}
</style>
@@ -0,0 +1,573 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import IconChevronLeft from '@/components/icons/IconChevronLeft.vue'
import IconHome from '@/components/icons/IconHome.vue'
import IconCatalog from '@/components/icons/IconCatalog.vue'
import IconCart from '@/components/icons/IconCart.vue'
import IconOrders from '@/components/icons/IconOrders.vue'
import IconShoppingBag from '@/components/icons/IconShoppingBag.vue'
import IconBuilding from '@/components/icons/IconBuilding.vue'
import IconLayoutGrid from '@/components/icons/IconLayoutGrid.vue'
import type { Company } from '@/types'
import type { Component } from 'vue'
const props = defineProps<{
companies: Company[]
cardVariant: (slug: string) => string
companyDescription: (company: Company) => string
companyLogo: (slug: string) => Component
}>()
const emit = defineEmits<{ select: [companyId: string] }>()
const router = useRouter()
const displayCompanies = computed(() =>
[...props.companies].sort((a, b) => {
if (a.slug === 'fam-baft') return -1
if (b.slug === 'fam-baft') return 1
return 0
}),
)
const quickLinks = [
{
label: 'انتخاب شرکت',
icon: IconHome,
path: '/',
tone: 'orange',
},
{
label: 'سفارش‌گذاری',
icon: IconCatalog,
path: '/',
tone: 'blue',
},
{
label: 'سبد خرید',
icon: IconCart,
path: '/cart',
tone: 'green',
},
{
label: 'سفارش‌های من',
icon: IconOrders,
path: '/orders',
tone: 'purple',
},
]
const orderSteps = [
{ id: 1, label: 'انتخاب شرکت', icon: IconBuilding, active: true },
{ id: 2, label: 'انتخاب کالیته', icon: IconLayoutGrid, active: false },
{ id: 3, label: 'ثبت سفارش', icon: IconOrders, active: false },
]
const currentStep = 1
</script>
<template>
<div class="desktop-page home-dashboard">
<header class="home-dashboard__head">
<h1 class="home-dashboard__title">انتخاب شرکت</h1>
<p class="home-dashboard__subtitle">شرکت موردنظر خود را برای شروع سفارش‌گذاری انتخاب کنید</p>
</header>
<section class="welcome-banner" aria-label="خوش‌آمدگویی">
<div class="welcome-banner__visual" aria-hidden="true">
<div class="welcome-banner__fabric">
<span class="welcome-banner__roll welcome-banner__roll--1" />
<span class="welcome-banner__roll welcome-banner__roll--2" />
</div>
</div>
<div class="welcome-banner__content">
<h2 class="welcome-banner__heading">به پارس بافت خوش آمدید</h2>
<p class="welcome-banner__text">
برای شروع سفارش، ابتدا شرکت موردنظر را انتخاب کنید و سپس کالیته و محصولات را اضافه
کنید.
</p>
</div>
<div class="welcome-banner__icon" aria-hidden="true">
<IconShoppingBag :size="26" />
</div>
</section>
<div class="home-dashboard__companies">
<article
v-for="company in displayCompanies"
:key="company.id"
class="company-showcase"
:class="`company-showcase--${cardVariant(company.slug)}`"
>
<div class="company-showcase__pattern" aria-hidden="true" />
<div class="company-showcase__body">
<span class="company-showcase__logo">
<component :is="companyLogo(company.slug)" :size="72" />
</span>
<h3 class="company-showcase__name">{{ company.name }}</h3>
<p class="company-showcase__desc">{{ companyDescription(company) }}</p>
<button
type="button"
class="company-showcase__cta"
@click="emit('select', company.id)"
>
<span class="company-showcase__cta-text">ورود به کاتالوگ‌ها</span>
<IconChevronLeft :size="16" class="company-showcase__cta-icon" aria-hidden="true" />
</button>
</div>
</article>
</div>
<div class="home-dashboard__bottom">
<section class="home-panel home-panel--quick">
<h3 class="home-panel__title">دسترسی سریع</h3>
<div class="quick-access">
<button
v-for="link in quickLinks"
:key="link.label"
type="button"
class="quick-access__item"
@click="router.push(link.path)"
>
<span class="quick-access__icon" :class="`quick-access__icon--${link.tone}`">
<component :is="link.icon" :size="22" />
</span>
<span class="quick-access__label">{{ link.label }}</span>
</button>
</div>
</section>
<section class="home-panel home-panel--steps">
<h3 class="home-panel__title">مراحل ثبت سفارش</h3>
<ol class="order-steps">
<template v-for="(step, index) in orderSteps" :key="step.id">
<li
class="order-step"
:class="{ 'order-step--active': step.id === currentStep }"
>
<span class="order-step__dot">{{ step.id }}</span>
<span class="order-step__icon">
<component :is="step.icon" :size="18" />
</span>
<span class="order-step__label">{{ step.label }}</span>
</li>
<li
v-if="index < orderSteps.length - 1"
class="order-step-bridge"
aria-hidden="true"
>
<span
class="order-step-bridge__line"
:class="{ 'order-step-bridge__line--done': index < currentStep }"
/>
</li>
</template>
</ol>
</section>
</div>
</div>
</template>
<style scoped>
.home-dashboard {
max-width: 980px;
margin-inline: auto;
padding-bottom: 32px;
}
.home-dashboard__head {
text-align: center;
margin-bottom: 24px;
}
.home-dashboard__title {
margin: 0 0 8px;
font-size: 1.5rem;
font-weight: 700;
color: var(--color-primary);
}
.home-dashboard__subtitle {
margin: 0;
font-size: 0.875rem;
color: var(--color-text-muted);
}
.welcome-banner {
direction: ltr;
display: grid;
grid-template-columns: 132px 1fr 56px;
align-items: center;
gap: 20px;
padding: 18px 22px;
margin-bottom: 24px;
background: linear-gradient(90deg, #fff 0%, #fff 58%, var(--color-primary-soft) 58%);
border: 1px solid var(--color-border);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-card);
}
.welcome-banner__visual {
justify-self: start;
}
.welcome-banner__fabric {
position: relative;
width: 112px;
height: 72px;
}
.welcome-banner__roll {
position: absolute;
bottom: 4px;
border-radius: 999px 999px 6px 6px;
background: linear-gradient(180deg, #dbeafe 0%, #93c5fd 55%, #60a5fa 100%);
box-shadow: inset 0 -4px 0 rgba(29, 53, 87, 0.08);
}
.welcome-banner__roll--1 {
width: 36px;
height: 52px;
left: 8px;
z-index: 2;
}
.welcome-banner__roll--2 {
width: 30px;
height: 44px;
left: 44px;
background: linear-gradient(180deg, #e2e8f0 0%, #94a3b8 55%, #64748b 100%);
z-index: 1;
}
.welcome-banner__content {
direction: rtl;
text-align: right;
}
.welcome-banner__heading {
margin: 0 0 6px;
font-size: 1rem;
font-weight: 700;
color: var(--color-text);
}
.welcome-banner__text {
margin: 0;
font-size: 0.8125rem;
color: var(--color-text-muted);
line-height: 1.65;
max-width: 460px;
}
.welcome-banner__icon {
justify-self: end;
width: 52px;
height: 52px;
border-radius: 50%;
background: var(--color-primary);
color: #fff;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.home-dashboard__companies {
direction: ltr;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 20px;
margin-bottom: 24px;
}
.company-showcase {
position: relative;
border-radius: 20px;
overflow: hidden;
min-height: 292px;
box-shadow: var(--shadow-md);
}
.company-showcase__pattern {
position: absolute;
inset: 0;
pointer-events: none;
}
.company-showcase--par {
background: #17379f;
color: #fff;
}
.company-showcase--par .company-showcase__pattern {
opacity: 0.22;
background:
radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.18) 0%, transparent 42%),
radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.12) 0%, transparent 38%),
repeating-linear-gradient(
115deg,
transparent,
transparent 14px,
rgba(255, 255, 255, 0.07) 14px,
rgba(255, 255, 255, 0.07) 28px
);
}
.company-showcase--fam-baft {
background: #f3ece3;
color: #1a202c;
}
.company-showcase--fam-baft .company-showcase__pattern {
opacity: 0.35;
background: repeating-linear-gradient(
45deg,
transparent,
transparent 8px,
rgba(0, 0, 0, 0.025) 8px,
rgba(0, 0, 0, 0.025) 16px
);
}
.company-showcase__body {
direction: rtl;
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 34px 24px 28px;
height: 100%;
}
.company-showcase__logo {
margin-bottom: 16px;
}
.company-showcase__name {
margin: 0 0 8px;
font-size: 1.25rem;
font-weight: 700;
}
.company-showcase__desc {
margin: 0 0 22px;
font-size: 0.8125rem;
line-height: 1.65;
max-width: 260px;
flex: 1;
}
.company-showcase--par .company-showcase__desc {
color: rgba(255, 255, 255, 0.88);
}
.company-showcase--fam-baft .company-showcase__desc {
color: #718096;
}
.company-showcase__cta {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 11px 22px;
border: none;
border-radius: 999px;
font-family: inherit;
font-size: 0.875rem;
font-weight: 600;
cursor: pointer;
transition: opacity 0.15s;
}
.company-showcase--par .company-showcase__cta {
background: #fff;
color: var(--color-primary);
}
.company-showcase--fam-baft .company-showcase__cta {
background: #c9b896;
color: #1a202c;
}
.company-showcase__cta:hover {
opacity: 0.92;
}
.company-showcase__cta-icon {
flex-shrink: 0;
}
.home-dashboard__bottom {
direction: ltr;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 20px;
}
.home-panel {
direction: rtl;
padding: 20px;
background: var(--color-surface);
border: 1px solid var(--color-border);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-card);
}
.home-panel__title {
margin: 0 0 16px;
font-size: 0.9375rem;
font-weight: 700;
color: var(--color-text);
}
.quick-access {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 10px;
}
.quick-access__item {
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
padding: 4px 6px 0;
border: none;
background: none;
cursor: pointer;
font-family: inherit;
}
.quick-access__icon {
width: 46px;
height: 46px;
border-radius: 14px;
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.15s;
}
.quick-access__item:hover .quick-access__icon {
transform: translateY(-2px);
}
.quick-access__icon--orange {
background: #fff4e5;
color: #ea580c;
}
.quick-access__icon--blue {
background: var(--color-primary-soft);
color: var(--color-primary);
}
.quick-access__icon--green {
background: var(--color-success-soft);
color: var(--color-success);
}
.quick-access__icon--purple {
background: var(--color-purple-light);
color: var(--color-purple);
}
.quick-access__label {
font-size: 0.6875rem;
font-weight: 600;
color: var(--color-text);
text-align: center;
line-height: 1.35;
}
.order-steps {
direction: rtl;
display: flex;
align-items: flex-start;
margin: 0;
padding: 0;
list-style: none;
}
.order-step {
flex: 1 1 0;
min-width: 0;
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
text-align: center;
}
.order-step-bridge {
flex: 1 1 0;
min-width: 16px;
list-style: none;
height: 28px;
display: flex;
align-items: center;
padding: 0;
margin: 0;
}
.order-step-bridge__line {
display: block;
width: 100%;
height: 0;
border-top: 2px dashed var(--color-border);
}
.order-step-bridge__line--done {
border-top-color: #93a8e8;
}
.order-step__dot {
width: 28px;
height: 28px;
border-radius: 50%;
border: 2px solid var(--color-border);
background: var(--color-surface);
color: var(--color-text-muted);
font-size: 0.75rem;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.order-step--active .order-step__dot {
border-color: var(--color-primary);
background: var(--color-primary);
color: #fff;
}
.order-step__icon {
width: 22px;
height: 22px;
color: var(--color-text-muted);
display: flex;
align-items: center;
justify-content: center;
}
.order-step--active .order-step__icon {
color: var(--color-primary);
}
.order-step__label {
font-size: 0.6875rem;
color: var(--color-text-muted);
font-weight: 500;
line-height: 1.35;
}
.order-step--active .order-step__label {
color: var(--color-primary);
font-weight: 600;
}
</style>
@@ -0,0 +1,126 @@
<script setup lang="ts">
import type { Company } from '@/types'
import type { Component } from 'vue'
defineProps<{
companies: Company[]
cardVariant: (slug: string) => string
companyDescription: (company: Company) => string
companyLogo: (slug: string) => Component
}>()
defineEmits<{
select: [companyId: string]
}>()
</script>
<template>
<div class="company-mobile-page">
<header class="company-mobile-page__header">
<h1 class="company-mobile-page__title">انتخاب شرکت</h1>
<p class="company-mobile-page__subtitle">شرکت مورد نظر خود را انتخاب کنید</p>
</header>
<div class="company-mobile-page__list">
<button
v-for="company in companies"
:key="company.id"
type="button"
class="company-brand-card"
:class="`company-brand-card--${cardVariant(company.slug)}`"
@click="$emit('select', company.id)"
>
<span class="company-brand-card__logo">
<component :is="companyLogo(company.slug)" :size="72" />
</span>
<h2 class="company-brand-card__name">{{ company.name }}</h2>
<p class="company-brand-card__desc">{{ companyDescription(company) }}</p>
</button>
</div>
</div>
</template>
<style scoped>
.company-mobile-page {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
background: #fff;
padding: 12px 0;
}
.company-mobile-page__header {
text-align: center;
margin-bottom: 28px;
}
.company-mobile-page__title {
margin: 0 0 8px;
font-size: 1.375rem;
font-weight: 700;
color: var(--color-primary);
}
.company-mobile-page__subtitle {
margin: 0;
font-size: 0.875rem;
color: var(--color-text-muted);
}
.company-mobile-page__list {
display: flex;
flex-direction: column;
gap: 16px;
overflow-y: auto;
}
.company-brand-card {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
min-height: 200px;
padding: 32px 24px;
border: none;
border-radius: 20px;
cursor: pointer;
text-align: center;
}
.company-brand-card--par {
background: var(--color-primary);
color: #fff;
box-shadow: 0 8px 24px rgba(29, 53, 87, 0.25);
}
.company-brand-card--fam-baft {
background: #f3ece3;
color: #1a202c;
box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}
.company-brand-card__logo {
margin-bottom: 16px;
}
.company-brand-card__name {
margin: 0 0 8px;
font-size: 1.125rem;
font-weight: 700;
}
.company-brand-card__desc {
margin: 0;
font-size: 0.8125rem;
max-width: 240px;
}
.company-brand-card--par .company-brand-card__desc {
color: rgba(255, 255, 255, 0.82);
}
.company-brand-card--fam-baft .company-brand-card__desc {
color: #718096;
}
</style>