import type { BaseTableColumn } from '@core/type/baseTable' import { usePrice } from '@core/utils/usePrice' import { toJalali } from '@core/utils/useDataTime' function formatSignedProfit(raw: unknown) { const n = Number(raw ?? 0) if (!Number.isFinite(n) || n === 0) { return usePrice(0, true, '') } const label = n < 0 ? 'تخفیف' : 'سود' return `${label} ${usePrice(Math.abs(n), true, '')}` } export function getSpecialPricePackageColumns(): BaseTableColumn[] { return [ { title: 'ردیف', dataIndex: 'id', key: 'row', filterable: false, sortable: false, customRender: (record: any) => record.index + 1 }, { title: 'عنوان پکیج', dataIndex: 'title', key: 'title', type: 'Text' }, { title: 'تعداد کاربر', dataIndex: 'customers_count', key: 'customers_count', type: 'Number', filterable: false }, { title: 'تعداد محصول', dataIndex: 'products_count', key: 'products_count', type: 'Number', filterable: false }, { title: 'سود خرید', dataIndex: 'profit_buy', key: 'profit_buy', type: 'Text', customRender: ({ record }) => formatSignedProfit(record.profit_buy) }, { title: 'سود فروش', dataIndex: 'profit_sell', key: 'profit_sell', type: 'Text', customRender: ({ record }) => formatSignedProfit(record.profit_sell) }, { title: 'نمایش محصول', dataIndex: 'show_product', key: 'show_product', type: 'Text', customRender: ({ record }) => (record.show_product ? 'فعال' : 'مخفی') }, { title: 'وضعیت', dataIndex: 'is_active', key: 'is_active', type: 'Text', customRender: ({ record }) => (record.is_active ? 'فعال' : 'غیرفعال') }, { title: 'تاریخ', dataIndex: 'updated_at', key: 'updated_at', type: 'DateTime', customRender: (r: any) => (r.record?.updated_at ? toJalali(r.record.updated_at) : '—') }, { title: 'عملیات', dataIndex: 'action', key: 'action', slot: 'action', filterable: false, sortable: false } ] }