import { Edit, Trash } from "iconsax-react"
import { BankCartInterface } from "../../types"
import { FC } from "react"
import { findBankByPAN, formatCartNumber } from "../../utility/cart"

type Props = {
    item: BankCartInterface,
    handleOpenDeleteDialog: () => void
}

export const BankCart: FC<Props> = ({ item, handleOpenDeleteDialog }) => {
    return (
        <div className={`w-full flex flex-col justify-between rounded-[40px] bg-auth-form p-[18px] cursor-pointer bank-bg min-h-[226px]`} style={{ backgroundImage: `url('/svgs/banks/${item?.bankName}.svg')` }}>
            <div className="flex flex-row justify-between items-center">
                <div className="flex flex-row gap-3 items-center">
                    {findBankByPAN(item.cartNumber).icon}
                    <p className="text-lg font-medium text-primary-text-color">بانک {item?.bankPersianName}</p>
                </div>
                <div className="flex flex-row gap-3 items-center">
                    <Trash color="#777577" onClick={handleOpenDeleteDialog} />
                    <Edit color="#777577" />
                </div>
            </div>
            <p className="font-medium text-2xl text-primary-text-color text-center" style={{ direction: "ltr" }}>{formatCartNumber(item?.cartNumber)}</p>
            <div className="flex flex-row items-center justify-between">
                <p className="text-sm text-secondary-text-color font-medium">{item?.cartOwner}</p>
                <p className="font-medium text-lg text-primary-text-color">IR {item?.shabaNumber}</p>
            </div>
        </div>
    )
}