import {
  CardInfoFields,
  Column,
  StatusTag,
  ActionTable,
  Notification,
} from './constants';
import { ASSETS, useTranslation } from 'core/i18n';
import { TypeCollectiveActionMessages } from './types';
import { useCommonMessages } from '../../components/i18n';

export type TAssetsMessages = {
  title: string;
  menuAssets: {
    tableAssets: string;
    groupsAssets: string;
  };
  table: {
    column: {
      name: string;
      status: string;
      type: string;
      ip: string;
      incidents: string;
      description: string;
      action: string;
      updated: string;
      vulnerabilities: string;
      tags: string;
      groupMember: string;
    };
    collectiveActionsMessages: TypeCollectiveActionMessages;
  };
  notification: {
    [key: string]: string;
  };
  statusTag: {
    [key: string]: string;
  };

  cardInfoFields: {
    [key: string]: string;
  };
};

export function useAssetsMessages(): TAssetsMessages {
  const { t } = useTranslation([ASSETS]);
  const formValidatorsMessages = useCommonMessages().formValidators;

  return {
    title: t('assets:app.assets.title'),
    menuAssets: {
      tableAssets: t('assets:app.assets.menuAssets.tableAssets'),
      groupsAssets: t('assets:app.assets.menuAssets.groupsAssets'),
    },
    table: {
      column: {
        [Column.Name]: t('assets:app.assets.table.column.name'),
        [Column.Status]: t('assets:app.assets.table.column.status'),
        [Column.Type]: t('assets:app.assets.table.column.type'),
        [Column.Ip]: t('assets:app.assets.table.column.ip'),
        [Column.Vulnerabilities]: t(
          'assets:app.assets.table.column.vulnerabilities',
        ),
        [Column.Incidents]: t('assets:app.assets.table.column.incidents'),
        [Column.Tags]: t('assets:app.assets.table.column.tags'),
        [Column.Updated]: t('assets:app.assets.table.column.updated'),
        [Column.Description]: t('assets:app.assets.table.column.description'),
        [Column.GroupMember]: t('assets:app.assets.table.column.group_member'),
        [Column.Action]: t('assets:app.assets.table.column.actions'),
      },
      collectiveActionsMessages: {
        [ActionTable.DeleteSelectedAssetsQuestion]: t(
          'assets:app.assets.table.action.delete_selected_assets_question',
        ),
        [ActionTable.ChangeStatusSelectedAssetsQuestion]: t(
          'assets:app.assets.table.action.change_status_selected_assets_question',
        ),
        [ActionTable.ChangeStatusSelectedAssetsPopover]: t(
          'assets:app.assets.table.action.change_status_selected_assets_popover',
        ),
        [ActionTable.DeleteSelectedAssetsPopover]: t(
          'assets:app.assets.table.action.delete_selected_assets_popover',
        ),
        [ActionTable.DeleteSelectedGroupsPopover]: t(
          'assets:app.assets.table.action.delete_selected_groups_popover',
        ),
        [ActionTable.DeleteSelectedGroupsQuestion]: t(
          'assets:app.assets.table.action.delete_selected_groups_question',
        ),
        [ActionTable.DeleteSelectedGroupQuestion]: t(
          'assets:app.assets.table.action.delete_selected_group_question',
        ),
      },
    },
    statusTag: {
      [StatusTag.Registered]: t(
        'assets:app.assets.table.status_tag.registered',
      ),
      [StatusTag.NotRegistered]: t(
        'assets:app.assets.table.status_tag.not_registered',
      ),
    },
    notification: {
      [Notification.TitleDeleted]: t(
        'assets:app.assets.notification.title_deleted',
      ),
      [Notification.DescriptionDeleted]: t(
        'assets:app.assets.notification.description_deleted',
      ),
      [Notification.TitleDownload]: t(
        'assets:app.assets.notification.title_download',
      ),
      [Notification.DescriptionDownload]: t(
        'assets:app.assets.notification.description_download',
      ),
      [Notification.DescriptionDeletedGroups]: t(
        'assets:app.assets.notification.description_deleted_groups',
      ),
      [Notification.ChangeStatus]: t(
        'assets:app.assets.notification.change_status',
      ),
      [Notification.PleaseCheckData]: t(
        'assets:app.assets.notification.please_check_data',
      ),
    },

    cardInfoFields: {
      [CardInfoFields.CreateNewAsset]: t(
        'assets:app.assets.table.card_info.create_new_asset',
      ),
      [CardInfoFields.CreateNewGroups]: t(
        'assets:app.assets.table.card_info.header.create_new_groups',
      ),
      [CardInfoFields.HeaderTitle]: t(
        'assets:app.assets.table.card_info.header.title',
      ),
      [CardInfoFields.Name]: t('assets:app.assets.table.card_info.name'),
      [CardInfoFields.Ip]: t('assets:app.assets.table.card_info.ip'),
      [CardInfoFields.IpValidation]: t(
        'assets:app.assets.table.card_info.ip_validation',
      ),

      [CardInfoFields.Os]: t('assets:app.assets.table.card_info.os'),
      [CardInfoFields.Manufacturer]: t(
        'assets:app.assets.table.card_info.manufacturer',
      ),
      [CardInfoFields.Model]: t('assets:app.assets.table.card_info.model'),
      [CardInfoFields.AssetType]: t(
        'assets:app.assets.table.card_info.asset_type',
      ),
      [CardInfoFields.Status]: t('assets:app.assets.table.card_info.status'),
      [CardInfoFields.Tags]: t('assets:app.assets.table.card_info.tags'),
      [CardInfoFields.Ports]: t('assets:app.assets.table.card_info.ports'),
      [CardInfoFields.PortsValidation]: formValidatorsMessages.badPortsJson,

      [CardInfoFields.Description]: t(
        'assets:app.assets.table.card_info.description',
      ),
      [CardInfoFields.Incidents]: t(
        'assets:app.assets.table.card_info.incidents',
      ),
      [CardInfoFields.SelectManufacturerFromList]: t(
        'assets:app.assets.table.card_info.select_manufacturer_from_list',
      ),
      [CardInfoFields.ManufacturerList]: t(
        'assets:app.assets.table.card_info.manufacturer_list',
      ),
      [CardInfoFields.PortsListExtra]: t(
        'assets:app.assets.table.card_info.ports_list_extra',
      ),
      [CardInfoFields.AssetModelExtra]: t(
        'assets:app.assets.table.card_info.asset_model_extra',
      ),
      [CardInfoFields.FieldCanNotEmptyValidation]: t(
        'assets:app.assets.table.card_info.field_can_not_empty_validation',
      ),
      [CardInfoFields.IpExtra]: t('assets:app.assets.table.card_info.ip_extra'),
      [CardInfoFields.SelectOsFromList]: t(
        'assets:app.assets.table.card_info.select_os_from_list',
      ),
      [CardInfoFields.OsFoundOnAssetExtra]: t(
        'assets:app.assets.table.card_info.os_found_on_asset_extra',
      ),
      [CardInfoFields.SelectGroupsFromListPlaceholder]: t(
        'assets:app.assets.table.card_info.select_groups_from_list_placeholder',
      ),
      [CardInfoFields.GroupsWhichTheAssetBelongs]: t(
        'assets:app.assets.table.card_info.groups_which_the_asset_belongs',
      ),
      [CardInfoFields.SelectAssetStatus]: t(
        'assets:app.assets.table.card_info.select_asset_status',
      ),
      [CardInfoFields.AssetResolutionStatus]: t(
        'assets:app.assets.table.card_info.asset_resolution_status',
      ),
      [CardInfoFields.EnterLoginAsset]: t(
        'assets:app.assets.table.card_info.enter_login_asset',
      ),
      [CardInfoFields.MaxLength]: t(
        'assets:app.assets.table.card_info.max_length',
      ),
      [CardInfoFields.EnterLoginAsset]: t(
        'assets:app.assets.table.card_info.enter_login_asset',
      ),
      [CardInfoFields.MaxLength]: t(
        'assets:app.assets.table.card_info.max_length',
      ),
      [CardInfoFields.Permitted]: t(
        'assets:app.assets.table.card_info.permitted',
      ),
      [CardInfoFields.NotPermitted]: t(
        'assets:app.assets.table.card_info.not_permitted',
      ),
    },
  };
}
