import React from 'react';
import { translate } from '../../../Helper';

const RewardPointsRow = ({ pointEntry }) => {
  const orderViewUrl = `admin.php?page=wc-orders&action=edit&id=${pointEntry.order_id}`;
  return (
    <tr className="hover:ecre-bg-gray-50">
        <td className="ecre-px-5 ecre-py-4 ecre-whitespace-nowrap">
            <div className="ecre-text-[#4f4f4f] ecre-text-sm ecre-font-semibold">
              {pointEntry.points_display || `${pointEntry.points} ${translate('points_text')}`}
            </div>
            <div className="ecre-text-sm ecre-text-[#757575] ecre-font-normal">
              {translate('issued')}: {pointEntry.earned_date || pointEntry.issuedDate}
            </div>
        </td>
        <td className="ecre-px-5 ecre-py-4 ecre-whitespace-nowrap ecre-text-sm ecre-text-gray-900">
            {pointEntry.earned_date || pointEntry.expiryDate || translate('n_a')}
        </td>
         <td className="ecre-px-5 ecre-py-4 ecre-whitespace-nowrap">
           {Number(pointEntry.order_id) > 0 ? (
            <a 
              href={orderViewUrl}
              target="_blank"
              rel="noopener noreferrer"
              className="ecre-text-blue-600 ecre-cursor-pointer hover:ecre-text-[#6A40D5] ecre-text-sm ecre-font-medium">{translate('view_order')}
            </a>
            ): (
              <span className="ecre-text-gray-400 ecre-text-sm">{translate('n_a')}</span>
            )}
        </td>
    </tr>
  );
};

export default RewardPointsRow;