import React, { memo } from 'react'; import type { ResultDetail } from '../types'; import CheckIcon from './CheckIcon'; import XCircleIcon from './XCircleIcon'; interface UserResultItemProps { detail: ResultDetail; onErrorClick: (details: string) => void; } const UserResultItem: React.FC = ({ detail, onErrorClick }) => { const isSuccess = detail.status === 'success'; const hasErrorDetails = !isSuccess && detail.errorDetails; // Check if message contains "Đã có quyền" - should be yellow/warning const isAlreadyHasPermission = isSuccess && detail.message?.includes('Đã có quyền'); // Determine status color: error=red, already has=yellow, success=green const statusColor = !isSuccess ? 'text-rose-400' : isAlreadyHasPermission ? 'text-amber-400' : 'text-green-400'; const Icon = isSuccess ? CheckIcon : XCircleIcon; const renderStatus = (className?: string) => { const commonClasses = `flex items-center gap-2 ${statusColor}`; if (hasErrorDetails) { return ( ) } return (
{detail.message}
); } return (
{detail.username}
{renderStatus('sm:col-span-6')}
); }; export default memo(UserResultItem);