/**
 * ZUCHT-SUFFIX: provides the own-Zucht name suffix (from the breeder profile) once
 * to the whole app. Consumers use `useGerbilName()` from ./breederSuffix.
 */
import type { ReactNode } from 'react'
import { getBreederProfile } from '../api/settings'
import { useApi } from '../hooks/useApi'
import { OwnSuffixContext } from './breederSuffix'

export function BreederSuffixProvider({ children }: { children: ReactNode }) {
  const profile = useApi(() => getBreederProfile(), [])
  return (
    <OwnSuffixContext.Provider value={profile.data?.nameSuffix ?? ''}>
      {children}
    </OwnSuffixContext.Provider>
  )
}
