import {createContext, type FunctionComponent, type PropsWithChildren, useState} from 'react'

export type Language = 'NL' | 'EN' | 'FR'

interface LanguageContextProps {
  selectedLanguage: Language
  setSelectedLanguage: (language: Language) => void
}

export const LanguageContext = createContext<LanguageContextProps>({
  selectedLanguage: 'NL',
  setSelectedLanguage: () => console.warn('No implementation for setSelectedLanguage, please provide one.'),
})

const LanguageProvider: FunctionComponent<PropsWithChildren> = ({children}) => {
  const [selectedLanguage, setSelectedLanguage] = useState<Language>('NL')

  return <LanguageContext value={{selectedLanguage, setSelectedLanguage}}>{children}</LanguageContext>
}

export default LanguageProvider
