<commit_before><commit_msg>Starting vanity url changes, broken<commit_after>import { VanityURLEntityQuery } from "__generated__/VanityURLEntityQuery.graphql"
import { HeaderTabsGridPlaceholder } from "lib/Components/HeaderTabGridPlaceholder"
import { defaultEnvironment } from "lib/relay/createEnvironment"
import { renderWithPlaceholder } from "lib/utils/renderWithPlaceholder"
import React from "react"
import { createFragmentContainer, graphql, QueryRenderer } from "react-relay"
import { Fair } from "../Fair/Fair"

const VanityURLEntity: React.FC<{ fairOrPartner: VanityURLEntity_fairOrPartner }> = ({ fairOrPartner }) => {
  if (fairOrPartner.__typename === "Fair") {
    return <Fair fair={fairOrPartner} />
  } else if (fairOrPartner.__typename === "Partner") {
    // might need to add `safeAreaInsets.top` top padding here since `Fair` is full-bleed and `Partner` isn't.
    return null // <Partner partner={fairOrPartner} />
  }
  throw new Error(`404`)
}

const VanityURLEntityContainer = createFragmentContainer(VanityURLEntity, {
  fairOrPartner: graphql`
    fragment VanityURLEntity_fairOrPartner on VanityURLEntity {
      ... on Fair {
        __typename
        ...Fair_fair
      }
      ... on Partner {
        __typename
        ...Partner_partner
      }
    }
  `,
})

export const VanityURLEntityQueryRenderer: React.SFC<{ entity: "fair" | "partner"; id: string }> = ({ entity, id }) => {
  return (
    <QueryRenderer<VanityURLEntityQuery>
      environment={defaultEnvironment}
      query={graphql`
        query VanityURLEntityQuery($id: String!) {
          vanityURLEntity(id: $id) {
            __typename
          }
        }
      `}
      variables={{ id }}
      render={renderWithPlaceholder({
        Container: VanityURLEntityContainer,
        renderPlaceholder: () => (entity === "fair" ? <></> : <HeaderTabsGridPlaceholder />),
      })}
    />
  )
}
{'fraction_non_alphanumeric': 0.12196409714889124, 'fraction_numerical': 0.0015839493136219642, 'mean_word_length': 3.417249417249417, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 15, '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': '360714', 'n_tokens_mistral': 607, 'n_tokens_neox': 583, 'n_words': 119}