import { Product, ProductVariant } from "@medusajs/medusa" import React from "react" import { useTranslation } from "react-i18next" import { ActionType } from "../../molecules/actionables" import { CollapsibleTree } from "../../molecules/collapsible-tree" type LeafProps = { id: string title: string sku?: string prices: { id: string currency_code: string amount: number price_list_id: string | null }[] } type ProductVariantTreeProps = { product: Pick & { variants: LeafProps[] } getProductActions?: (product: Product) => ActionType[] | undefined getVariantActions?: (variant: ProductVariant) => ActionType[] | undefined } const ProductVariantTree: React.FC = ({ product, getProductActions, getVariantActions, }) => { return (
{product.title}
{product.variants.map((variant) => ( ))}
) } const ProductVariantLeaf = ({ sku, title, prices = [] }: LeafProps) => { const { t } = useTranslation() const filteredPrices = prices.filter((pr) => pr.price_list_id) return (
{title} {sku && (SKU: {sku})}
{filteredPrices.length ? ( {t("product-variant-tree-count", "{{count}}", { count: filteredPrices.length, })} ) : ( {t("product-variant-tree-add-prices", "Add prices")} )}
) } export default ProductVariantTree