import React from 'react'

function CouponTable({coupon}) {
  return (
    <table className="wallet-activity w-full table-auto border-collapse text-left">
        <thead className='border-b-2'>
            <tr className='text-slate-600'>
            <th className="p-2">Date</th>
            <th className="p-2">Description</th>
            <th className="p-2">Amount</th>
            <th className="p-2">Active</th>
            </tr>
        </thead>
        {coupon.data.length ?
        (
        <tbody>
            {coupon.data.map((item, index) => (
            <tr key={index} className='text-slate-500'>
                <td className="p-2">{item.added}</td>
                <td className="p-2">{item.code}</td>
                <td className="p-2">{item.amount}</td>
                <td className="p-2">{item.status}</td>
            </tr>
            ))}
        </tbody>
        )
        :
        coupon.error ? 
        (
        <tbody>
            <tr className='text-slate-500'>
                <td className="p-2" colSpan={4}>Opps! an error occurred. Please try again!</td>
            </tr>
        </tbody>
        )
        :
        <tbody>
            <tr className='text-slate-500'>
                <td className="p-2" colSpan={4}>No Purchase History Found!</td>
            </tr>
        </tbody>
        }
    </table>
  )
}

export default CouponTable