card.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import type { FC } from 'react'
  2. import { CopyFeedbackNew } from '@/app/components/base/copy-feedback'
  3. type CardProps = {
  4. log: { role: string; text: string }[]
  5. }
  6. const Card: FC<CardProps> = ({
  7. log,
  8. }) => {
  9. return (
  10. <>
  11. {
  12. log.length === 1 && (
  13. <div className='px-4 py-2'>
  14. <div className='whitespace-pre-line text-gray-700'>
  15. {log[0].text}
  16. </div>
  17. </div>
  18. )
  19. }
  20. {
  21. log.length > 1 && (
  22. <div>
  23. {
  24. log.map((item, index) => (
  25. <div key={index} className='group/card mb-2 px-4 pt-2 pb-4 rounded-xl hover:bg-gray-50 last-of-type:mb-0'>
  26. <div className='flex justify-between items-center h-8'>
  27. <div className='font-semibold text-[#2D31A6]'>{item.role.toUpperCase()}</div>
  28. <CopyFeedbackNew className='hidden w-6 h-6 group-hover/card:block' content={item.text} />
  29. </div>
  30. <div className='whitespace-pre-line text-gray-700'>{item.text}</div>
  31. </div>
  32. ))
  33. }
  34. </div>
  35. )
  36. }
  37. </>
  38. )
  39. }
  40. export default Card