AppendViewCard.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React from 'react';
  2. import { Card, Image, Badge } from 'antd';
  3. import { View } from '@/API/patient/viewActions';
  4. import { getViewIconUrl } from '@/API/bodyPosition';
  5. interface AppendViewCardProps {
  6. view: View;
  7. isSelected: boolean;
  8. onClick: (view: View) => void;
  9. }
  10. const AppendViewCard: React.FC<AppendViewCardProps> = ({
  11. view,
  12. isSelected,
  13. onClick,
  14. }) => {
  15. return (
  16. <Badge.Ribbon
  17. text="已选"
  18. color="green"
  19. style={{ display: isSelected ? 'block' : 'none' }}
  20. >
  21. <Card
  22. hoverable
  23. onClick={() => onClick(view)}
  24. className={`cursor-pointer transition-all ${
  25. isSelected
  26. ? 'border-4 border-[var(--color-primary)] shadow-lg'
  27. : 'border-2 border-gray-200'
  28. }`}
  29. cover={
  30. <Image
  31. alt={view.view_name}
  32. src={getViewIconUrl(view.view_icon_name || view.view_coach_name)}
  33. preview={false}
  34. style={{
  35. width: '100%',
  36. height: '120px',
  37. objectFit: 'contain',
  38. padding: '10px',
  39. }}
  40. />
  41. }
  42. >
  43. <Card.Meta
  44. title={
  45. <div className="text-center text-sm font-medium truncate">
  46. {view.view_name}
  47. </div>
  48. }
  49. description={
  50. <div className="text-center text-xs text-gray-500 truncate">
  51. {view.view_description}
  52. </div>
  53. }
  54. />
  55. </Card>
  56. </Badge.Ribbon>
  57. );
  58. };
  59. export default AppendViewCard;