import { useLokaliseTranslation } from 'src/utils/i18n';

import { useGoalFeaturesConfig } from '../../hooks/useGoalFeaturesConfig';

export type UseGoalWeightsTextsArgs = {
  fromMyGoalsPage: boolean;
};

const useGoalWeightsTexts = ({ fromMyGoalsPage }: UseGoalWeightsTextsArgs) => {
  const { t } = useLokaliseTranslation('goals');
  const { isApprovalFlowEnabled } = useGoalFeaturesConfig();

  const isManagerApprovalMode = !fromMyGoalsPage && isApprovalFlowEnabled;

  const getText = () => {
    return isManagerApprovalMode
      ? t('my_team.edit_weight_approve')
      : t('my_team.edit_weight');
  };

  const getSaveButtonText = () => {
    return isManagerApprovalMode
      ? t('my_team.save_approve')
      : t('general:save');
  };

  return {
    isManagerApprovalMode,
    getText,
    getSaveButtonText,
    fromMyGoalsPage,
  };
};

export default useGoalWeightsTexts;
