AgentsView.tsx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import React from 'react';
  2. import { useLanguage } from '../../contexts/LanguageContext';
  3. import { Search, Plus, MoreHorizontal, MessageSquare } from 'lucide-react';
  4. import { motion, AnimatePresence } from 'framer-motion';
  5. // Mock data based on the provided design
  6. interface AgentMock {
  7. id: string;
  8. name: string;
  9. description: string;
  10. status: 'running' | 'stopped';
  11. updatedAt: string;
  12. iconEmoji: string;
  13. iconBgClass: string;
  14. }
  15. const mockAgents: AgentMock[] = [
  16. {
  17. id: '1',
  18. name: 'agent1Name',
  19. description: 'agent1Desc',
  20. status: 'running',
  21. updatedAt: 'agent1Time',
  22. iconEmoji: '🧑‍💻',
  23. iconBgClass: 'bg-indigo-50'
  24. },
  25. {
  26. id: '2',
  27. name: 'agent2Name',
  28. description: 'agent2Desc',
  29. status: 'running',
  30. updatedAt: 'agent2Time',
  31. iconEmoji: '💻',
  32. iconBgClass: 'bg-green-50'
  33. },
  34. {
  35. id: '3',
  36. name: 'agent3Name',
  37. description: 'agent3Desc',
  38. status: 'running',
  39. updatedAt: 'agent3Time',
  40. iconEmoji: '📐',
  41. iconBgClass: 'bg-blue-50'
  42. },
  43. {
  44. id: '4',
  45. name: 'agent4Name',
  46. description: 'agent4Desc',
  47. status: 'stopped',
  48. updatedAt: 'agent4Time',
  49. iconEmoji: '🧪',
  50. iconBgClass: 'bg-slate-100'
  51. },
  52. {
  53. id: '5',
  54. name: 'agent5Name',
  55. description: 'agent5Desc',
  56. status: 'running',
  57. updatedAt: 'agent5Time',
  58. iconEmoji: '📊',
  59. iconBgClass: 'bg-purple-50'
  60. },
  61. {
  62. id: '6',
  63. name: 'agent6Name',
  64. description: 'agent6Desc',
  65. status: 'running',
  66. updatedAt: 'agent6Time',
  67. iconEmoji: '⚙️',
  68. iconBgClass: 'bg-orange-50'
  69. },
  70. {
  71. id: '7',
  72. name: 'agent7Name',
  73. description: 'agent7Desc',
  74. status: 'running',
  75. updatedAt: 'agent7Time',
  76. iconEmoji: '📈',
  77. iconBgClass: 'bg-red-50'
  78. }
  79. ];
  80. export const AgentsView: React.FC = () => {
  81. const { t } = useLanguage();
  82. return (
  83. <div className="flex flex-col h-full bg-[#f4f7fb] overflow-hidden">
  84. {/* Header Area */}
  85. <div className="px-8 pt-8 pb-6 flex items-start justify-between shrink-0">
  86. <div>
  87. <h1 className="text-[22px] font-bold text-slate-900 leading-tight">
  88. {t('agentTitle')}
  89. </h1>
  90. <p className="text-[14px] text-slate-500 mt-1">{t('agentDesc')}</p>
  91. </div>
  92. <div className="flex items-center gap-4">
  93. <div className="relative w-64">
  94. <Search className="absolute text-slate-400 left-3 top-1/2 -translate-y-1/2" size={16} />
  95. <input
  96. type="text"
  97. placeholder={t('searchAgent')}
  98. className="w-full h-10 pl-10 pr-4 bg-white border border-slate-200 rounded-lg focus:bg-white focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 outline-none transition-all text-sm font-medium"
  99. />
  100. </div>
  101. <button className="flex items-center gap-2 px-5 h-10 bg-blue-600 hover:bg-blue-700 text-white rounded-lg shadow-sm shadow-blue-100 transition-all font-semibold text-sm active:scale-95">
  102. <Plus size={18} />
  103. <span>{t('createAgent')}</span>
  104. </button>
  105. </div>
  106. </div>
  107. {/* Content Area */}
  108. <div className="px-8 pb-8 flex-1 overflow-y-auto">
  109. <div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6 max-w-[1600px] mx-auto">
  110. <AnimatePresence>
  111. {mockAgents.map((agent) => (
  112. <motion.div
  113. key={agent.id}
  114. layout
  115. initial={{ opacity: 0, y: 10 }}
  116. animate={{ opacity: 1, y: 0 }}
  117. className="bg-white rounded-2xl p-6 shadow-sm border border-slate-100 hover:shadow-md transition-all group flex flex-col h-[220px]"
  118. >
  119. {/* Top layer */}
  120. <div className="flex items-center justify-between mb-4">
  121. <div className={`w-12 h-12 flex items-center justify-center rounded-xl ${agent.iconBgClass} text-2xl`}>
  122. {agent.iconEmoji}
  123. </div>
  124. <div className="flex items-center gap-3">
  125. {/* Status Badge */}
  126. {agent.status === 'running' ? (
  127. <div className="px-2.5 py-1 text-[12px] font-semibold text-emerald-600 bg-emerald-50 rounded-full border border-emerald-100/50 flex flex-row items-center justify-center">
  128. {t('statusRunning')}
  129. </div>
  130. ) : (
  131. <div className="px-2.5 py-1 text-[12px] font-semibold text-slate-500 bg-slate-50 rounded-full border border-slate-100 flex flex-row items-center justify-center">
  132. {t('statusStopped')}
  133. </div>
  134. )}
  135. {/* Options button */}
  136. <button className="text-slate-400 hover:text-slate-600 transition-colors">
  137. <MoreHorizontal size={20} />
  138. </button>
  139. </div>
  140. </div>
  141. {/* Middle layer */}
  142. <div className="flex-1">
  143. <h3 className="font-bold text-slate-800 text-[17px] mb-2 leading-tight">
  144. {t(agent.name as any)}
  145. </h3>
  146. <p className="text-[13px] text-slate-500 leading-relaxed line-clamp-2">
  147. {t(agent.description as any)}
  148. </p>
  149. </div>
  150. {/* Bottom layer */}
  151. <div className="mt-4 pt-4 border-t border-slate-50 flex items-center justify-between">
  152. <span className="text-[12px] font-medium text-slate-400">
  153. {t('updatedAtPrefix')}{t(agent.updatedAt as any)}
  154. </span>
  155. <button className="flex items-center justify-center gap-1.5 px-3 py-1.5 text-blue-600 bg-blue-50 hover:bg-blue-100 rounded-lg transition-colors">
  156. <MessageSquare size={14} className="text-blue-500" />
  157. <span className="text-[13px] font-bold">{t('btnChat')}</span>
  158. </button>
  159. </div>
  160. </motion.div>
  161. ))}
  162. </AnimatePresence>
  163. </div>
  164. </div>
  165. </div>
  166. );
  167. };