import React, {FC} from "react"; import {EmulatedButton} from "./EmulatedButton"; import {__, CouponsPlus} from "../globals"; import {useOpenTestablesPopupWindow} from "./useOpenTestablesPopupWindow"; import {convertTestableData, useNodesStore} from "./store"; import {PopupWindowStateContext, TreeContextData} from "./atoms"; import {wrapTestablesInDefaultGroup} from "./NodeHelpers"; import {TestableFormat} from "./testables"; import {WeeklyScheduleMeta} from "./cards/conditions/WeeklySchedule"; import {HolidaysMeta} from "./cards/conditions/Holidays"; import {predatesConditionPalette} from "./predatesPalette"; export type noPredatesProps = {} export const NoPredates: FC = ({}) => { const openTestablesPopup = useOpenTestablesPopupWindow() const addTestables = useNodesStore(store => store.addTestables) const openConditionsPanel = () => { // @ts-ignore const context = { id: 'predates-new', scope: 'predates', data: { componentType: 'condition', conditionColorPalette: predatesConditionPalette, targetType: 'ghost', // root | testableComposite supportedComponents: [ CouponsPlus?.components?.conditions?.Date?.type, CouponsPlus?.components?.conditions?.WeeklySchedule?.type ?? WeeklyScheduleMeta.id, CouponsPlus?.components?.conditions?.Holidays?.type ?? HolidaysMeta.id ], supportsMultipleComponents: false, showTabs: false, targetId: null, // string id if testableComposite, index if root (eg: 0 for the first root, 1 for the second root, etc) mainWindow: { title: __('Schedule'), description: __('Add a schedule that restricts when this coupon is available.') } } } as PopupWindowStateContext openTestablesPopup({ // @ts-ignore context, onClose: (data) => { if (data.status !== 'success' || !data.components) { return } addTestables([ [wrapTestablesInDefaultGroup(convertTestableData(data.components), undefined, 'OR')], TestableFormat.Nested ], (addedIds, testablesManager, writeableStore) => { // set the created testable group id as the preconditionsID const rootGroupID = addedIds?.[0] as string | undefined if (!rootGroupID) { return } writeableStore.predatesID = rootGroupID }) } }) } return

{__('Available anytime')} {__('Schedule')}

{false &&

}
}