import { useTranslation } from 'react-i18next';
import { SUCCESS_MESSAGES, ERROR_MESSAGES } from '../utils/constants';

/**
 * Hook to get translated success messages
 */
export const useSuccessMessages = () => {
  const { t } = useTranslation();

  const getMessage = (key: keyof typeof SUCCESS_MESSAGES): string => {
    const translationKey = SUCCESS_MESSAGES[key];
    const [namespace, path] = translationKey.split(':');
    return t(`${namespace}:${path}`);
  };

  return { getMessage };
};

/**
 * Hook to get translated error messages
 */
export const useErrorMessages = () => {
  const { t } = useTranslation();

  const getMessage = (key: keyof typeof ERROR_MESSAGES): string => {
    const translationKey = ERROR_MESSAGES[key];
    const [namespace, path] = translationKey.split(':');
    return t(`${namespace}:${path}`);
  };

  return { getMessage };
};