import { memo } from '@wordpress/element'; import FieldWrapper from './FieldWrapper'; import Icon from '../../utils/Icon'; interface PricingPlan { storage: string; description: string; price: string; period: string; button: string; card_class?: string; button_class?: string; icon?: string; icon_size?: number; icon_color?: string; url?: string; } interface PricingFieldConfig { id: string; label?: string; context?: any; context_html?: string; title?: string; title_class?: string; grid_class?: string; url?: string; plans?: PricingPlan[]; default_card_class?: string; default_button_class?: string; default_icon?: string; default_icon_size?: number; default_icon_color?: string; [key: string]: any; } interface PricingProps { field: PricingFieldConfig; value?: any; onChange?: (value: any) => void; } const Pricing = ({ field }: PricingProps) => { const { title = '', title_class = 'text-[17px] mb-[14px] text-gray-900 mt-0', grid_class = 'grid grid-cols-2 gap-[10px]', url = '', plans = [], default_card_class = 'bg-gray-100 border-gray-300', default_button_class = 'rounded-xl bg-white text-gray-900 border border-gray-300 hover:bg-gray-100', default_icon = '', default_icon_size = 8, default_icon_color = 'currentColor', } = field; const renderPlanCard = (plan: PricingPlan, index: number) => { const cardClass = plan.card_class || default_card_class; const buttonClass = plan.button_class || default_button_class; const icon = plan.icon || default_icon; const iconSize = plan.icon_size !== undefined ? plan.icon_size : default_icon_size; const iconColor = plan.icon_color || default_icon_color; const planUrl = plan.url || url; return (
{plan.description}