suggested-questions.tsx 930 B

1234567891011121314151617181920212223242526272829303132333435
  1. import type { FC } from 'react'
  2. import type { ChatItem } from '../../types'
  3. import { useChatContext } from '../context'
  4. type SuggestedQuestionsProps = {
  5. item: ChatItem
  6. }
  7. const SuggestedQuestions: FC<SuggestedQuestionsProps> = ({
  8. item,
  9. }) => {
  10. const { onSend } = useChatContext()
  11. const {
  12. isOpeningStatement,
  13. suggestedQuestions,
  14. } = item
  15. if (!isOpeningStatement || !suggestedQuestions?.length)
  16. return null
  17. return (
  18. <div className='flex flex-wrap'>
  19. {suggestedQuestions.map((question, index) => (
  20. <div
  21. key={index}
  22. className='mt-1 mr-1 max-w-full last:mr-0 shrink-0 py-[5px] leading-[18px] items-center px-4 rounded-lg border border-gray-200 shadow-xs bg-white text-xs font-medium text-primary-600 cursor-pointer'
  23. onClick={() => onSend?.(question)}
  24. >
  25. {question}
  26. </div>),
  27. )}
  28. </div>
  29. )
  30. }
  31. export default SuggestedQuestions