From 8bc4971c766ac9cedcfc301476b122dba35b8347 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Mon, 8 Dec 2025 14:33:34 +0330 Subject: [PATCH] translate rate --- src/app/[name]/(Main)/order/rate/[orderId]/page.tsx | 9 +++++++-- src/app/[name]/(Main)/order/rate/enum/Enum.ts | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/[name]/(Main)/order/rate/[orderId]/page.tsx b/src/app/[name]/(Main)/order/rate/[orderId]/page.tsx index dccabe9..de0d1db 100644 --- a/src/app/[name]/(Main)/order/rate/[orderId]/page.tsx +++ b/src/app/[name]/(Main)/order/rate/[orderId]/page.tsx @@ -50,6 +50,11 @@ function RatingOrderIndex({ }: Props) { NegativePointEnum.UNFRIENDLY_SERVICE, ]; + const getTranslationKey = (point: string, isPositive: boolean): string => { + const basePath = isPositive ? 'Tabs.Strengths.Options' : 'Tabs.Weeknesses.Options'; + return `${basePath}.${point}`; + }; + const handleToggle = (pointValue: string, isPositive: boolean) => (checked: boolean) => { const setter = isPositive ? setPositivePoints : setNegativePoints; @@ -76,7 +81,7 @@ function RatingOrderIndex({ }: Props) { // @ts-expect-error - Type mismatch between custom ToggleButton and React types onToggle={handleToggle(point, false)} > - {t(`Tabs.Weeknesses.Options.${point}`)} + {t(getTranslationKey(point, false))} ))} @@ -95,7 +100,7 @@ function RatingOrderIndex({ }: Props) { // @ts-expect-error - Type mismatch between custom ToggleButton and React types onToggle={handleToggle(point, true)} > - {t(`Tabs.Strengths.Options.${point}`)} + {t(getTranslationKey(point, true))} ))} diff --git a/src/app/[name]/(Main)/order/rate/enum/Enum.ts b/src/app/[name]/(Main)/order/rate/enum/Enum.ts index e634c34..8dd859b 100644 --- a/src/app/[name]/(Main)/order/rate/enum/Enum.ts +++ b/src/app/[name]/(Main)/order/rate/enum/Enum.ts @@ -1,4 +1,4 @@ -export const enum PositivePointEnum { +export enum PositivePointEnum { GREAT_TASTE = "great_taste", FAST_DELIVERY = "fast_delivery", GOOD_QUALITY = "good_quality", @@ -6,7 +6,7 @@ export const enum PositivePointEnum { FRIENDLY_SERVICE = "friendly_service", } -export const enum NegativePointEnum { +export enum NegativePointEnum { SMALL_PORTION = "small_portion", SLOW_DELIVERY = "slow_delivery", POOR_QUALITY = "poor_quality",