Initial admin edits
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useMediaQuery } from '@vueuse/core'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useCrmStore } from '@/stores/crm'
|
||||
@@ -24,6 +25,8 @@ import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import UserAvatar from '@/components/ui/UserAvatar.vue'
|
||||
import HomeSuggestionsSection from '@/components/home/HomeSuggestionsSection.vue'
|
||||
import { useTouchSwipe } from '@/composables/useTouchSwipe'
|
||||
import { isProductUnavailable } from '@/utils/productAvailability'
|
||||
import { followBannerLink } from '@/utils/bannerLink'
|
||||
|
||||
const router = useRouter()
|
||||
const { goBack } = useGoBack('/')
|
||||
@@ -77,6 +80,7 @@ const suggestionsForHome = computed(() => {
|
||||
colorImages: item.colorImages?.some(Boolean)
|
||||
? item.colorImages
|
||||
: product?.colorImages,
|
||||
productIsActive: item.productIsActive ?? product?.isActive,
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -101,6 +105,8 @@ let bannerTimer: number | undefined
|
||||
|
||||
const banner = computed(() => banners.value[bannerIndex.value] ?? FALLBACK_BANNER)
|
||||
|
||||
const bannerImageLink = computed(() => banner.value.bannerLink?.trim() || '')
|
||||
|
||||
const heroHasCopy = computed(() => {
|
||||
const item = banner.value
|
||||
return (
|
||||
@@ -156,6 +162,12 @@ const { onTouchStart: onHeroTouchStart, onTouchEnd: onHeroTouchEnd } = useTouchS
|
||||
|
||||
const displayFirst = computed(() => auth.user?.firstName || 'کاربر')
|
||||
const displayLast = computed(() => auth.user?.lastName || '')
|
||||
|
||||
const isNarrowHeader = useMediaQuery('(max-width: 467px)')
|
||||
const homeAvatarSize = computed(() => (isNarrowHeader.value ? 36 : 44))
|
||||
const homeGreetingName = computed(() =>
|
||||
isNarrowHeader.value ? displayFirst.value : `${displayFirst.value} ${displayLast.value}`.trim(),
|
||||
)
|
||||
const homeLevel = computed(() => {
|
||||
if (agentLevel.value) return agentLevel.value
|
||||
const u = auth.user
|
||||
@@ -223,6 +235,13 @@ function goBanner() {
|
||||
go(banner.value.ctaLink.trim() || '/categories')
|
||||
}
|
||||
|
||||
function onHeroBannerClick(event: MouseEvent) {
|
||||
if (!bannerImageLink.value) return
|
||||
const target = event.target as HTMLElement
|
||||
if (target.closest('.hero-banner__cta, .hero-banner__dots')) return
|
||||
followBannerLink(bannerImageLink.value, router)
|
||||
}
|
||||
|
||||
async function toggleFavorite(productId: string) {
|
||||
favError.value = null
|
||||
try {
|
||||
@@ -244,11 +263,11 @@ async function toggleFavorite(productId: string) {
|
||||
class="home-header__avatar"
|
||||
:src="auth.user?.avatarUrl"
|
||||
:initials="displayFirst.charAt(0)"
|
||||
:size="44"
|
||||
:size="homeAvatarSize"
|
||||
/>
|
||||
<div>
|
||||
<div class="home-header__text">
|
||||
<p class="home-header__hello">
|
||||
سلام، {{ displayFirst }} {{ displayLast }}
|
||||
سلام، {{ homeGreetingName }}
|
||||
</p>
|
||||
<p class="home-header__welcome">خوش آمدید</p>
|
||||
</div>
|
||||
@@ -279,7 +298,9 @@ async function toggleFavorite(productId: string) {
|
||||
<template v-else>
|
||||
<section
|
||||
class="hero-banner"
|
||||
:class="{ 'hero-banner--linked': !!bannerImageLink }"
|
||||
:aria-label="banner.title"
|
||||
@click="onHeroBannerClick"
|
||||
@touchstart.passive="onHeroTouchStart"
|
||||
@touchend.passive="onHeroTouchEnd"
|
||||
>
|
||||
@@ -306,7 +327,7 @@ async function toggleFavorite(productId: string) {
|
||||
v-if="banner.showCta !== false && banner.ctaLabel"
|
||||
type="button"
|
||||
class="hero-banner__cta"
|
||||
@click="goBanner"
|
||||
@click.stop="goBanner"
|
||||
>
|
||||
{{ banner.ctaLabel }}
|
||||
</button>
|
||||
@@ -322,7 +343,7 @@ async function toggleFavorite(productId: string) {
|
||||
:class="{ 'dot--active': index === bannerIndex }"
|
||||
:aria-label="item.title"
|
||||
:aria-selected="index === bannerIndex"
|
||||
@click="setBanner(index)"
|
||||
@click.stop="setBanner(index)"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
@@ -409,7 +430,11 @@ async function toggleFavorite(productId: string) {
|
||||
:class="`product-card__image--${index % 3}`"
|
||||
:style="item.imageUrl ? { backgroundImage: `url(${item.imageUrl})` } : undefined"
|
||||
>
|
||||
<span v-if="item.isNew" class="product-card__badge">جدید</span>
|
||||
<span
|
||||
v-if="isProductUnavailable(item)"
|
||||
class="product-card__badge product-card__badge--oos"
|
||||
>ناموجود</span>
|
||||
<span v-else-if="item.isNew" class="product-card__badge">جدید</span>
|
||||
</div>
|
||||
<div class="product-card__body">
|
||||
<strong class="product-card__name">{{ item.name }}</strong>
|
||||
@@ -471,10 +496,15 @@ async function toggleFavorite(productId: string) {
|
||||
}
|
||||
|
||||
.home-header__avatar {
|
||||
flex-shrink: 0;
|
||||
background: var(--color-primary-soft);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.home-header__text {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.home-header__hello {
|
||||
margin: 0;
|
||||
font-size: 0.95rem;
|
||||
@@ -518,6 +548,10 @@ async function toggleFavorite(productId: string) {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.hero-banner--linked {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hero-banner {
|
||||
--hero-image: #8a7a65;
|
||||
position: relative;
|
||||
@@ -928,6 +962,10 @@ html.dark .quick-card__label {
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.product-card__badge--oos {
|
||||
background: #b91c1c;
|
||||
}
|
||||
|
||||
.product-card__body {
|
||||
position: relative;
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user