import cx from "classnames"; import React from "react"; import ConditionalWrapper from "../../utils/ConditionalWrapper"; import { Bar, BarItem } from "../Bar"; import { IconButton } from "../Button"; import { Icon } from "../Icon"; import { Image } from "../Image"; import { Tag } from "../Tag"; import { InfoTooltip } from "../Tooltip/InfoTooltip"; import type { Item } from "./generateTotal"; import Price from "./Price"; export interface Labels { [key: string]: string; remove: string; add: string; free: string; upfront: string; monthly: string; } export interface Row extends Item { description?: string | string[]; } interface RowResult { col1: React.ReactNode; col2: React.ReactNode; col3: React.ReactNode; col4?: React.ReactNode; } const generateRow = ( row: Row, isEditable: boolean, labels: Labels, ): RowResult => { const { isSubitem, image, badge, // type, name, tooltip, price, discount, description, icon, isMandatory, isOptional, } = row; return { col1: ( <> {isSubitem && ( )} {icon && ( )} {image && ( )} {badge && {badge}} {/* {type} */} {name}} > {name} {tooltip && "\xa0"} {tooltip && ( {tooltip} )} {description && (
{typeof description === "string" ? description : description.map((text) => (

{text}

))}
)}
{isEditable && !isMandatory && !isOptional ? ( ) : null} {isOptional && ( )}
{!price?.monthly && discount?.monthsCount && (

{`1. – ${discount.monthsCount}. mesiac`}

)} ), col2: ( ), col3: ( ), ...(isEditable && !isMandatory && !isOptional && { col4: ( {labels["remove"]} ), }), ...(isOptional && { col4: ( {labels["add"]} ), }), }; }; export default generateRow;