show price in product editor

This commit is contained in:
2026-06-10 10:56:35 +03:30
parent 39f7ea00db
commit b7abe34f7e
3 changed files with 25 additions and 49 deletions
+3 -15
View File
@@ -55,7 +55,6 @@ export function resolveAppBasePrice(lastPrice?: Partial<last> & { price?: number
export type ProductEditorPricePreview =
| { status: 'ready'; amount: number; source: string }
| { status: 'empty'; message: string }
| { status: 'loading'; message: string }
export function computeProductEditorPricePreview(input: {
form: {
@@ -68,8 +67,6 @@ export function computeProductEditorPricePreview(input: {
meltedPriceOption: MeltedPriceSource
pricesData: MethodePrices[]
appLastPrice?: (Partial<last> & { price?: number }) | null
pricesLoading?: boolean
appPriceLoading?: boolean
}): ProductEditorPricePreview {
const offsetPercent = Number(input.form.price_offset_percent ?? 0)
const melted = isMeltedTradeGroup(input.form.group_type)
@@ -83,12 +80,9 @@ export function computeProductEditorPricePreview(input: {
}
if (input.meltedPriceOption === 'app') {
if (input.appPriceLoading) {
return { status: 'loading', message: 'در حال دریافت قیمت اپ...' }
}
const base = resolveAppBasePrice(input.appLastPrice)
if (base <= 0) {
return { status: 'empty', message: 'قیمت اپ در دسترس نیست' }
return { status: 'empty', message: '' }
}
return {
status: 'ready',
@@ -100,12 +94,9 @@ export function computeProductEditorPricePreview(input: {
if (!input.form.reading_method) {
return { status: 'empty', message: 'مرجع قیمت را انتخاب کنید' }
}
if (input.pricesLoading) {
return { status: 'loading', message: 'در حال دریافت قیمت مرجع...' }
}
const entry = findMethodPriceEntry(input.pricesData, input.form.reading_method)
if (!entry) {
return { status: 'empty', message: 'مرجع قیمت یافت نشد' }
return { status: 'empty', message: '' }
}
const { base, profit } = normalizeReferenceBase(entry)
return {
@@ -125,12 +116,9 @@ export function computeProductEditorPricePreview(input: {
if (!input.form.reading_method) {
return { status: 'empty', message: 'مرجع قیمت را انتخاب کنید' }
}
if (input.pricesLoading) {
return { status: 'loading', message: 'در حال دریافت قیمت مرجع...' }
}
const entry = findMethodPriceEntry(input.pricesData, input.form.reading_method)
if (!entry) {
return { status: 'empty', message: 'مرجع قیمت یافت نشد' }
return { status: 'empty', message: '' }
}
const { base, profit } = normalizeReferenceBase(entry)
return {