import {CustomAttribute} from "./AttributeFields"; import {CouponsPlus} from "../../globals"; import {SelectOption} from "../fields/MultiSelectSearch"; const getAttributeMeta = (attribute: CustomAttribute) => { return CouponsPlus.attributes.find(attr => attr.id === attribute.id); } export const getAttributeName = (attribute: CustomAttribute): string => getAttributeMeta(attribute)?.name ?? `? (${attribute.id})`; export const getAttributeValueNames = (attribute: CustomAttribute): string[] => getAttributeMeta(attribute) ?.values ?.filter(({id}) => attribute.values.includes(id)) ?.map?.(({name}) => name) ?? []