/**
 * @desc 分组下的数据字典列表
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios';
import type { AxiosResponse } from 'axios';
export default async function (
  /** 码本分组key */
  group: string,

  success: (data: Array<dictionary.Dictionary>) => void = defaultSuccess,
  fail: (error: { code: string; error?: string }) => void = defaultError,
): Promise<void> {
  return http({
    method: 'get',
    url: `/group/${group}/dictionaries`,
  })
    .then((data: AxiosResponse<Array<dictionary.Dictionary>, unknown>) => {
      success(data.data);
    })
    .catch((error: { code: string; error?: string }) => fail(error));
}
