ExerciseInputs.tsx 768 B

12345678910111213141516171819202122232425262728
  1. import { TextInput } from '../../form'
  2. import { TExercise } from '../types'
  3. import ExerciseSelector from './ExerciseSelector'
  4. interface IExerciseInputs {
  5. onChange: GenericEventHandler
  6. value?: TExercise
  7. name: string
  8. }
  9. const ExerciseInputs = ({ onChange, value, name }: IExerciseInputs) => {
  10. if (!value) return null
  11. return (
  12. <>
  13. <p>Exercise: {value?.id}</p>
  14. <ExerciseSelector name={name} value={value} label='Existing exercise' onChange={onChange} />
  15. <TextInput name={`${name}.name`} label='Name' value={value.name} onChange={onChange} />
  16. <TextInput
  17. name={`${name}.description`}
  18. label='Description'
  19. value={value.description}
  20. onChange={onChange}
  21. />
  22. </>
  23. )
  24. }
  25. export default ExerciseInputs