import { PrefixSuffixResponse } from "@/record-management/dto/userRecords/prefixAndSuffixDto";
import { prefixSuffixService } from "@/user-management/services/api/prefixSuffixService";

/**
 * @deprecated Use `prefixSuffixService` (user-management domain service) directly.
 * This adapter is kept temporarily for backward compatibility.
 */
export const fetchPrefixes = async (
  unitId: string,
  recordTypeKey: string,
  cc = false,
  skip = 0,
  take = 10
): Promise<PrefixSuffixResponse> => {
  try {
    const { data } = cc
      ? await prefixSuffixService.getPrefixCC(unitId, recordTypeKey, skip, take)
      : await prefixSuffixService.getPrefix(unitId, recordTypeKey, skip, take);
    return data as PrefixSuffixResponse;
  } catch (error) {
    throw error;
  }
};

/**
 * @deprecated Use `prefixSuffixService` (user-management domain service) directly.
 * This adapter is kept temporarily for backward compatibility.
 */
export const fetchSuffixes = async (
  unitId: string,
  recordTypeKey: string,
  cc = false,
  skip = 0,
  take = 10
): Promise<PrefixSuffixResponse> => {
  try {
    const { data } = cc
      ? await prefixSuffixService.getSuffixCC(unitId, recordTypeKey, skip, take)
      : await prefixSuffixService.getSuffix(unitId, recordTypeKey, skip, take);
    return data as PrefixSuffixResponse;
  } catch (error) {
    throw error;
  }
};
