7/7/405
This commit is contained in:
@@ -77,9 +77,14 @@ function goToCategories() {
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<button v-else type="button" class="empty-cta" @click="goToCategories">
|
||||
<div v-else class="empty-cta">
|
||||
شما هیچ کالیته ای درخواست نکرده اید، جهت درخواست کالیته و مشاهده فیزیکی پارچه ها کلیک کنید
|
||||
</button>
|
||||
<button type="button" class="desk-new-btn" @click="goToCategories">
|
||||
مشاهده محصولات
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -56,7 +56,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
|
||||
<template>
|
||||
<!-- Mobile -->
|
||||
<div class="page settlement-mobile-page mobile-only">
|
||||
<div class="page settlement-page mobile-only">
|
||||
<PageHeader
|
||||
title="انتخاب نوع تسویه"
|
||||
subtitle="پس از صدور فاکتور، نوع تسویه را انتخاب کنید"
|
||||
@@ -64,7 +64,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
centered
|
||||
@back="router.push(`/orders/${orderId}`)"
|
||||
/>
|
||||
<div class="page__scroll">
|
||||
<div class="page__scroll page__scroll--with-nav settlement-page__scroll">
|
||||
<FormErrorBanner :message="formError" />
|
||||
|
||||
<div v-if="!invoiceReady" class="settlement-waiting">
|
||||
@@ -116,18 +116,31 @@ async function selectType(type: 'cash' | 'check') {
|
||||
</div>
|
||||
|
||||
<!-- Desktop -->
|
||||
<div class="desktop-checkout-shell desktop-only">
|
||||
<div class="desktop-page settlement-desktop desktop-only">
|
||||
<CheckoutStepper :current-step="4" />
|
||||
|
||||
<header class="desktop-page__head">
|
||||
<h1 class="desktop-page__title">انتخاب نوع تسویه</h1>
|
||||
<p class="desktop-page__subtitle">
|
||||
<template v-if="invoiceReady">
|
||||
مبلغ فاکتور {{ invoiceLabel }}{{ order ? ` · سفارش ${order.orderNumber}` : '' }}
|
||||
پس از صدور فاکتور، روش تسویه را انتخاب کنید.
|
||||
</template>
|
||||
<template v-else>پس از قیمتگذاری مدیریت فعال میشود</template>
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div
|
||||
v-if="invoiceReady"
|
||||
class="settlement-invoice settlement-invoice--desktop"
|
||||
role="status"
|
||||
>
|
||||
<div class="settlement-invoice--desktop__main">
|
||||
<span class="settlement-invoice__label">مبلغ فاکتور</span>
|
||||
<strong class="settlement-invoice__value">{{ invoiceLabel }}</strong>
|
||||
</div>
|
||||
<span v-if="order" class="settlement-invoice__meta">سفارش {{ order.orderNumber }}</span>
|
||||
</div>
|
||||
|
||||
<FormErrorBanner :message="formError" />
|
||||
|
||||
<div v-if="!invoiceReady" class="settlement-waiting settlement-waiting--desktop">
|
||||
@@ -170,9 +183,33 @@ async function selectType(type: 'cash' | 'check') {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.settlement-mobile-page {
|
||||
.settlement-page {
|
||||
background: var(--color-bg);
|
||||
padding: 12px 0 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.settlement-page__scroll {
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.settlement-desktop {
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.settlement-invoice--desktop {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
.settlement-invoice--desktop__main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.settlement-waiting {
|
||||
@@ -262,11 +299,13 @@ async function selectType(type: 'cash' | 'check') {
|
||||
}
|
||||
|
||||
.settlement-card--desktop {
|
||||
min-height: 220px;
|
||||
min-height: 240px;
|
||||
border: 1px solid var(--color-border);
|
||||
background: var(--color-surface);
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
box-shadow 0.15s;
|
||||
box-shadow 0.15s,
|
||||
transform 0.15s;
|
||||
}
|
||||
|
||||
.settlement-card--desktop:hover:not(:disabled) {
|
||||
|
||||
+63
-150
@@ -22,6 +22,7 @@ import { useGoBack } from '@/composables/useGoBack'
|
||||
import AuthThemeToggle from '@/components/ui/AuthThemeToggle.vue'
|
||||
import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import UserAvatar from '@/components/ui/UserAvatar.vue'
|
||||
import HomeSuggestionsSection from '@/components/home/HomeSuggestionsSection.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const { goBack } = useGoBack('/')
|
||||
@@ -32,6 +33,7 @@ const loading = ref(true)
|
||||
const error = ref<string | null>(null)
|
||||
const newest = ref<CatalogProductCard[]>([])
|
||||
const suggestions = ref<ProductSuggestionDto[]>([])
|
||||
const browseProducts = ref<CatalogProductCard[]>([])
|
||||
const favError = ref<string | null>(null)
|
||||
const agentLevel = ref<{
|
||||
label: string
|
||||
@@ -62,6 +64,22 @@ const agentActions: QuickAction[] = [
|
||||
|
||||
const actions = computed(() => (auth.isAgent ? agentActions : customerActions))
|
||||
|
||||
const suggestionsForHome = computed(() => {
|
||||
const byId = new Map(browseProducts.value.map((p) => [p.id, p]))
|
||||
return suggestions.value.map((item) => {
|
||||
const product = byId.get(item.productId)
|
||||
return {
|
||||
...item,
|
||||
composition: item.composition?.trim() || product?.composition?.trim() || '',
|
||||
widthCm: item.widthCm ?? product?.widthCm,
|
||||
colors: item.colors?.length ? item.colors : product?.colors ?? [],
|
||||
colorImages: item.colorImages?.some(Boolean)
|
||||
? item.colorImages
|
||||
: product?.colorImages,
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const FALLBACK_BANNER: AppBannerDto = {
|
||||
id: 'fallback',
|
||||
slot: 'home_hero',
|
||||
@@ -147,7 +165,10 @@ onMounted(async () => {
|
||||
error.value = null
|
||||
try {
|
||||
const [products, homeBanners] = await Promise.all([
|
||||
crm.loadBrowseProducts(),
|
||||
crm.loadBrowseProducts().then((list) => {
|
||||
browseProducts.value = list
|
||||
return list
|
||||
}),
|
||||
fetchBanners('home_hero').catch(() => [] as AppBannerDto[]),
|
||||
favorites.hydrate(),
|
||||
])
|
||||
@@ -240,7 +261,10 @@ async function toggleFavorite(productId: string) {
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="page__scroll page__scroll--with-nav home-scroll">
|
||||
<div
|
||||
class="page__scroll page__scroll--with-nav home-scroll"
|
||||
:class="{ 'home-scroll--customer': !auth.isAgent }"
|
||||
>
|
||||
<p v-if="error" class="home-error">{{ error }}</p>
|
||||
<PageSkeleton v-else-if="loading" variant="home" />
|
||||
<template v-else>
|
||||
@@ -345,37 +369,11 @@ async function toggleFavorite(productId: string) {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-else class="suggest-card" aria-label="پیشنهاد اختصاصی">
|
||||
<div class="suggest-card__head">
|
||||
<h3 class="suggest-card__title">پیشنهاد اختصاصی ما برای شما</h3>
|
||||
<p v-if="!suggestions.length" class="suggest-card__empty">
|
||||
هنوز پیشنهاد اختصاصی برای شما ثبت نشده است.
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="suggestions.length" class="suggest-card__row scroll-x">
|
||||
<article
|
||||
v-for="(item, index) in suggestions"
|
||||
:key="item.id"
|
||||
class="suggest-card__item"
|
||||
@click="go(`/product?id=${item.productId}`)"
|
||||
>
|
||||
<div
|
||||
class="suggest-card__image"
|
||||
:class="`suggest-card__image--${index % 3}`"
|
||||
:style="item.imageUrl ? { backgroundImage: `url(${item.imageUrl})` } : undefined"
|
||||
>
|
||||
<span v-if="item.isNew" class="suggest-card__badge">جدید</span>
|
||||
</div>
|
||||
<div class="suggest-card__body">
|
||||
<strong class="suggest-card__name">{{ item.productName }}</strong>
|
||||
<span class="suggest-card__sub">
|
||||
{{ item.subtitle || item.catalogName || item.productCode }}
|
||||
</span>
|
||||
<p v-if="item.note" class="suggest-card__note">{{ item.note }}</p>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
<HomeSuggestionsSection
|
||||
v-if="!auth.isAgent"
|
||||
class="home-suggestions"
|
||||
:items="suggestionsForHome"
|
||||
/>
|
||||
|
||||
<section class="section">
|
||||
<div class="section__head">
|
||||
@@ -718,6 +716,19 @@ async function toggleFavorite(productId: string) {
|
||||
font-size: 0.7rem;
|
||||
text-align: center;
|
||||
line-height: 1.4;
|
||||
/* Force navy color for quick-card labels (override global/link styles on server) */
|
||||
color: var(--color-accent-navy) !important;
|
||||
}
|
||||
|
||||
/* Keep the same color on hover/focus so it doesn't turn default link/blue */
|
||||
.quick-card:hover .quick-card__label,
|
||||
.quick-card:focus .quick-card__label {
|
||||
color: var(--color-accent-navy) !important;
|
||||
}
|
||||
|
||||
/* Ensure dark mode keeps readable navy (adjust if you prefer a different dark color) */
|
||||
html.dark .quick-card__label {
|
||||
color: var(--color-accent-navy) !important;
|
||||
}
|
||||
|
||||
.level-card {
|
||||
@@ -815,110 +826,10 @@ async function toggleFavorite(productId: string) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.suggest-card {
|
||||
background: var(--color-surface);
|
||||
border-radius: 18px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--color-border);
|
||||
.home-suggestions {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.suggest-card__head {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.suggest-card__title {
|
||||
margin: 0;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 800;
|
||||
color: var(--color-accent-navy);
|
||||
}
|
||||
|
||||
.suggest-card__empty {
|
||||
margin: 8px 0 0;
|
||||
font-size: 0.8rem;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.suggest-card__row {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
gap: 10px;
|
||||
margin-inline: -16px;
|
||||
padding-inline: 16px;
|
||||
padding-bottom: 4px;
|
||||
scroll-snap-type: x proximity;
|
||||
}
|
||||
|
||||
.suggest-card__item {
|
||||
flex: 0 0 132px;
|
||||
width: 132px;
|
||||
scroll-snap-align: start;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.suggest-card__image {
|
||||
position: relative;
|
||||
height: 92px;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #e8ecf0, #d5dbe3);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.suggest-card__image--0 {
|
||||
background-color: #e7dfd6;
|
||||
}
|
||||
|
||||
.suggest-card__image--1 {
|
||||
background-color: #dfe8ea;
|
||||
}
|
||||
|
||||
.suggest-card__image--2 {
|
||||
background-color: #ebe4df;
|
||||
}
|
||||
|
||||
.suggest-card__badge {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
font-size: 0.62rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.suggest-card__body {
|
||||
padding: 8px 2px 0;
|
||||
}
|
||||
|
||||
.suggest-card__name {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
font-size: 0.78rem;
|
||||
line-height: 1.35;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.suggest-card__sub {
|
||||
display: block;
|
||||
font-size: 0.68rem;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.suggest-card__note {
|
||||
margin: 4px 0 0;
|
||||
font-size: 0.65rem;
|
||||
color: var(--color-primary);
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.section__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -1057,7 +968,6 @@ async function toggleFavorite(productId: string) {
|
||||
html.dark .section__title,
|
||||
html.dark .home-desk-head__title,
|
||||
html.dark .level-card__name,
|
||||
html.dark .suggest-card__title,
|
||||
html.dark .product-card__name {
|
||||
color: #fff;
|
||||
}
|
||||
@@ -1110,15 +1020,31 @@ html.dark .product-card__sub {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.home-scroll--customer {
|
||||
grid-template-areas:
|
||||
'hero hero hero'
|
||||
'quick quick quick'
|
||||
'suggest suggest suggest'
|
||||
'products products products';
|
||||
}
|
||||
|
||||
.home-scroll--customer .hero-banner {
|
||||
aspect-ratio: 2.35 / 1;
|
||||
}
|
||||
|
||||
.home-suggestions {
|
||||
grid-area: suggest;
|
||||
}
|
||||
|
||||
.hero-banner {
|
||||
grid-area: hero;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
height: 100%;
|
||||
aspect-ratio: 2.1 / 1;
|
||||
align-self: start;
|
||||
align-self: stretch;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
@@ -1132,19 +1058,6 @@ html.dark .product-card__sub {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.suggest-card {
|
||||
grid-area: level;
|
||||
padding: 20px 22px;
|
||||
align-self: start;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.suggest-card__row {
|
||||
margin-inline: -22px;
|
||||
padding-inline: 22px;
|
||||
}
|
||||
|
||||
.quick-grid {
|
||||
grid-area: quick;
|
||||
display: grid;
|
||||
|
||||
@@ -7,6 +7,8 @@ import BaseButton from '@/components/ui/BaseButton.vue'
|
||||
import BaseInput from '@/components/ui/BaseInput.vue'
|
||||
import CurrencyInput from '@/components/ui/CurrencyInput.vue'
|
||||
import PersianDateInput from '@/components/ui/PersianDateInput.vue'
|
||||
import TimeInput from '@/components/ui/TimeInput.vue'
|
||||
import AppSelect from '@/components/ui/AppSelect.vue'
|
||||
import FormErrorBanner from '@/components/ui/FormErrorBanner.vue'
|
||||
import IconChevronBack from '@/components/icons/IconChevronBack.vue'
|
||||
import IconChevronLeft from '@/components/icons/IconChevronLeft.vue'
|
||||
@@ -30,7 +32,7 @@ import { getStatusHero, getTrackingFooterLabel } from '@/utils/orderTracking'
|
||||
import OrderTrackingTimeline from '@/components/orders/OrderTrackingTimeline.vue'
|
||||
import OrderStatusHero from '@/components/orders/OrderStatusHero.vue'
|
||||
import OrderTrackingSummary from '@/components/orders/OrderTrackingSummary.vue'
|
||||
import { canSubmitCashReceipt, isInvoicePriced } from '@/utils/orderInvoice'
|
||||
import { canSubmitCashReceipt, isInvoicePriced, orderItemMeterage } from '@/utils/orderInvoice'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -122,6 +124,14 @@ watch(
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
const bankAccountOptions = computed(() => [
|
||||
{ value: '', label: 'انتخاب کنید' },
|
||||
...bankAccounts.value.map((acc) => ({
|
||||
value: acc.id,
|
||||
label: `${acc.bankName} — ${acc.cardNumber}`,
|
||||
})),
|
||||
])
|
||||
|
||||
watch(
|
||||
() => orderId.value,
|
||||
async (id) => {
|
||||
@@ -401,7 +411,7 @@ async function submitReceipt() {
|
||||
<strong>{{ item.productName }}</strong>
|
||||
<p class="item-row__meta">کالیته {{ item.catalogCode }} · {{ item.color }}</p>
|
||||
</div>
|
||||
<span>{{ formatMeterage(item.requestedMeterage) }}</span>
|
||||
<span>{{ formatMeterage(orderItemMeterage(item)) }}</span>
|
||||
</div>
|
||||
<div class="item-row item-row--summary">
|
||||
<span>مجموع متراژ</span>
|
||||
@@ -517,7 +527,12 @@ async function submitReceipt() {
|
||||
label="تاریخ واریز"
|
||||
:error="fieldErrors.receiptDate"
|
||||
/>
|
||||
<BaseInput v-model="receiptTime" label="ساعت واریز" type="time" />
|
||||
<TimeInput
|
||||
v-model="receiptTime"
|
||||
label="ساعت واریز"
|
||||
placeholder="مثلاً ۱۴:۳۰"
|
||||
hint="با گام ۵ دقیقه"
|
||||
/>
|
||||
<BaseInput
|
||||
v-model="trackingNumber"
|
||||
label="شماره پیگیری"
|
||||
@@ -525,22 +540,13 @@ async function submitReceipt() {
|
||||
dir="ltr"
|
||||
:error="fieldErrors.trackingNumber"
|
||||
/>
|
||||
<div class="form-group">
|
||||
<label class="form-label">حساب مقصد</label>
|
||||
<select
|
||||
v-model="destinationAccountId"
|
||||
class="select-input"
|
||||
:class="{ 'select-input--error': fieldErrors.destinationAccountId }"
|
||||
>
|
||||
<option value="">انتخاب کنید</option>
|
||||
<option v-for="acc in bankAccounts" :key="acc.id" :value="acc.id">
|
||||
{{ acc.bankName }} - {{ acc.cardNumber }}
|
||||
</option>
|
||||
</select>
|
||||
<p v-if="fieldErrors.destinationAccountId" class="input-error-text">
|
||||
{{ fieldErrors.destinationAccountId }}
|
||||
</p>
|
||||
</div>
|
||||
<AppSelect
|
||||
v-model="destinationAccountId"
|
||||
label="حساب مقصد"
|
||||
aria-label="حساب مقصد"
|
||||
:options="bankAccountOptions"
|
||||
:error="fieldErrors.destinationAccountId"
|
||||
/>
|
||||
<div class="form-group">
|
||||
<label class="form-label">تصویر رسید</label>
|
||||
<label class="upload-box" :class="{ 'upload-box--error': fieldErrors.receiptImage }">
|
||||
@@ -1188,18 +1194,6 @@ async function submitReceipt() {
|
||||
}
|
||||
}
|
||||
|
||||
.select-input {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 1.5px solid var(--color-border);
|
||||
border-radius: var(--radius-sm);
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.select-input--error {
|
||||
border-color: var(--color-danger);
|
||||
}
|
||||
|
||||
.upload-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -58,7 +58,6 @@ const orderModalOpen = ref(false)
|
||||
const orderModalError = ref('')
|
||||
const {
|
||||
requesting: catalogRequesting,
|
||||
successMessage: catalogSuccessMessage,
|
||||
addressModalOpen,
|
||||
addressError: catalogAddressError,
|
||||
requestCatalog,
|
||||
@@ -279,10 +278,6 @@ function onAddressSubmit(address: string) {
|
||||
|
||||
<template>
|
||||
<div v-if="product" class="page product-detail product-page">
|
||||
<p v-if="catalogSuccessMessage" class="catalog-success-banner" role="status">
|
||||
{{ catalogSuccessMessage }}
|
||||
</p>
|
||||
|
||||
<header class="pd-header mobile-only">
|
||||
<button type="button" class="icon-btn" aria-label="بازگشت" @click="goBack">
|
||||
<IconChevronBack :size="20" />
|
||||
@@ -505,7 +500,7 @@ function onAddressSubmit(address: string) {
|
||||
:disabled="catalogRequesting"
|
||||
@click="requestPhysicalCatalog"
|
||||
>
|
||||
<img class="btn-secondary__icon" :src="quickCatalogRequestIcon" alt="" aria-hidden="true" />
|
||||
<!-- <img class="btn-secondary__icon" :src="quickCatalogRequestIcon" alt="" aria-hidden="true" />-->
|
||||
{{ catalogRequesting ? 'در حال ثبت...' : 'درخواست کالیته' }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -527,7 +522,7 @@ function onAddressSubmit(address: string) {
|
||||
:disabled="catalogRequesting"
|
||||
@click="requestPhysicalCatalog"
|
||||
>
|
||||
<img class="btn-secondary__icon" :src="quickCatalogRequestIcon" alt="" aria-hidden="true" />
|
||||
<!-- <img class="btn-secondary__icon" :src="quickCatalogRequestIcon" alt="" aria-hidden="true" />-->
|
||||
{{ catalogRequesting ? 'در حال ثبت...' : 'درخواست کالیته' }}
|
||||
</button>
|
||||
</footer>
|
||||
@@ -564,17 +559,6 @@ function onAddressSubmit(address: string) {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.catalog-success-banner {
|
||||
margin: 0;
|
||||
padding: 12px var(--page-padding);
|
||||
background: var(--color-success-light);
|
||||
color: var(--color-success);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.6;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.product-detail {
|
||||
--pd-card-border: 1px solid #eeeef1;
|
||||
--pd-card-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 16px rgba(16, 24, 40, 0.05);
|
||||
@@ -772,18 +756,19 @@ function onAddressSubmit(address: string) {
|
||||
}
|
||||
|
||||
.spec-cell strong {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.45;
|
||||
color: var(--color-text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.spec-cell span {
|
||||
color: #98a2ad;
|
||||
font-size: 0.7rem;
|
||||
.spec-cell span:not(.spec-icon) {
|
||||
color: var(--color-text-muted);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.specs-more {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { onClickOutside } from '@vueuse/core'
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useCrmStore } from '@/stores/crm'
|
||||
@@ -8,6 +7,7 @@ import PageHeader from '@/components/layout/PageHeader.vue'
|
||||
import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import SearchField from '@/components/ui/SearchField.vue'
|
||||
import BaseButton from '@/components/ui/BaseButton.vue'
|
||||
import AppSelect from '@/components/ui/AppSelect.vue'
|
||||
import IconFilter from '@/components/icons/IconFilter.vue'
|
||||
import IconChevronLeft from '@/components/icons/IconChevronLeft.vue'
|
||||
import IconHeart from '@/components/icons/IconHeart.vue'
|
||||
@@ -37,32 +37,20 @@ const sortMode = ref<'newest' | 'name'>('newest')
|
||||
const filterOpen = ref(false)
|
||||
const filterDraftCategory = ref('')
|
||||
const filterDraftSeason = ref('')
|
||||
const categorySelectOpen = ref(false)
|
||||
const seasonSelectOpen = ref(false)
|
||||
const categoryRoot = ref<HTMLElement | null>(null)
|
||||
const seasonRoot = ref<HTMLElement | null>(null)
|
||||
const categoryRootDesk = ref<HTMLElement | null>(null)
|
||||
const seasonRootDesk = ref<HTMLElement | null>(null)
|
||||
|
||||
const showFilter = computed(() => !catalogId.value)
|
||||
|
||||
const categoryFilterOptions = computed(() => [
|
||||
{ value: '', label: 'همه دستهها' },
|
||||
...crm.usageCategories.map((item) => ({ value: item.id, label: item.title })),
|
||||
])
|
||||
|
||||
const seasonFilterOptions = computed(() => [
|
||||
{ value: '', label: 'همه فصول' },
|
||||
...crm.seasonCategories.map((item) => ({ value: item.id, label: item.title })),
|
||||
])
|
||||
|
||||
const hasActiveFilters = computed(() => !!categoryId.value || !!season.value)
|
||||
|
||||
const selectedCategoryLabel = computed(() => {
|
||||
if (!filterDraftCategory.value) return 'همه دستهها'
|
||||
return (
|
||||
crm.usageCategories.find((item) => item.id === filterDraftCategory.value)?.title ??
|
||||
'همه دستهها'
|
||||
)
|
||||
})
|
||||
|
||||
const selectedSeasonLabel = computed(() => {
|
||||
if (!filterDraftSeason.value) return 'همه فصول'
|
||||
return (
|
||||
crm.seasonCategories.find((item) => item.id === filterDraftSeason.value)?.title ?? 'همه فصول'
|
||||
)
|
||||
})
|
||||
|
||||
const title = computed(() => {
|
||||
if (catalogId.value && catalogTitle.value) return catalogTitle.value
|
||||
if (categoryId.value) {
|
||||
@@ -289,53 +277,13 @@ function toggleFavorite(productId: string) {
|
||||
function openFilter() {
|
||||
filterDraftCategory.value = categoryId.value
|
||||
filterDraftSeason.value = season.value
|
||||
categorySelectOpen.value = false
|
||||
seasonSelectOpen.value = false
|
||||
filterOpen.value = true
|
||||
}
|
||||
|
||||
function closeFilter() {
|
||||
filterOpen.value = false
|
||||
categorySelectOpen.value = false
|
||||
seasonSelectOpen.value = false
|
||||
}
|
||||
|
||||
function toggleCategorySelect() {
|
||||
seasonSelectOpen.value = false
|
||||
categorySelectOpen.value = !categorySelectOpen.value
|
||||
}
|
||||
|
||||
function toggleSeasonSelect() {
|
||||
categorySelectOpen.value = false
|
||||
seasonSelectOpen.value = !seasonSelectOpen.value
|
||||
}
|
||||
|
||||
function selectFilterCategory(id: string) {
|
||||
filterDraftCategory.value = id
|
||||
categorySelectOpen.value = false
|
||||
}
|
||||
|
||||
function selectFilterSeason(id: string) {
|
||||
filterDraftSeason.value = id
|
||||
seasonSelectOpen.value = false
|
||||
}
|
||||
|
||||
onClickOutside(categoryRoot, () => {
|
||||
categorySelectOpen.value = false
|
||||
})
|
||||
|
||||
onClickOutside(seasonRoot, () => {
|
||||
seasonSelectOpen.value = false
|
||||
})
|
||||
|
||||
onClickOutside(categoryRootDesk, () => {
|
||||
categorySelectOpen.value = false
|
||||
})
|
||||
|
||||
onClickOutside(seasonRootDesk, () => {
|
||||
seasonSelectOpen.value = false
|
||||
})
|
||||
|
||||
function resolveFilterAxis(nextCategory: string, nextSeason: string) {
|
||||
if (nextCategory) return 'usage'
|
||||
if (nextSeason) return 'season'
|
||||
@@ -415,103 +363,21 @@ onUnmounted(() => {
|
||||
<h2>فیلتر محصولات</h2>
|
||||
</header>
|
||||
|
||||
<label class="products-filter-section">
|
||||
<span class="products-filter-section__title">دسته کاربرد</span>
|
||||
<div ref="categoryRootDesk" class="field-select">
|
||||
<button
|
||||
type="button"
|
||||
class="field-select__trigger"
|
||||
:class="{ 'is-open': categorySelectOpen }"
|
||||
aria-haspopup="listbox"
|
||||
:aria-expanded="categorySelectOpen"
|
||||
@click="toggleCategorySelect"
|
||||
>
|
||||
<span :class="{ 'is-placeholder': !filterDraftCategory }">{{ selectedCategoryLabel }}</span>
|
||||
<svg class="field-select__chevron" viewBox="0 0 12 12" aria-hidden="true">
|
||||
<path
|
||||
d="M2.5 4.5 6 8l3.5-3.5"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<ul v-if="categorySelectOpen" class="field-select__menu" role="listbox" aria-label="دسته کاربرد">
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
class="field-select__option"
|
||||
:class="{ 'is-active': !filterDraftCategory }"
|
||||
@click="selectFilterCategory('')"
|
||||
>
|
||||
همه دستهها
|
||||
</button>
|
||||
</li>
|
||||
<li v-for="item in crm.usageCategories" :key="item.id">
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
class="field-select__option"
|
||||
:class="{ 'is-active': filterDraftCategory === item.id }"
|
||||
@click="selectFilterCategory(item.id)"
|
||||
>
|
||||
{{ item.title }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</label>
|
||||
<AppSelect
|
||||
v-model="filterDraftCategory"
|
||||
class="products-filter-section"
|
||||
label="دسته کاربرد"
|
||||
aria-label="دسته کاربرد"
|
||||
:options="categoryFilterOptions"
|
||||
/>
|
||||
|
||||
<label class="products-filter-section">
|
||||
<span class="products-filter-section__title">فصل</span>
|
||||
<div ref="seasonRootDesk" class="field-select">
|
||||
<button
|
||||
type="button"
|
||||
class="field-select__trigger"
|
||||
:class="{ 'is-open': seasonSelectOpen }"
|
||||
aria-haspopup="listbox"
|
||||
:aria-expanded="seasonSelectOpen"
|
||||
@click="toggleSeasonSelect"
|
||||
>
|
||||
<span :class="{ 'is-placeholder': !filterDraftSeason }">{{ selectedSeasonLabel }}</span>
|
||||
<svg class="field-select__chevron" viewBox="0 0 12 12" aria-hidden="true">
|
||||
<path
|
||||
d="M2.5 4.5 6 8l3.5-3.5"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<ul v-if="seasonSelectOpen" class="field-select__menu" role="listbox" aria-label="فصل">
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
class="field-select__option"
|
||||
:class="{ 'is-active': !filterDraftSeason }"
|
||||
@click="selectFilterSeason('')"
|
||||
>
|
||||
همه فصول
|
||||
</button>
|
||||
</li>
|
||||
<li v-for="item in crm.seasonCategories" :key="item.id">
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
class="field-select__option"
|
||||
:class="{ 'is-active': filterDraftSeason === item.id }"
|
||||
@click="selectFilterSeason(item.id)"
|
||||
>
|
||||
{{ item.title }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</label>
|
||||
<AppSelect
|
||||
v-model="filterDraftSeason"
|
||||
class="products-filter-section"
|
||||
label="فصل"
|
||||
aria-label="فصل"
|
||||
:options="seasonFilterOptions"
|
||||
/>
|
||||
|
||||
<div class="products-filter-actions products-filter-actions--desk">
|
||||
<BaseButton @click="applyFilter">اعمال فیلتر</BaseButton>
|
||||
@@ -546,107 +412,21 @@ onUnmounted(() => {
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<label class="products-filter-section">
|
||||
<span class="products-filter-section__title">دسته کاربرد</span>
|
||||
<div ref="categoryRoot" class="field-select">
|
||||
<button
|
||||
type="button"
|
||||
class="field-select__trigger"
|
||||
:class="{ 'is-open': categorySelectOpen }"
|
||||
aria-haspopup="listbox"
|
||||
:aria-expanded="categorySelectOpen"
|
||||
@click="toggleCategorySelect"
|
||||
>
|
||||
<span :class="{ 'is-placeholder': !filterDraftCategory }">{{ selectedCategoryLabel }}</span>
|
||||
<svg class="field-select__chevron" viewBox="0 0 12 12" aria-hidden="true">
|
||||
<path
|
||||
d="M2.5 4.5 6 8l3.5-3.5"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<ul v-if="categorySelectOpen" class="field-select__menu" role="listbox" aria-label="دسته کاربرد">
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
class="field-select__option"
|
||||
:class="{ 'is-active': !filterDraftCategory }"
|
||||
:aria-selected="!filterDraftCategory"
|
||||
@click="selectFilterCategory('')"
|
||||
>
|
||||
همه دستهها
|
||||
</button>
|
||||
</li>
|
||||
<li v-for="item in crm.usageCategories" :key="item.id">
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
class="field-select__option"
|
||||
:class="{ 'is-active': filterDraftCategory === item.id }"
|
||||
:aria-selected="filterDraftCategory === item.id"
|
||||
@click="selectFilterCategory(item.id)"
|
||||
>
|
||||
{{ item.title }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</label>
|
||||
<AppSelect
|
||||
v-model="filterDraftCategory"
|
||||
class="products-filter-section"
|
||||
label="دسته کاربرد"
|
||||
aria-label="دسته کاربرد"
|
||||
:options="categoryFilterOptions"
|
||||
/>
|
||||
|
||||
<label class="products-filter-section">
|
||||
<span class="products-filter-section__title">فصل</span>
|
||||
<div ref="seasonRoot" class="field-select">
|
||||
<button
|
||||
type="button"
|
||||
class="field-select__trigger"
|
||||
:class="{ 'is-open': seasonSelectOpen }"
|
||||
aria-haspopup="listbox"
|
||||
:aria-expanded="seasonSelectOpen"
|
||||
@click="toggleSeasonSelect"
|
||||
>
|
||||
<span :class="{ 'is-placeholder': !filterDraftSeason }">{{ selectedSeasonLabel }}</span>
|
||||
<svg class="field-select__chevron" viewBox="0 0 12 12" aria-hidden="true">
|
||||
<path
|
||||
d="M2.5 4.5 6 8l3.5-3.5"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<ul v-if="seasonSelectOpen" class="field-select__menu" role="listbox" aria-label="فصل">
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
class="field-select__option"
|
||||
:class="{ 'is-active': !filterDraftSeason }"
|
||||
:aria-selected="!filterDraftSeason"
|
||||
@click="selectFilterSeason('')"
|
||||
>
|
||||
همه فصول
|
||||
</button>
|
||||
</li>
|
||||
<li v-for="item in crm.seasonCategories" :key="item.id">
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
class="field-select__option"
|
||||
:class="{ 'is-active': filterDraftSeason === item.id }"
|
||||
:aria-selected="filterDraftSeason === item.id"
|
||||
@click="selectFilterSeason(item.id)"
|
||||
>
|
||||
{{ item.title }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</label>
|
||||
<AppSelect
|
||||
v-model="filterDraftSeason"
|
||||
class="products-filter-section"
|
||||
label="فصل"
|
||||
aria-label="فصل"
|
||||
:options="seasonFilterOptions"
|
||||
/>
|
||||
|
||||
<div class="products-filter-actions">
|
||||
<BaseButton block @click="applyFilter">اعمال فیلتر</BaseButton>
|
||||
@@ -960,83 +740,10 @@ onUnmounted(() => {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.field-select {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.field-select__trigger {
|
||||
.products-filter-section.app-select {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
height: var(--btn-height);
|
||||
padding: 0 14px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
font-size: 0.9375rem;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
|
||||
.field-select__trigger.is-open {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.field-select__trigger .is-placeholder {
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.field-select__chevron {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
color: var(--color-text-muted);
|
||||
flex-shrink: 0;
|
||||
transition: transform 0.15s ease;
|
||||
}
|
||||
|
||||
.field-select__trigger.is-open .field-select__chevron {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.field-select__menu {
|
||||
position: absolute;
|
||||
inset-inline: 0;
|
||||
top: calc(100% + 6px);
|
||||
z-index: 20;
|
||||
margin: 0;
|
||||
padding: 6px;
|
||||
list-style: none;
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: var(--shadow-md);
|
||||
max-height: 220px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.field-select__option {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
background: transparent;
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
font-size: 0.875rem;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.field-select__option.is-active {
|
||||
background: var(--color-primary-light);
|
||||
color: var(--color-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.products-filter-actions {
|
||||
|
||||
@@ -1,24 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useMediaQuery } from '@vueuse/core'
|
||||
import BaseButton from '@/components/ui/BaseButton.vue'
|
||||
import IconMapPin from '@/components/icons/IconMapPin.vue'
|
||||
import IconPlus from '@/components/icons/IconPlus.vue'
|
||||
import IconTrash from '@/components/icons/IconTrash.vue'
|
||||
import IconVerified from '@/components/icons/IconVerified.vue'
|
||||
import ProfileSubpageLayout from '@/views/profile/components/ProfileSubpageLayout.vue'
|
||||
import { useAppToast } from '@/composables/useAppToast'
|
||||
import { addressesApi, type SavedAddress } from '@/services/addresses'
|
||||
import { ApiError } from '@/services/http'
|
||||
|
||||
const isDesktop = useMediaQuery('(min-width: 768px)')
|
||||
const toast = useAppToast()
|
||||
|
||||
const rows = ref<SavedAddress[]>([])
|
||||
const text = ref('')
|
||||
const label = ref('')
|
||||
const error = ref('')
|
||||
const pageError = ref('')
|
||||
const formError = ref('')
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
const addOpen = ref(false)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
pageError.value = ''
|
||||
try {
|
||||
rows.value = await addressesApi.list()
|
||||
} catch (e) {
|
||||
error.value = e instanceof ApiError || e instanceof Error ? e.message : 'دریافت آدرسها ناموفق بود.'
|
||||
pageError.value =
|
||||
e instanceof ApiError || e instanceof Error ? e.message : 'دریافت آدرسها ناموفق بود.'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -26,133 +38,424 @@ async function load() {
|
||||
|
||||
onMounted(load)
|
||||
|
||||
function resetForm() {
|
||||
text.value = ''
|
||||
label.value = ''
|
||||
formError.value = ''
|
||||
}
|
||||
|
||||
function openAddForm() {
|
||||
resetForm()
|
||||
addOpen.value = true
|
||||
}
|
||||
|
||||
function closeAddForm() {
|
||||
if (saving.value) return
|
||||
addOpen.value = false
|
||||
resetForm()
|
||||
}
|
||||
|
||||
function onAddKeydown(event: KeyboardEvent) {
|
||||
if (event.key === 'Escape' && addOpen.value) closeAddForm()
|
||||
}
|
||||
|
||||
watch(addOpen, (isOpen) => {
|
||||
document.body.style.overflow = isOpen ? 'hidden' : ''
|
||||
if (isOpen) {
|
||||
window.addEventListener('keydown', onAddKeydown)
|
||||
} else {
|
||||
window.removeEventListener('keydown', onAddKeydown)
|
||||
}
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.body.style.overflow = ''
|
||||
window.removeEventListener('keydown', onAddKeydown)
|
||||
})
|
||||
|
||||
async function add() {
|
||||
const trimmed = text.value.trim()
|
||||
if (trimmed.length < 3 || saving.value) {
|
||||
error.value = 'آدرس را کاملتر بنویسید.'
|
||||
formError.value = 'آدرس را کاملتر بنویسید.'
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
error.value = ''
|
||||
formError.value = ''
|
||||
try {
|
||||
await addressesApi.create({ text: trimmed, label: label.value.trim() || undefined })
|
||||
text.value = ''
|
||||
label.value = ''
|
||||
rows.value = await addressesApi.list()
|
||||
closeAddForm()
|
||||
toast.show('آدرس با موفقیت ثبت شد.', { tone: 'success' })
|
||||
} catch (e) {
|
||||
error.value = e instanceof ApiError || e instanceof Error ? e.message : 'ذخیره آدرس ناموفق بود.'
|
||||
formError.value =
|
||||
e instanceof ApiError || e instanceof Error ? e.message : 'ذخیره آدرس ناموفق بود.'
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function makeDefault(id: string) {
|
||||
error.value = ''
|
||||
pageError.value = ''
|
||||
try {
|
||||
rows.value = await addressesApi.makeDefault(id)
|
||||
toast.show('آدرس پیشفرض بهروزرسانی شد.', { tone: 'success' })
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : 'تغییر آدرس پیشفرض ناموفق بود.'
|
||||
pageError.value = e instanceof Error ? e.message : 'تغییر آدرس پیشفرض ناموفق بود.'
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(id: string) {
|
||||
error.value = ''
|
||||
pageError.value = ''
|
||||
try {
|
||||
rows.value = await addressesApi.remove(id)
|
||||
toast.show('آدرس حذف شد.', { tone: 'success' })
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : 'حذف آدرس ناموفق بود.'
|
||||
pageError.value = e instanceof Error ? e.message : 'حذف آدرس ناموفق بود.'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ProfileSubpageLayout title="آدرسها" subtitle="برای ارسال کالیته از آدرس پیشفرض استفاده میشود">
|
||||
<p v-if="error" class="addr-error">{{ error }}</p>
|
||||
<p v-if="loading" class="addr-muted">در حال دریافت…</p>
|
||||
<ul v-else-if="rows.length" class="addr-list">
|
||||
<li v-for="row in rows" :key="row.id" class="addr-item">
|
||||
<div>
|
||||
<strong>{{ row.label || 'آدرس' }}</strong>
|
||||
<span v-if="row.isDefault" class="addr-badge">پیشفرض</span>
|
||||
<p>{{ row.text }}</p>
|
||||
</div>
|
||||
<div class="addr-actions">
|
||||
<button v-if="!row.isDefault" type="button" @click="makeDefault(row.id)">پیشفرض</button>
|
||||
<button type="button" class="addr-remove" @click="remove(row.id)">حذف</button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else class="addr-muted">هنوز آدرسی ثبت نشده است.</p>
|
||||
<div class="addresses-page">
|
||||
<ProfileSubpageLayout title="آدرسها" subtitle="برای ارسال کالیته از آدرس پیشفرض استفاده میشود">
|
||||
<div class="addresses-page__toolbar">
|
||||
<p class="addresses-page__hint">آدرسهای محل فعالیت برای ارسال کالیته</p>
|
||||
<BaseButton class="addresses-page__new-btn" size="sm" @click="openAddForm">
|
||||
<IconPlus :size="18" />
|
||||
آدرس جدید
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<label class="addr-field">
|
||||
<span>عنوان (اختیاری)</span>
|
||||
<input v-model="label" type="text" maxlength="40" placeholder="مثلاً فروشگاه" />
|
||||
</label>
|
||||
<label class="addr-field">
|
||||
<span>آدرس</span>
|
||||
<textarea v-model="text" rows="3" maxlength="500" placeholder="آدرس کامل محل فعالیت" />
|
||||
</label>
|
||||
<BaseButton :loading="saving" @click="add">افزودن آدرس</BaseButton>
|
||||
</ProfileSubpageLayout>
|
||||
<p v-if="pageError" class="addr-error" role="alert">{{ pageError }}</p>
|
||||
<p v-if="loading" class="addr-muted">در حال دریافت…</p>
|
||||
|
||||
<ul v-else-if="rows.length" class="addr-list">
|
||||
<li
|
||||
v-for="row in rows"
|
||||
:key="row.id"
|
||||
class="addr-card"
|
||||
:class="{ 'addr-card--default': row.isDefault }"
|
||||
>
|
||||
<div class="addr-card__main">
|
||||
<div class="addr-card__icon" aria-hidden="true">
|
||||
<IconMapPin :size="20" />
|
||||
</div>
|
||||
<div class="addr-card__body">
|
||||
<div class="addr-card__head">
|
||||
<span v-if="row.isDefault" class="addr-default-badge">
|
||||
<IconVerified :size="16" />
|
||||
پیشفرض ارسال
|
||||
</span>
|
||||
<strong class="addr-card__label">{{ row.label || 'آدرس' }}</strong>
|
||||
</div>
|
||||
<p class="addr-card__text">{{ row.text }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="addr-card__actions">
|
||||
<button
|
||||
v-if="!row.isDefault"
|
||||
type="button"
|
||||
class="addr-icon-btn"
|
||||
aria-label="انتخاب بهعنوان آدرس پیشفرض"
|
||||
title="پیشفرض"
|
||||
@click="makeDefault(row.id)"
|
||||
>
|
||||
<IconVerified :size="20" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="addr-icon-btn addr-icon-btn--danger"
|
||||
aria-label="حذف آدرس"
|
||||
title="حذف"
|
||||
@click="remove(row.id)"
|
||||
>
|
||||
<IconTrash :size="20" />
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div v-else class="addr-empty">
|
||||
<IconMapPin :size="40" class="addr-empty__icon" />
|
||||
<p class="addr-muted">هنوز آدرسی ثبت نشده است.</p>
|
||||
<BaseButton size="sm" variant="outline" @click="openAddForm">افزودن اولین آدرس</BaseButton>
|
||||
</div>
|
||||
</ProfileSubpageLayout>
|
||||
|
||||
<!-- Mobile: action sheet -->
|
||||
<Teleport to="body">
|
||||
<Transition name="addr-sheet">
|
||||
<div
|
||||
v-if="addOpen && !isDesktop"
|
||||
class="addr-add-panel"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="addr-add-title-mobile"
|
||||
@click.self="closeAddForm"
|
||||
>
|
||||
<div class="addr-add-sheet">
|
||||
<div class="addr-add-sheet__handle" aria-hidden="true" />
|
||||
<header class="addr-add-sheet__head">
|
||||
<h2 id="addr-add-title-mobile">آدرس جدید</h2>
|
||||
<button type="button" class="addr-add-sheet__close" aria-label="بستن" @click="closeAddForm">
|
||||
×
|
||||
</button>
|
||||
</header>
|
||||
<form class="addr-form" @submit.prevent="add">
|
||||
<label class="addr-field">
|
||||
<span>عنوان (اختیاری)</span>
|
||||
<input v-model="label" type="text" maxlength="40" placeholder="مثلاً فروشگاه" />
|
||||
</label>
|
||||
<label class="addr-field">
|
||||
<span>آدرس</span>
|
||||
<textarea
|
||||
v-model="text"
|
||||
rows="3"
|
||||
maxlength="500"
|
||||
placeholder="آدرس کامل محل فعالیت"
|
||||
/>
|
||||
</label>
|
||||
<p v-if="formError" class="addr-error" role="alert">{{ formError }}</p>
|
||||
<BaseButton type="submit" class="addr-form__submit" :loading="saving">
|
||||
افزودن آدرس
|
||||
</BaseButton>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
|
||||
<!-- Desktop: modal -->
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="addOpen && isDesktop"
|
||||
class="dialog-overlay addr-add-overlay"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="addr-add-title-desktop"
|
||||
@click.self="closeAddForm"
|
||||
>
|
||||
<div class="dialog card addr-add-modal">
|
||||
<h2 id="addr-add-title-desktop" class="addr-add-modal__title">آدرس جدید</h2>
|
||||
<p class="addr-add-modal__hint">آدرس کامل محل فعالیت را وارد کنید.</p>
|
||||
<form class="addr-form" @submit.prevent="add">
|
||||
<label class="addr-field">
|
||||
<span>عنوان (اختیاری)</span>
|
||||
<input v-model="label" type="text" maxlength="40" placeholder="مثلاً فروشگاه" />
|
||||
</label>
|
||||
<label class="addr-field">
|
||||
<span>آدرس</span>
|
||||
<textarea
|
||||
v-model="text"
|
||||
rows="3"
|
||||
maxlength="500"
|
||||
placeholder="آدرس کامل محل فعالیت"
|
||||
/>
|
||||
</label>
|
||||
<p v-if="formError" class="addr-error" role="alert">{{ formError }}</p>
|
||||
<div class="dialog-actions addr-add-modal__actions">
|
||||
<BaseButton type="button" variant="outline" :disabled="saving" @click="closeAddForm">
|
||||
انصراف
|
||||
</BaseButton>
|
||||
<BaseButton type="submit" :loading="saving">افزودن آدرس</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.addresses-page :deep(.profile-subpage__card.card) {
|
||||
background: var(--color-bg);
|
||||
border: none;
|
||||
}
|
||||
|
||||
.addresses-page :deep(.profile-subpage__nav) {
|
||||
background: var(--color-bg);
|
||||
}
|
||||
|
||||
.addresses-page :deep(.profile-subpage-desktop__panel.card) {
|
||||
background: var(--color-bg);
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.addresses-page__toolbar {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.addresses-page__hint {
|
||||
margin: 0;
|
||||
flex: 1;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.addresses-page__new-btn {
|
||||
flex-shrink: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.addr-error {
|
||||
margin: 0 0 12px;
|
||||
color: var(--color-danger);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.addr-muted {
|
||||
margin: 0;
|
||||
color: var(--color-text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.addr-list {
|
||||
list-style: none;
|
||||
margin: 0 0 16px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.addr-item {
|
||||
.addr-card {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
padding: 14px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 14px;
|
||||
background: var(--color-elevated);
|
||||
}
|
||||
|
||||
.addr-card--default {
|
||||
border-color: rgba(var(--color-primary-rgb), 0.45);
|
||||
background: var(--color-primary-soft);
|
||||
box-shadow: 0 0 0 1px rgba(var(--color-primary-rgb), 0.08);
|
||||
}
|
||||
|
||||
.addr-card__main {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.addr-card__icon {
|
||||
flex-shrink: 0;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.addr-item p {
|
||||
margin: 6px 0 0;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.addr-badge {
|
||||
margin-right: 8px;
|
||||
font-size: 0.75rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--color-bg);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.addr-actions {
|
||||
.addr-card--default .addr-card__icon {
|
||||
background: var(--color-elevated);
|
||||
}
|
||||
|
||||
.addr-card__body {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.addr-card__head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.addr-default-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 700;
|
||||
color: var(--color-primary);
|
||||
background: var(--color-elevated);
|
||||
}
|
||||
|
||||
.addr-card--default .addr-default-badge {
|
||||
background: rgba(var(--color-primary-rgb), 0.12);
|
||||
}
|
||||
|
||||
.addr-card__label {
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.addr-card__text {
|
||||
margin: 8px 0 0;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.65;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.addr-card__actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.addr-actions button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
.addr-icon-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
background: var(--color-bg);
|
||||
color: var(--color-primary);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
transition: background 0.15s ease, color 0.15s ease;
|
||||
}
|
||||
|
||||
.addr-remove {
|
||||
color: var(--color-danger) !important;
|
||||
.addr-card--default .addr-icon-btn {
|
||||
background: var(--color-elevated);
|
||||
}
|
||||
|
||||
.addr-icon-btn:hover {
|
||||
background: var(--color-primary-soft);
|
||||
}
|
||||
|
||||
.addr-icon-btn--danger {
|
||||
color: var(--color-danger);
|
||||
}
|
||||
|
||||
.addr-icon-btn--danger:hover {
|
||||
background: rgba(220, 38, 38, 0.1);
|
||||
}
|
||||
|
||||
.addr-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 32px 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.addr-empty__icon {
|
||||
color: var(--color-text-muted);
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.addr-field {
|
||||
@@ -173,6 +476,126 @@ async function remove(id: string) {
|
||||
font: inherit;
|
||||
font-weight: 400;
|
||||
color: var(--color-text);
|
||||
background: transparent;
|
||||
background: var(--color-elevated);
|
||||
}
|
||||
|
||||
.addr-form__submit {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Mobile sheet */
|
||||
.addr-add-panel {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 200;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.addr-add-sheet {
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
max-height: min(88dvh, 640px);
|
||||
overflow-y: auto;
|
||||
background: var(--color-elevated);
|
||||
color: var(--color-text);
|
||||
border-radius: 20px 20px 0 0;
|
||||
padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.addr-add-sheet__handle {
|
||||
width: 40px;
|
||||
height: 4px;
|
||||
border-radius: 999px;
|
||||
background: var(--color-border);
|
||||
margin: 4px auto 12px;
|
||||
}
|
||||
|
||||
.addr-add-sheet__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.addr-add-sheet__head h2 {
|
||||
margin: 0;
|
||||
font-size: 1.0625rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.addr-add-sheet__close {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
background: var(--color-bg);
|
||||
color: var(--color-text);
|
||||
font-size: 1.4rem;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.addr-sheet-enter-active,
|
||||
.addr-sheet-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.addr-sheet-enter-active .addr-add-sheet,
|
||||
.addr-sheet-leave-active .addr-add-sheet {
|
||||
transition: transform 0.24s ease;
|
||||
}
|
||||
|
||||
.addr-sheet-enter-from,
|
||||
.addr-sheet-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.addr-sheet-enter-from .addr-add-sheet,
|
||||
.addr-sheet-leave-to .addr-add-sheet {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
/* Desktop modal */
|
||||
.addr-add-overlay {
|
||||
z-index: 200;
|
||||
}
|
||||
|
||||
.addr-add-modal {
|
||||
padding: 24px;
|
||||
max-width: min(440px, calc(100vw - 48px));
|
||||
}
|
||||
|
||||
.addr-add-modal__title {
|
||||
margin: 0 0 6px;
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.addr-add-modal__hint {
|
||||
margin: 0 0 16px;
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.addr-add-modal__actions {
|
||||
flex-direction: row-reverse;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.addr-card__actions {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.addresses-page__toolbar {
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { addressesApi } from '@/services/addresses'
|
||||
import BaseInput from '@/components/ui/BaseInput.vue'
|
||||
import FormErrorBanner from '@/components/ui/FormErrorBanner.vue'
|
||||
import BaseButton from '@/components/ui/BaseButton.vue'
|
||||
@@ -14,8 +16,13 @@ import {
|
||||
hasFieldErrors,
|
||||
type FieldErrors,
|
||||
} from '@/utils/formErrors'
|
||||
import { useAppToast } from '@/composables/useAppToast'
|
||||
import { ApiError } from '@/services/http'
|
||||
|
||||
const auth = useAuthStore()
|
||||
const router = useRouter()
|
||||
const savedAddressText = ref<string | null>(null)
|
||||
const savedAddressLoading = ref(true)
|
||||
|
||||
const firstName = ref(auth.user?.firstName ?? '')
|
||||
const lastName = ref(auth.user?.lastName ?? '')
|
||||
@@ -26,7 +33,9 @@ const fileInput = ref<HTMLInputElement | null>(null)
|
||||
const fieldErrors = ref<FieldErrors>({})
|
||||
const formError = ref('')
|
||||
const saved = ref(false)
|
||||
const saving = ref(false)
|
||||
const photoBusy = ref(false)
|
||||
const toast = useAppToast()
|
||||
|
||||
const initials = computed(() => {
|
||||
const first = firstName.value.trim().charAt(0)
|
||||
@@ -79,6 +88,19 @@ async function removeAvatar() {
|
||||
await persistAvatar(null)
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
savedAddressLoading.value = true
|
||||
try {
|
||||
const rows = await addressesApi.list()
|
||||
const preferred = rows.find((r) => r.isDefault) ?? rows[0]
|
||||
savedAddressText.value = preferred?.text ?? null
|
||||
} catch {
|
||||
savedAddressText.value = null
|
||||
} finally {
|
||||
savedAddressLoading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
async function save() {
|
||||
fieldErrors.value = {}
|
||||
formError.value = ''
|
||||
@@ -94,6 +116,7 @@ async function save() {
|
||||
if (hasFieldErrors(errors)) {
|
||||
fieldErrors.value = errors
|
||||
formError.value = FORM_VALIDATION_SUMMARY
|
||||
toast.show('لطفاً فیلدهای مشخصشده را اصلاح کنید.', { tone: 'error' })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -107,15 +130,31 @@ async function save() {
|
||||
payload.address = address.value.trim()
|
||||
}
|
||||
|
||||
const updated = await auth.updateProfile(payload)
|
||||
if (!updated) {
|
||||
formError.value = 'ذخیره پروفایل ناموفق بود.'
|
||||
return
|
||||
saving.value = true
|
||||
try {
|
||||
const updated = await auth.updateProfile(payload)
|
||||
if (!updated) {
|
||||
formError.value = 'ذخیره پروفایل ناموفق بود.'
|
||||
toast.show('ذخیره اطلاعات انجام نشد. دوباره تلاش کنید.', { tone: 'error' })
|
||||
return
|
||||
}
|
||||
saved.value = true
|
||||
toast.show('اطلاعات کاربری با موفقیت ذخیره شد.')
|
||||
setTimeout(() => {
|
||||
saved.value = false
|
||||
}, 2000)
|
||||
} catch (e) {
|
||||
const msg =
|
||||
e instanceof ApiError
|
||||
? e.message
|
||||
: e instanceof Error
|
||||
? e.message
|
||||
: 'ذخیره پروفایل ناموفق بود.'
|
||||
formError.value = msg
|
||||
toast.show(msg, { tone: 'error' })
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
saved.value = true
|
||||
setTimeout(() => {
|
||||
saved.value = false
|
||||
}, 2000)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -191,7 +230,7 @@ async function save() {
|
||||
@update:model-value="clearField('nationalId')"
|
||||
/>
|
||||
<div v-if="auth.isAgent" class="form-group profile-edit__full">
|
||||
<label class="form-label" for="profile-address">آدرس</label>
|
||||
<label class="form-label" for="profile-address">آدرس (واسطه)</label>
|
||||
<textarea
|
||||
id="profile-address"
|
||||
v-model="address"
|
||||
@@ -203,10 +242,28 @@ async function save() {
|
||||
/>
|
||||
<p v-if="fieldErrors.address" class="input-error-text">{{ fieldErrors.address }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="form-group profile-edit__full profile-edit__saved-address">
|
||||
<label class="form-label">آدرس ثبتشده</label>
|
||||
<p v-if="savedAddressLoading" class="profile-edit__address-hint">در حال بارگذاری…</p>
|
||||
<p v-else-if="savedAddressText" class="profile-edit__address-text">{{ savedAddressText }}</p>
|
||||
<p v-else class="profile-edit__address-hint">
|
||||
هنوز آدرسی ثبت نشده. هنگام درخواست کالیته یا از بخش «آدرسها» میتوانید آدرس اضافه کنید.
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="profile-edit__address-link"
|
||||
@click="router.push('/profile/addresses')"
|
||||
>
|
||||
مدیریت آدرسها
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="profile-edit__actions">
|
||||
<BaseButton class="profile-edit__save" @click="save">ذخیره تغییرات</BaseButton>
|
||||
<BaseButton class="profile-edit__save" :loading="saving" @click="save">
|
||||
ذخیره تغییرات
|
||||
</BaseButton>
|
||||
<p v-if="saved" class="profile-edit__saved">ذخیره شد ✓</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -395,4 +452,37 @@ async function save() {
|
||||
font-size: 0.8125rem;
|
||||
margin: 4px 0 0;
|
||||
}
|
||||
|
||||
.profile-edit__saved-address {
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--color-bg);
|
||||
}
|
||||
|
||||
.profile-edit__address-text {
|
||||
margin: 6px 0 10px;
|
||||
font-size: 0.9375rem;
|
||||
line-height: 1.65;
|
||||
color: var(--color-text);
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.profile-edit__address-hint {
|
||||
margin: 6px 0 10px;
|
||||
font-size: 0.8125rem;
|
||||
line-height: 1.6;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.profile-edit__address-link {
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
font: inherit;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { onClickOutside } from '@vueuse/core'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { fetchReminders } from '@/services/agentApi'
|
||||
import { useCrmStore } from '@/stores/crm'
|
||||
@@ -13,6 +12,8 @@ import IconChevronBack from '@/components/icons/IconChevronBack.vue'
|
||||
import { useGoBack } from '@/composables/useGoBack'
|
||||
import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import PersianDateInput from '@/components/ui/PersianDateInput.vue'
|
||||
import AppSelect from '@/components/ui/AppSelect.vue'
|
||||
import TimeInput from '@/components/ui/TimeInput.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -34,23 +35,12 @@ const form = ref({
|
||||
time: '10:00',
|
||||
note: '',
|
||||
})
|
||||
const customerOpen = ref(false)
|
||||
const customerRoot = ref<HTMLElement | null>(null)
|
||||
|
||||
const selectedCustomerLabel = computed(() => {
|
||||
if (!form.value.customerId) return 'انتخاب مشتری'
|
||||
const customer = customers.value.find((item) => item.id === form.value.customerId)
|
||||
return customer?.name || customer?.contactName || 'انتخاب مشتری'
|
||||
})
|
||||
|
||||
onClickOutside(customerRoot, () => {
|
||||
customerOpen.value = false
|
||||
})
|
||||
|
||||
function selectCustomer(id: string) {
|
||||
form.value.customerId = id
|
||||
customerOpen.value = false
|
||||
}
|
||||
const customerOptions = computed(() =>
|
||||
customers.value.map((customer) => ({
|
||||
value: customer.id,
|
||||
label: customer.name || customer.contactName || customer.id,
|
||||
})),
|
||||
)
|
||||
|
||||
const filters: Array<{ id: ReminderFilter; label: string }> = [
|
||||
{ id: 'all', label: 'همه' },
|
||||
@@ -134,7 +124,6 @@ function typeClass(type: MeetingInteractionType) {
|
||||
async function openCreate() {
|
||||
showCreate.value = true
|
||||
completedExpanded.value = false
|
||||
customerOpen.value = false
|
||||
error.value = null
|
||||
try {
|
||||
customers.value = await crm.loadCustomers()
|
||||
@@ -248,54 +237,21 @@ function toggleCompleted() {
|
||||
<section v-if="showCreate" class="create-panel">
|
||||
<h3>یادآور جدید</h3>
|
||||
<p v-if="error" class="create-error">{{ error }}</p>
|
||||
<label>
|
||||
مشتری
|
||||
<div ref="customerRoot" class="field-select">
|
||||
<button
|
||||
type="button"
|
||||
class="field-select__trigger"
|
||||
:class="{ 'is-open': customerOpen }"
|
||||
aria-haspopup="listbox"
|
||||
:aria-expanded="customerOpen"
|
||||
@click="customerOpen = !customerOpen"
|
||||
>
|
||||
<span :class="{ 'is-placeholder': !form.customerId }">{{ selectedCustomerLabel }}</span>
|
||||
<svg class="field-select__chevron" viewBox="0 0 12 12" aria-hidden="true">
|
||||
<path
|
||||
d="M2.5 4.5 6 8l3.5-3.5"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<ul v-if="customerOpen" class="field-select__menu" role="listbox">
|
||||
<li v-for="customer in customers" :key="customer.id">
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
class="field-select__option"
|
||||
:class="{ 'is-active': form.customerId === customer.id }"
|
||||
:aria-selected="form.customerId === customer.id"
|
||||
@click="selectCustomer(customer.id)"
|
||||
>
|
||||
{{ customer.name || customer.contactName }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</label>
|
||||
<AppSelect
|
||||
v-model="form.customerId"
|
||||
label="مشتری"
|
||||
placeholder="انتخاب مشتری"
|
||||
aria-label="مشتری"
|
||||
searchable
|
||||
:options="customerOptions"
|
||||
/>
|
||||
<label>
|
||||
عنوان
|
||||
<input v-model="form.title" type="text" placeholder="مثلاً پیگیری نمونه" />
|
||||
</label>
|
||||
<div class="create-row">
|
||||
<PersianDateInput v-model="form.date" label="تاریخ" class="create-date" />
|
||||
<label>
|
||||
ساعت
|
||||
<input v-model="form.time" type="time" />
|
||||
</label>
|
||||
<TimeInput v-model="form.time" label="ساعت" placeholder="مثلاً ۱۰:۳۰" />
|
||||
</div>
|
||||
<label>
|
||||
یادداشت
|
||||
@@ -904,83 +860,6 @@ function toggleCompleted() {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.field-select {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.field-select__trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
height: var(--btn-height);
|
||||
padding: 0 14px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
font-size: 0.9375rem;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
|
||||
.field-select__trigger.is-open {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.field-select__trigger .is-placeholder {
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.field-select__chevron {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
color: var(--color-text-muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.field-select__trigger.is-open .field-select__chevron {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.field-select__menu {
|
||||
position: absolute;
|
||||
inset-inline: 0;
|
||||
top: calc(100% + 6px);
|
||||
z-index: 20;
|
||||
margin: 0;
|
||||
padding: 6px;
|
||||
list-style: none;
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
|
||||
max-height: 220px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.field-select__option {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
background: transparent;
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
font-size: 0.875rem;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.field-select__option.is-active {
|
||||
background: var(--color-primary-light);
|
||||
color: var(--color-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.create-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
|
||||
Reference in New Issue
Block a user