Initial admin edits
This commit is contained in:
@@ -24,6 +24,8 @@ import {
|
||||
import { formatNumber } from '@/utils/format'
|
||||
import { colorSwatchStyle } from '@/utils/colorSwatch'
|
||||
import { demoProductsFor, findMockCalite } from '@/data/caliteCollections'
|
||||
import { isProductUnavailable } from '@/utils/productAvailability'
|
||||
import { useAppToast } from '@/composables/useAppToast'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -32,6 +34,7 @@ const catalogStore = useCatalogStore()
|
||||
const crm = useCrmStore()
|
||||
const cartStore = useCartStore()
|
||||
const favorites = useFavoritesStore()
|
||||
const appToast = useAppToast()
|
||||
|
||||
const catalogId = computed(() => String(route.params.catalogId ?? ''))
|
||||
const catalog = ref<Catalog | null>(null)
|
||||
@@ -39,7 +42,6 @@ const products = ref<CatalogProductCard[]>([])
|
||||
const loading = ref(true)
|
||||
const error = ref<string | null>(null)
|
||||
const adding = ref(false)
|
||||
const toast = ref('')
|
||||
const tab = ref<'all' | PatternKind>('all')
|
||||
|
||||
const title = computed(() => catalogDisplayTitle(catalog.value?.name || 'کالیته'))
|
||||
@@ -186,18 +188,18 @@ function toCartProduct(item: CatalogProductCard): Product {
|
||||
minMeterage: item.minMeterage ?? 30,
|
||||
orderMultiplier: item.orderMultiplier ?? 10,
|
||||
basePrice: item.basePrice,
|
||||
isActive: true,
|
||||
isActive: item.isActive !== false,
|
||||
}
|
||||
}
|
||||
|
||||
async function addAllToInquiry() {
|
||||
if (!products.value.length || adding.value) return
|
||||
adding.value = true
|
||||
toast.value = ''
|
||||
let added = 0
|
||||
let failed = ''
|
||||
try {
|
||||
for (const item of products.value) {
|
||||
if (isProductUnavailable(item)) continue
|
||||
const product = toCartProduct(item)
|
||||
const result = await cartStore.addItem(
|
||||
product,
|
||||
@@ -207,11 +209,16 @@ async function addAllToInquiry() {
|
||||
if (result.success) added += 1
|
||||
else failed = result.message || failed
|
||||
}
|
||||
toast.value = added
|
||||
const text = added
|
||||
? `${formatNumber(added)} طرح به سبد استعلام اضافه شد.`
|
||||
: failed || 'افزودن به سبد ناموفق بود.'
|
||||
if (added) {
|
||||
window.setTimeout(() => router.push('/cart'), 650)
|
||||
appToast.show(text, {
|
||||
tone: 'success',
|
||||
onDismiss: () => router.push('/cart'),
|
||||
})
|
||||
} else {
|
||||
appToast.show(text, { tone: failed ? 'error' : 'warning' })
|
||||
}
|
||||
} finally {
|
||||
adding.value = false
|
||||
@@ -348,6 +355,10 @@ async function addAllToInquiry() {
|
||||
class="pattern-card__photo"
|
||||
:style="pattern.imageUrl ? { backgroundImage: `url(${pattern.imageUrl})` } : undefined"
|
||||
>
|
||||
<span
|
||||
v-if="pattern.items.every((p) => isProductUnavailable(p))"
|
||||
class="pattern-card__oos"
|
||||
>ناموجود</span>
|
||||
<button
|
||||
type="button"
|
||||
class="pattern-card__fav"
|
||||
@@ -394,7 +405,6 @@ async function addAllToInquiry() {
|
||||
<small>{{ formatNumber(patterns.length) }} طرح انتخاب میشود</small>
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="toast" class="toast">{{ toast }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -662,6 +672,19 @@ async function addAllToInquiry() {
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.pattern-card__oos {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
inset-inline-end: 8px;
|
||||
z-index: 1;
|
||||
padding: 3px 8px;
|
||||
border-radius: 999px;
|
||||
background: #b91c1c;
|
||||
color: #fff;
|
||||
font-size: 0.65rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.pattern-card__fav {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
@@ -749,20 +772,6 @@ async function addAllToInquiry() {
|
||||
color: #8a847c;
|
||||
}
|
||||
|
||||
.toast {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
bottom: calc(var(--nav-height) + 84px);
|
||||
z-index: 20;
|
||||
transform: translateX(-50%);
|
||||
padding: 8px 14px;
|
||||
border-radius: 999px;
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
font-size: 0.75rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
html.dark .calite-detail {
|
||||
background: #0b0f14;
|
||||
color: #eef2f8;
|
||||
@@ -912,10 +921,6 @@ html.dark .calite-detail__footer.sticky-footer {
|
||||
margin-inline: auto;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.toast {
|
||||
bottom: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
|
||||
Reference in New Issue
Block a user