/**
 * ZUCHT-SUFFIX: the own-Zucht name-suffix context + the `useGerbilName()` helper.
 * Kept separate from the provider component so each module has a single concern
 * (and satisfies react-refresh's "components-only" rule for .tsx files).
 */
import { createContext, useContext } from 'react'
import { gerbilDisplayName } from '../format/gerbilName'
import type { Gerbil } from '../api/types'

export const OwnSuffixContext = createContext<string>('')

/** Returns a function that renders a gerbil's display name incl. the Zucht suffix. */
export function useGerbilName() {
  const ownSuffix = useContext(OwnSuffixContext)
  return (g: Pick<Gerbil, 'name' | 'originContactId' | 'originBreeder'>): string =>
    gerbilDisplayName(g, ownSuffix)
}
