import React from 'react';

import { formatCurrency } from '@/packages/shared/src/utils';
import { StoreCartLineItem } from '@medusajs/types';
import { useTranslation } from 'react-i18next';

import { Table, TableBody } from '@kit/ui/shadcn/table';

import MobileTableRow from './mobile-table-row';

const MobileCartItems = ({
  item,
  currencyCode,
  productColumnLabelKey,
}: {
  item: StoreCartLineItem;
  currencyCode: string;
  productColumnLabelKey: string;
}) => {
  const {
    i18n: { language, t },
  } = useTranslation();

  return (
    <Table className="border-separate rounded-lg border p-2">
      <TableBody>
        <MobileTableRow
          title={t(productColumnLabelKey)}
          value={item.product_title}
        />
        <MobileTableRow title={t('cart:table.time')} value={item.quantity} />
        <MobileTableRow
          title={t('cart:table.price')}
          value={formatCurrency({
            value: item.unit_price,
            currencyCode,
            locale: language,
          })}
        />
        <MobileTableRow
          title={t('cart:table.total')}
          value={
            item.total &&
            formatCurrency({
              value: item.total,
              currencyCode,
              locale: language,
            })
          }
        />
      </TableBody>
    </Table>
  );
};

export default MobileCartItems;
