translate rate

This commit is contained in:
hamid zarghami
2025-12-08 14:33:34 +03:30
parent 6eb390e60c
commit 8bc4971c76
2 changed files with 9 additions and 4 deletions
@@ -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))}
</ToggleButton>
))}
</div>
@@ -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))}
</ToggleButton>
))}
</div>
@@ -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",