<commit_before>import React from "react"
import { SavedSearchAlertPills } from "./SavedSearchAlertPills"
import { FilterPill, SavedSearchEntity } from "../types"
import { useActiveFilterPills } from "../useActiveFilterPills"
import { Flex, Spacer } from "@artsy/palette"
import { useArtworkFilterContext } from "Components/ArtworkFilter/ArtworkFilterContext"
import { usePrepareFiltersForPills } from "Components/ArtworkFilter/Utils/usePrepareFiltersForPills"
import { getSearchCriteriaFromFilters } from "../Utils/savedSearchCriteria"
import { DEFAULT_METRIC } from "Utils/metrics"
import { AuthModalOptions } from "Utils/openAuthModal"
import { ContextModule, Intent } from "@artsy/cohesion"
import { SavedSearchCreateAlertButton } from "./SavedSearchCreateAlertButton"

export interface ActiveFilterPillsAndCreateAlertProps {
  savedSearchEntity: SavedSearchEntity
  defaultPills?: FilterPill[]
}

const PILL_HORIZONTAL_MARGIN_SIZE = 0.5

export const ActiveFilterPillsAndCreateAlert: React.FC<ActiveFilterPillsAndCreateAlertProps> = props => {
  const { defaultPills = [], savedSearchEntity } = props
  const { pills, removePill } = useActiveFilterPills(defaultPills)
  const { aggregations } = useArtworkFilterContext()
  const filters = usePrepareFiltersForPills()
  const criteria = getSearchCriteriaFromFilters(savedSearchEntity, filters)
  const metric = filters?.metric ?? DEFAULT_METRIC

  const getAuthModalOptions = (): AuthModalOptions => {
    return {
      entity: {
        name: savedSearchEntity.owner.name,
        slug: savedSearchEntity.owner.slug,
      },
      afterSignUpAction: {
        action: "createAlert",
        kind: "artist",
        objectId: savedSearchEntity.owner.slug,
      },
      contextModule: ContextModule.artworkGrid,
      intent: Intent.createAlert,
      redirectTo: location.href,
    }
  }

  return (
    <Flex
      flexWrap="wrap"
      mx={-PILL_HORIZONTAL_MARGIN_SIZE}
      mb={4}
      data-testid="artworkGridFilterPills"
    >
      <SavedSearchAlertPills items={pills} onDeletePress={removePill} />

      <Spacer ml={PILL_HORIZONTAL_MARGIN_SIZE} />

      <SavedSearchCreateAlertButton
        entity={savedSearchEntity}
        criteria={criteria}
        metric={metric}
        aggregations={aggregations}<commit_msg>chore: change auth modal copy for artwork alert creation<commit_after>import React from "react"
import { SavedSearchAlertPills } from "./SavedSearchAlertPills"
import { FilterPill, SavedSearchEntity } from "../types"
import { useActiveFilterPills } from "../useActiveFilterPills"
import { Flex, Spacer } from "@artsy/palette"
import { useArtworkFilterContext } from "Components/ArtworkFilter/ArtworkFilterContext"
import { usePrepareFiltersForPills } from "Components/ArtworkFilter/Utils/usePrepareFiltersForPills"
import { getSearchCriteriaFromFilters } from "../Utils/savedSearchCriteria"
import { DEFAULT_METRIC } from "Utils/metrics"
import { AuthModalOptions } from "Utils/openAuthModal"
import { ContextModule, Intent } from "@artsy/cohesion"
import { SavedSearchCreateAlertButton } from "./SavedSearchCreateAlertButton"

export interface ActiveFilterPillsAndCreateAlertProps {
  savedSearchEntity: SavedSearchEntity
  defaultPills?: FilterPill[]
}

const PILL_HORIZONTAL_MARGIN_SIZE = 0.5

export const ActiveFilterPillsAndCreateAlert: React.FC<ActiveFilterPillsAndCreateAlertProps> = props => {
  const { defaultPills = [], savedSearchEntity } = props
  const { pills, removePill } = useActiveFilterPills(defaultPills)
  const { aggregations } = useArtworkFilterContext()
  const filters = usePrepareFiltersForPills()
  const criteria = getSearchCriteriaFromFilters(savedSearchEntity, filters)
  const metric = filters?.metric ?? DEFAULT_METRIC

  const getAuthModalOptions = (): AuthModalOptions => {
    return {
      entity: {
        name: savedSearchEntity.owner.name,
        slug: savedSearchEntity.owner.slug,
      },
      afterSignUpAction: {
        action: "createAlert",
        kind: "artist",
        objectId: savedSearchEntity.owner.slug,
      },
      contextModule: ContextModule.artworkGrid,
      title: "Sign up to create an alert",
      intent: Intent.createAlert,
      redirectTo: location.href,
    }
  }

  return (
    <Flex
      flexWrap="wrap"
      mx={-PILL_HORIZONTAL_MARGIN_SIZE}
      mb={4}
      data-testid="artworkGridFilterPills"
    >
      <SavedSearchAlertPills items={pills} onDeletePress={removePill} />

      <Spacer ml={PILL_HORIZONTAL_MARGIN_SIZE} />

      <SavedSearchCreateAlertButton
        entity={savedSearchEntity}
        criteria={criteria}
        metric={metric}
        aggregations={aggregations}
{'fraction_non_alphanumeric': 0.09381708887934737, 'fraction_numerical': 0.0012881064834693002, 'mean_word_length': 4.367511520737327, 'pattern_counts': {'":': 0, '<': 13, '<?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': '3838346', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1361, 'n_words': 266}