From a186db08e219235fc94870bb35658386c9b600c8 Mon Sep 17 00:00:00 2001 From: AmirmahdiNourkazemi Date: Wed, 17 Jun 2026 19:10:21 +0330 Subject: [PATCH] feat: add product 3 mount --- lib/utils.ts | 15 +++++---------- types/product.ts | 3 ++- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/utils.ts b/lib/utils.ts index 7a031f2..ac72bbb 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,5 +1,10 @@ import { User } from "@/types/user"; +// Single source of truth for product type labels lives in types/product.ts +// (kept in sync with the backend Product::TYPES). Re-exported here so existing +// `@/lib/utils` imports keep working without a divergent (previously wrong) map. +export { getProductTypeLabel } from "@/types/product"; + export const formatDate = (dateString: string | null): string => { if (!dateString) return 'نامشخص'; @@ -20,16 +25,6 @@ export const formatPrice = (price: number | null): string => { return new Intl.NumberFormat('fa-IR').format(price); }; -export const getProductTypeLabel = (type: number | null): string => { - const types: Record = { - 1: 'ماهیانه', - 2: 'سه ماهه', - 3: 'شش ماهه', - 4: 'سالیانه', - }; - return type && types[type] ? types[type] : 'نامشخص'; -}; - export const getFullName = (user: User): string => { if (user.full_name) return user.full_name; diff --git a/types/product.ts b/types/product.ts index 07a9101..09373e7 100644 --- a/types/product.ts +++ b/types/product.ts @@ -35,7 +35,8 @@ export const PRODUCT_TYPES = { 1: 'دائمی', 2: 'سالیانه', 3: '۶ ماهه', - 4: 'ماهیانه' + 4: 'ماهیانه', + 5: 'سه ماهه' } as const; export type ProductType = keyof typeof PRODUCT_TYPES;