FormatSelector.tsx 888 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { useFormatsQuery, Format, FormatsQuery, FormatsQueryVariables } from '../../gql'
  2. import Selector from './Selector'
  3. interface IFormatSelector {
  4. value?: Format
  5. onChange: GenericEventHandler
  6. name?: string
  7. label?: string
  8. className?: string
  9. }
  10. const FormatSelectItem = ({ data }: { data: Format }) => {
  11. return (
  12. <div>
  13. <h3>{data.name}</h3>
  14. <p>{data.description}</p>
  15. </div>
  16. )
  17. }
  18. const FormatSelector = ({
  19. value,
  20. onChange,
  21. name = 'type',
  22. label = 'Training type',
  23. className = 'training-type',
  24. }: IFormatSelector) => {
  25. return (
  26. <Selector<FormatsQuery, FormatsQueryVariables>
  27. SelectorItem={FormatSelectItem}
  28. name={name}
  29. value={value}
  30. onChange={onChange}
  31. query={useFormatsQuery}
  32. searchKeys={['name_contains', 'description_contains']}
  33. className={className}
  34. />
  35. )
  36. }
  37. export default FormatSelector