"use client";

import { useCallback } from "react";

import { _useScopedI18n } from "../i18n/client";
import { resolveUsaHomeStationErrorMessage } from "../utils/usa-home-station-error.util";

export function useUsaHomeStationErrorMessage() {
  const t = _useScopedI18n("cart.usaHomeStation");

  return useCallback(
    (error: unknown) =>
      resolveUsaHomeStationErrorMessage(error, (key, params) =>
        t(key as "quotaExceeded", params),
      ),
    [t],
  );
}
