import { useIntl } from 'umi';

export enum LinkStatusMap {
  ENABLED = '0',
  DISABLED = '1',
}
export const useFriendLinkDict = () => {
  const intl = useIntl();

  // 友情链接状态选项
  const linkStatusOptions = [
    {
      label: intl.formatMessage({ id: 'friendLink.enabled' }),
      value: LinkStatusMap.ENABLED,
    },
    {
      label: intl.formatMessage({ id: 'friendLink.disabled' }),
      value: LinkStatusMap.DISABLED,
    },
  ];

  // 获取状态标签
  const getLinkStatusText = (status: number) => {
    const option = linkStatusOptions.find(item => item.value === status.toString());
    return option ? option.label : '-';
  };

  // 友情链接分类类型选项
  const categoryTypeOptions = [
    {
      label: intl.formatMessage({ id: 'friendLink.category.type.normal' }),
      value: 'normal',
    },
    {
      label: intl.formatMessage({ id: 'friendLink.category.type.featured' }),
      value: 'featured',
    },
  ];

  // 获取分类类型标签
  const getCategoryTypeText = (type: string) => {
    const option = categoryTypeOptions.find(item => item.value === type);
    return option ? option.label : '-';
  };

  return {
    linkStatusOptions,
    getLinkStatusText,
    categoryTypeOptions,
    getCategoryTypeText,
  };
};
