fix(trade): use stream closed and trade_open instead of device clock

Changing the phone time can no longer open a product that the server has closed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-05 12:58:19 +03:30
co-authored by Cursor
parent 2d3c590c71
commit bc2acc3eb6
11 changed files with 86 additions and 24 deletions
+13
View File
@@ -24,6 +24,19 @@ export function isProductTradeOpen(product: TradeOpenProduct, isBuy: boolean) {
return isBuy ? isProductBuyOpen(product) : isProductSellOpen(product)
}
/** ساعت کاری محصول از استریم (trade_open) — نه ساعت دستگاه */
export function isProductTradingHoursOpen(
product?: { show?: boolean; trade_open?: boolean } | null,
) {
if (!product) return false
if (typeof product.trade_open === 'boolean') return product.trade_open
return product.show === true
}
export function productHoursClosedMessage() {
return 'این محصول در حال حاضر خارج از ساعت کاری است.'
}
/** تب اولیه با توجه به query و وضعیت باز/بسته خرید و فروش */
export function resolveProductTradeIsBuy(product: TradeOpenProduct, routeState?: string | null) {
const wantSell = routeState === 'sell'