types#ChainCategoryType TypeScript Examples

The following examples show how to use types#ChainCategoryType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: community_cards.tsx    From commonwealth with GNU General Public License v3.0 6 votes vote down vote up
buildChainToCategoriesMap = (
  categoryTypes,
  chainsAndCategories
) => {
  // Handle mapping provided by ChainCategories table
  const categoryMap = {};
  for (const data of categoryTypes) {
    categoryMap[data.id] = data.category_name;
  }
  const chainToCategoriesMap: { [chain: string]: ChainCategoryType[] } = {};
  for (const data of chainsAndCategories) {
    if (chainToCategoriesMap[data.chain_id]) {
      chainToCategoriesMap[data.chain_id].push(
        categoryMap[data.category_type_id]
      );
    } else {
      chainToCategoriesMap[data.chain_id] = [
        categoryMap[data.category_type_id],
      ];
    }
  }

  return chainToCategoriesMap;
}
Example #2
Source File: helpers.ts    From commonwealth with GNU General Public License v3.0 6 votes vote down vote up
setSelectedTags = (chain: string) => {
  const categoryTypes = app.config.chainCategoryTypes;
  const chainsAndCategories = app.config.chainCategories;
  const chainToCategoriesMap: { [chain: string]: ChainCategoryType[] } =
    buildChainToCategoriesMap(categoryTypes, chainsAndCategories);

  const types = Object.keys(ChainCategoryType);
  const selectedTags = {};

  for (const type of types) {
    selectedTags[type] = false;
  }

  if (chainToCategoriesMap[chain]) {
    for (const tag of chainToCategoriesMap[chain]) {
      selectedTags[tag] = true;
    }
  }

  return selectedTags;
}
Example #3
Source File: chain_metadata_rows.tsx    From commonwealth with GNU General Public License v3.0 5 votes vote down vote up
selectedTags: { [type in ChainCategoryType]?: boolean };
Example #4
Source File: chain_metadata_rows.tsx    From commonwealth with GNU General Public License v3.0 5 votes vote down vote up
categoryMap: { [type in ChainCategoryType]?: number };