import React, {FC, useEffect, useState} from "react"; import {NotInCartNotification} from "./cards/BuyXGetY"; import {Text} from "./fields/Text"; import {__, CouponsPlus} from "../globals"; import field from "../Field"; import {FieldsGrid, GridField} from "./fields/FieldsGrid"; import {MultiSelectSearch} from "./fields/MultiSelectSearch"; import {mapLocalMetaFieldOptions} from "./cards/FieldHelpers"; import {BuyXGetXOptions} from "./cards/BuyXGetX"; export type BuyXGetYNotInCartNotificationConfigFieldsProps = { notification: NotInCartNotification, onDataModified: (notification: NotInCartNotification) => void } export const BuyXGetYNotInCartNotificationConfigFields: FC = ({notification, onDataModified}) => { const [message, setMessage] = useState(notification.message) const [buttonText, setButtonText] = useState(notification.button.text) const [buttonURLType, setButtonURLType] = useState(notification.button.url.type) const [buttonURLValue, setButtonURLValue] = useState(notification.button.url.value) useEffect(() => { onDataModified({ ...notification, message, button: { text: buttonText, url: { type: buttonURLType, value: buttonURLValue } } }) }, [message, buttonText, buttonURLType, buttonURLValue]) return

{__('Message')}

{__('Button')}

}, { title: 'URL Type', description: __("Shop: Will link to your site's shop page. URL: Select a custom URL."), field: { setButtonURLType(id) }} /> }, buttonURLType === 'url' && { title: __('URL'), description: __("The direct URL to send the customer after they've clicked the link."), field: } ].filter(v => v) as GridField[]} />
; }