Unify store-closed messaging when the market is closed or has no quote.

Treat missing quotes as closed across home and products, show only the admin closed_message as hint, and block trading with consistent notices.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-11 12:42:56 +02:00
co-authored by Cursor
parent 1000df5931
commit 0109f3a744
12 changed files with 99 additions and 82 deletions
+3 -3
View File
@@ -242,7 +242,7 @@ import { calcFeeInGrams, calcPayablePriceRial, calcSellGoldDebit, feeDeductFromG
import { resolveProductCashFeeBuyRial, resolveProductCashFeeSellRial } from '@/utils/productCashFee'
import { formatCashWalletBalanceText, formatGoldWalletBalanceText } from '@/utils/productDealMethod'
import { getCashWalletBalance } from '@/utils/productAssets'
import { isStoreClosed, getStoreClosedMessage } from '@/utils/storeHours'
import { isStoreClosed, resolveStoreClosedNotice } from '@/utils/storeHours'
import { resetTransactionsPageData } from '@/views/base/transactions/composables/useTransactionsPageData'
const infoVisible = ref(false)
@@ -663,7 +663,7 @@ async function initPrice() {
function okConfirm() {
if (isStoreClosed()) {
message.warning(getStoreClosedMessage())
message.warning(resolveStoreClosedNotice(userStore.getValueByKey('closed_message')))
return
}
confirmAction.value = true
@@ -671,7 +671,7 @@ function okConfirm() {
async function ok() {
if (isStoreClosed()) {
message.warning(getStoreClosedMessage())
message.warning(resolveStoreClosedNotice(userStore.getValueByKey('closed_message')))
return
}
try {
+3 -3
View File
@@ -346,7 +346,7 @@ import {
serviceFeePercentage,
type TradeInputLock,
} from '@/utils/serviceFee'
import { isStoreClosed, getStoreClosedMessage } from '@/utils/storeHours'
import { isStoreClosed, resolveStoreClosedNotice } from '@/utils/storeHours'
import { resetTransactionsPageData } from '@/views/base/transactions/composables/useTransactionsPageData'
import { formatCashWalletBalanceText, getWeightUnit } from '@/utils/productDealMethod'
import { formatProductWalletBalanceText, getCashWalletBalance, getProductInventoryQuantity } from '@/utils/productAssets'
@@ -776,7 +776,7 @@ async function initPrice() {
function okConfirm() {
if (isStoreClosed()) {
message.warning(getStoreClosedMessage())
message.warning(resolveStoreClosedNotice(userStore.getValueByKey('closed_message')))
return
}
if (cashValidationMessage.value) {
@@ -791,7 +791,7 @@ async function ok() {
return
}
if (isStoreClosed()) {
message.warning(getStoreClosedMessage())
message.warning(resolveStoreClosedNotice(userStore.getValueByKey('closed_message')))
return
}
try {
@@ -13,7 +13,7 @@
/>
</div>
<div class="status-box__title">{{ statusTitle }}</div>
<div class="status-box__hint">{{ statusHint }}</div>
<div v-if="statusHint" class="status-box__hint">{{ statusHint }}</div>
</div>
</template>
@@ -55,8 +55,9 @@ import { useUserStore } from '@/store/userStore'
import { getTradeBuyPrice, lastPrice, percentPriceChanged, price } from '@/utils/price'
import {
NO_QUOTE_MESSAGE,
STORE_CLOSED_TITLE,
getPriceDisplayState,
getStoreClosedMessage,
getStoreClosedHint,
} from '@/utils/storeHours'
import Vue3Odometer from 'vue3-odometer'
import 'odometer/themes/odometer-theme-default.css'
@@ -67,16 +68,12 @@ const userStore = useUserStore()
const displayState = computed(() => getPriceDisplayState())
const statusTitle = computed(() =>
displayState.value === 'closed' ? 'فروشگاه بسته است' : NO_QUOTE_MESSAGE
displayState.value === 'closed' ? STORE_CLOSED_TITLE : NO_QUOTE_MESSAGE
)
const statusHint = computed(() => {
if (displayState.value === 'closed') {
const custom = userStore.getValueByKey('closed_message')
if (typeof custom === 'string' && custom.trim()) {
return custom.replace(/<[^>]*>/g, '').trim()
}
return getStoreClosedMessage()
return getStoreClosedHint(userStore.getValueByKey('closed_message'))
}
return 'در حال حاضر مظنه‌ای برای نمایش وجود ندارد.'
})
@@ -12,7 +12,7 @@ import {
} from '@/utils/productAssets'
import { useSettingsStore } from '@/store/settingsStore'
import { getTradeBuyPrice, lastPrice, stopLastPricePolling } from '@/utils/price'
import { getStoreClosedMessage, isStoreClosed } from '@/utils/storeHours'
import { isStoreClosed } from '@/utils/storeHours'
import { message, Modal } from 'ant-design-vue'
import { useBanners } from './useBanners'
import { usePriceChart, type ChartMetalType } from './usePriceChart'
@@ -74,7 +74,7 @@ export function useHomePage() {
const closedMessage = computed(() => userStore.getValueByKey('closed_message'))
const marketClosedText = computed(() => {
if (!isStoreClosed()) return ''
// فقط پیام سفارشی ادمین رو نشون بده — پیام ساعت کاری در CurrentPrice نمایش داده میشه
// فقط پیام سفارشی ادمین — در CurrentPrice نمایش داده می‌شود
const custom = typeof closedMessage.value === 'string' ? closedMessage.value.trim() : ''
return custom || ''
})
@@ -16,7 +16,7 @@
/>
</div>
<p class="dhome-hero-price__closed-title">{{ statusTitle }}</p>
<p class="dhome-hero-price__closed-hint">{{ statusHint }}</p>
<p v-if="statusHint" class="dhome-hero-price__closed-hint">{{ statusHint }}</p>
</div>
</template>
@@ -55,8 +55,9 @@ import { useUserStore } from '@/store/userStore'
import { getTradeBuyPrice, lastPrice, percentPriceChanged } from '@/utils/price'
import {
NO_QUOTE_MESSAGE,
STORE_CLOSED_TITLE,
getPriceDisplayState,
getStoreClosedMessage,
getStoreClosedHint,
} from '@/utils/storeHours'
import { formatSignedPercentChange } from '@/utils/usePrice'
@@ -65,16 +66,12 @@ const userStore = useUserStore()
const displayState = computed(() => getPriceDisplayState())
const statusTitle = computed(() =>
displayState.value === 'closed' ? 'فروشگاه بسته است' : NO_QUOTE_MESSAGE
displayState.value === 'closed' ? STORE_CLOSED_TITLE : NO_QUOTE_MESSAGE
)
const statusHint = computed(() => {
if (displayState.value === 'closed') {
const custom = userStore.getValueByKey('closed_message')
if (typeof custom === 'string' && custom.trim()) {
return custom.replace(/<[^>]*>/g, '').trim()
}
return getStoreClosedMessage()
return getStoreClosedHint(userStore.getValueByKey('closed_message'))
}
return 'در حال حاضر مظنه‌ای برای نمایش وجود ندارد.'
})
@@ -321,7 +321,7 @@ import {
} from '@/utils/productOrderLimit'
import { useWalletAssets } from '@/composables/useWalletAssets'
import { formatProductWalletBalanceText, formatInventoryCardValue, getCashWalletBalance, getProductInventoryQuantity } from '@/utils/productAssets'
import { isStoreClosed, getStoreClosedMessage } from '@/utils/storeHours'
import { isStoreClosed, resolveStoreClosedNotice } from '@/utils/storeHours'
const catalogProducts = getProductsCatalogRef()
@@ -864,7 +864,7 @@ async function initPrice() {
function okConfirm() {
if (isStoreClosed()) {
message.warning(getStoreClosedMessage())
message.warning(resolveStoreClosedNotice(userStore.getValueByKey('closed_message')))
return
}
confirmAction.value = true
@@ -873,7 +873,7 @@ function okConfirm() {
async function ok() {
if (isStoreClosed()) {
message.warning(getStoreClosedMessage())
message.warning(resolveStoreClosedNotice(userStore.getValueByKey('closed_message')))
return
}
try {
@@ -13,7 +13,8 @@ import { loading } from '@/utils'
import type { Product } from '@/models/products'
import { cloneDeep } from 'lodash'
import { isProductPriceInactive } from '@/utils/productPrice'
import { getStoreClosedMessage, isStoreClosed } from '@/utils/storeHours'
import { getStoreClosedHint, shouldBlockStoreTrading } from '@/utils/storeHours'
import { useUserStore } from '@/store/userStore'
import { lastPrice } from '@/utils/price'
import {
changeProductsTab,
@@ -50,15 +51,18 @@ export const PRODUCTS_PAGE_CONTEXT_KEY: InjectionKey<ProductsPageContext> =
Symbol('productsPageContext')
export function useProductsPageProvider() {
const userStore = useUserStore()
const showFilter = ref(false)
const orderSheetKey = ref(0)
const selectedProduct = ref<Product>()
const isAfterCloseTime = ref(false)
const isProductInactive = ref(false)
const storeClosedMessage = computed(() => getStoreClosedMessage())
const storeClosedMessage = computed(() =>
getStoreClosedHint(userStore.getValueByKey('closed_message')),
)
function syncStoreClosedState() {
if (isStoreClosed()) {
if (shouldBlockStoreTrading()) {
showFilter.value = false
isAfterCloseTime.value = true
}
@@ -73,7 +77,7 @@ export function useProductsPageProvider() {
function clickProduct(item?: Product) {
if (!item?.show) return
if (isStoreClosed()) {
if (shouldBlockStoreTrading()) {
showFilter.value = false
isAfterCloseTime.value = true
return
@@ -95,7 +99,7 @@ export function useProductsPageProvider() {
}
watch(showFilter, (open) => {
if (open && isStoreClosed()) {
if (open && shouldBlockStoreTrading()) {
showFilter.value = false
isAfterCloseTime.value = true
return
@@ -115,7 +119,7 @@ export function useProductsPageProvider() {
}
if (router.currentRoute.value.query.state) {
if (isStoreClosed()) {
if (shouldBlockStoreTrading()) {
isAfterCloseTime.value = true
} else if (router.currentRoute.value.query.product) {
clickProduct(productsItems.value?.find((x) => x.title === 'سکه'))
@@ -10,7 +10,7 @@
<!-- بنر بسته بودن فروشگاه -->
<div v-if="storeClosed" class="dproducts-closed-banner">
<span>🔒</span>
<span class="dproducts-closed-banner__title">فروشگاه بسته است</span>
<span class="dproducts-closed-banner__title">{{ STORE_CLOSED_TITLE }}</span>
<span v-if="storeClosedMessage" class="dproducts-closed-banner__hint">— {{ storeClosedMessage }}</span>
</div>
@@ -57,7 +57,7 @@
import DesktopPageTopbar from '@/layouts/components/DesktopPageTopbar.vue'
import DesktopProductCard from './components/DesktopProductCard.vue'
import { useProductsPageContext } from '../composables/useProductsPage'
import { getPriceDisplayState, isStoreClosedBySchedule, getStoreClosedMessage } from '@/utils/storeHours'
import { isMarketClosedForDisplay, STORE_CLOSED_TITLE } from '@/utils/storeHours'
import { computed } from 'vue'
const {
@@ -68,10 +68,10 @@ const {
changeTab,
clickProduct,
isProductPriceInactive,
storeClosedMessage,
} = useProductsPageContext()
const storeClosed = computed(() => getPriceDisplayState() === 'closed' || isStoreClosedBySchedule())
const storeClosedMessage = computed(() => getStoreClosedMessage())
const storeClosed = computed(() => isMarketClosedForDisplay())
</script>
<style lang="less" src="./styles/desktop-products.less"></style>
+4 -4
View File
@@ -52,10 +52,9 @@
<BasicModal v-model:visible="isAfterCloseTime" custom-footer :closable="false">
<div class="text-center">
<div class="font-bold text-red-600">مشتریان گرامی</div>
<div class="mt-2 leading-relaxed">
<p>{{ storeClosedMessage }}</p>
<p>از همراهی و اعتماد شما سپاسگزاریم.🤍</p>
<div class="font-bold text-red-600">{{ STORE_CLOSED_TITLE }}</div>
<div v-if="storeClosedMessage" class="mt-2 leading-relaxed text-gray-600">
{{ storeClosedMessage }}
</div>
</div>
<template #footer>
@@ -75,6 +74,7 @@ import BasicModal from '@/components/BasicPacks/BasicModal.vue'
import ResponsiveViewPair from '@/layouts/components/ResponsiveViewPair.vue'
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
import { usesQuantityTrade } from '@/utils/productCategories'
import { STORE_CLOSED_TITLE } from '@/utils/storeHours'
import { useProductsPageProvider } from './composables/useProductsPage'
import MobileProductsView from './mobile/MobileProductsView.vue'
import DesktopProductsView from './desktop/DesktopProductsView.vue'
@@ -9,7 +9,7 @@
<div v-if="storeClosed" class="mx-4 mt-4 closed-banner">
<div class="closed-banner__icon">🔒</div>
<div class="closed-banner__body">
<div class="closed-banner__title">فروشگاه بسته است</div>
<div class="closed-banner__title">{{ STORE_CLOSED_TITLE }}</div>
<div v-if="storeClosedMessage" class="closed-banner__hint">{{ storeClosedMessage }}</div>
</div>
</div>
@@ -59,7 +59,7 @@ import img from '@/assets/img/user_ly1.svg'
import MobilePageHeader from '@/layouts/components/MobilePageHeader.vue'
import ProductItem from '@/views/base/products/components/ProductItem.vue'
import { useProductsPageContext } from '../composables/useProductsPage'
import { getPriceDisplayState, isStoreClosedBySchedule, getStoreClosedMessage } from '@/utils/storeHours'
import { isMarketClosedForDisplay, STORE_CLOSED_TITLE } from '@/utils/storeHours'
import { computed } from 'vue'
const {
@@ -70,10 +70,10 @@ const {
changeTab,
clickProduct,
isProductPriceInactive,
storeClosedMessage,
} = useProductsPageContext()
const storeClosed = computed(() => getPriceDisplayState() === 'closed' || isStoreClosedBySchedule())
const storeClosedMessage = computed(() => getStoreClosedMessage())
const storeClosed = computed(() => isMarketClosedForDisplay())
</script>
<style scoped>