<commit_before>import AssociatedSequencePanel from "components/features/Summary/Panels/AssociatedSequencePanel"
import GeneralInfoPanel from "components/features/Summary/Panels/GeneralInfoPanel"
import ProductInfoPanel from "components/features/Summary/Panels/ProductInfoPanel"
import PanelWrapper from "components/panels/PanelWrapper"
import { Content, GeneQuery, Gene } from "dicty-graphql-schema"
import { Component } from "react"

const SummaryContainerContent = {
  generalInformation: {
    id: "generalInformation",
    title: "General Information",
    route: "/gene/${geneId}/",
  },
  gene: {
    id: "gene",
    title: "Latest Gene Ontology Annotations",
    route: "/gene/${geneId}/goannotations",
  },
  listGeneProductInfo: {
    id: "listGeneProductInfo",
    title: "Gene Product Information",
    route: "/gene/${geneId}/",
  },
  getAssociatedSequnces: {
    id: "getAssociatedSequnces",
    title: "Associated Sequences",
    route: "/gene/${geneId}/",
  },
  getLinks: {
    id: "getLinks",
    title: "Links",
    route: "/gene/${geneId}/",
  },
  allPublications: {
    id: "allPublications",
    title:
      "Latest References (press references tab to view all ${gene.allPublications.num_pubs} papers)",
    route: "`/gene/${geneId}/references`",
  },
}

const returnComponentByName = (id: string, gene: GeneQuery) => {
  if (id === "generalInformation") {
    return <GeneralInfoPanel gene={gene}></GeneralInfoPanel>
  }
}

const convertStringToTemplateString = (target: string, gene: GeneQuery) => {
  /* Not efficient 
    I tried the regex but I had issue with converting a string to a string literal
  */
  if (target === "geneId")
    return target.replace("$(geneId}", `${gene.gene?.name}`)
  if (target === "allPublications")
    return target.replace(
      "${gene.allPublications.num_pubs",
      `${gene.allPublications.num_pubs}`,
    )
}

/* 
  This function will take in props and return the container items
*/
const contentGenerator = (req: string[], gene: GeneQuery) => {
  let returnArray: any[] = []
  console.log(gene)
  req.forEach((element) => {
    if (gene[element]) {
      let entry = {
        props: SummaryContainerContent[element],
        component: returnComponentByName(
          SummaryContainerContent[element].id,
          gene,
        ),
      }
      returnArray.push(entry)
    }
  })

  return returnArray
}

export {
  contentGenerator,
  convertStringToTemplateString,
  returnComponentByName,
}
<commit_msg>feat: add all cases to returnComponentByName<commit_after>import AssociatedSequencePanel from "components/features/Summary/Panels/AssociatedSequencePanel"
import GeneralInfoPanel from "components/features/Summary/Panels/GeneralInfoPanel"
import GoaPanel from "components/features/Summary/Panels/GoaPanel"
import LinkPanel from "components/features/Summary/Panels/LinksPanel"
import ProductInfoPanel from "components/features/Summary/Panels/ProductInfoPanel"
import ReferencesPanel from "components/features/Summary/Panels/ReferencesPanel"
import PanelWrapper from "components/panels/PanelWrapper"
import { Content, GeneQuery, Gene } from "dicty-graphql-schema"
import { Component } from "react"

const SummaryContainerContent = {
  generalInformation: {
    id: "generalInformation",
    title: "General Information",
    route: "/gene/${geneId}/",
  },
  gene: {
    id: "gene",
    title: "Latest Gene Ontology Annotations",
    route: "/gene/${geneId}/goannotations",
  },
  listGeneProductInfo: {
    id: "listGeneProductInfo",
    title: "Gene Product Information",
    route: "/gene/${geneId}/",
  },
  getAssociatedSequnces: {
    id: "getAssociatedSequnces",
    title: "Associated Sequences",
    route: "/gene/${geneId}/",
  },
  getLinks: {
    id: "getLinks",
    title: "Links",
    route: "/gene/${geneId}/",
  },
  allPublications: {
    id: "allPublications",
    title:
      "Latest References (press references tab to view all ${gene.allPublications.num_pubs} papers)",
    route: "`/gene/${geneId}/references`",
  },
}

const returnComponentByName = (id: string, gene: GeneQuery) => {
  switch (id) {
    case "generalInformation":
      ;<GeneralInfoPanel gene={gene}></GeneralInfoPanel>
      break
    case "gene":
      ;<GoaPanel data={gene} />
      break
    case "listGeneProductInfo":
      ;<ProductInfoPanel gene={gene} />
      break
    case "getAssociatedSequences":
      ;<AssociatedSequencePanel data={gene} />
      break
    case "getLinks":
      ;<LinkPanel data={gene} />
      break
    case "allPublications":
      ;<ReferencesPanel gene={gene} />
      break
  }
}

const convertStringToTemplateString = (target: string, gene: GeneQuery) => {
  /* Not efficient 
    I tried the regex but I had issue with converting a string to a string literal
  */
  if (target === "geneId")
    return target.replace("$(geneId}", `${gene.gene?.name}`)
  if (target === "allPublications")
    return target.replace(
      "${gene.allPublications.num_pubs",
      `${gene.allPublications.num_pubs}`,
    )
}

/* 
  This function will take in props and return the container items
*/
const contentGenerator = (req: string[], gene: GeneQuery) => {
  let returnArray: any[] = []
  console.log(gene)
  req.forEach((element) => {
    if (gene[element]) {
      let entry = {
        props: SummaryContainerContent[element],
        component: returnComponentByName(
          SummaryContainerContent[element].id,
          gene,
        ),
      }
      returnArray.push(entry)
    }
  })

  return returnArray
}

export {
  contentGenerator,
  convertStringToTemplateString,
  returnComponentByName,
}

{'fraction_non_alphanumeric': 0.13166815343443355, 'fraction_numerical': 0.0, 'mean_word_length': 3.660016625103907, 'pattern_counts': {'":': 6, '<': 12, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4648191', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1663, 'n_words': 391}