change gift-card

This commit is contained in:
2026-09-21 11:10:34 +03:30
parent 8004dd52b3
commit 7e869902d6
7 changed files with 214 additions and 48 deletions
@@ -0,0 +1,32 @@
import type { Giftcard } from '@/model/giftCard'
export function resolveGiftCardCustomer(giftCard?: Giftcard | null) {
if (!giftCard) return null
const name = giftCard.customer?.name ?? giftCard.name
const mobile = giftCard.customer?.mobile ?? giftCard.mobile
if (name || mobile) {
return {
name: name || '-',
mobile: mobile || '-',
}
}
if (giftCard.customer_id) {
return {
name: `مشتری #${giftCard.customer_id}`,
mobile: '-',
}
}
return null
}
export function giftCardCustomerLabel(giftCard?: Giftcard | null) {
return resolveGiftCardCustomer(giftCard)?.name ?? '— (کد عمومی)'
}
export function giftCardCustomerMobile(giftCard?: Giftcard | null) {
return resolveGiftCardCustomer(giftCard)?.mobile ?? '-'
}