import classNames from 'classnames' import { useField } from '../../lib/hooks/useField' import { FormComponentConstructor } from '../../lib/types' import { FormFieldProps } from '../../types' import { Label } from '../Label/Label' import { usePreset } from '../../../../hooks/usePreset' import { GIFT_CARD_DESIGN_VARIANTS } from '../GiftCardDesignField/giftCardDesigns' import { GiftCardDesignPickerValue } from './types' import './GiftCardDesignPickerField.scss' const DEFAULT_DESIGN: GiftCardDesignPickerValue = 'botanical_green' const resolveSelectedDesign = (value: unknown): GiftCardDesignPickerValue => { const raw = String(value ?? '').trim() const match = GIFT_CARD_DESIGN_VARIANTS.find((variant) => variant.id === raw) return match ? match.id : DEFAULT_DESIGN } export const createGiftCardDesignPickerField: FormComponentConstructor< string > = ({ field }) => { return ({ name, label, misc }: FormFieldProps) => { const { value, setValue } = useField(field) const { plugin_url } = usePreset() as { plugin_url?: string } const selectedDesign = resolveSelectedDesign(value) return (
) } }