import React, {FC} from "react"; import {__} from "../globals"; import {EmulatedButton} from "./EmulatedButton"; import {CurrentDashboardSectionIdAtom, PopupWindowsState, PopupWindowStateContext, TreeContextData} from "./atoms"; import {TestablesSaver} from "./TestablesSaver"; import {Button} from "./cards/Button"; import {TreeDashboardSection} from "./TreeDashboardSections"; import {useOpenTestablesPopupWindow} from "./useOpenTestablesPopupWindow"; import {useAtom} from "jotai/index"; import {useOpenPopupsCount} from "./hooks"; import {getPopupStackDimensionCalculators} from "./ulitilies"; export type NewTreeActionsProps = { onClose?: PopupWindowsState['onClose'] onselectelegible?: () => void, onTemplateActionSelected?: () => void, } export const NewTreeActions: FC = ({onClose, onselectelegible, onTemplateActionSelected}) => { const openTestablePopupWindow = useOpenTestablesPopupWindow(); const [currentSectionId, setCurrentSectionId] = useAtom(CurrentDashboardSectionIdAtom) const popupsCount = useOpenPopupsCount() const stackDimensions = getPopupStackDimensionCalculators( popupsCount) return
{__('Select target products' /*'Select eligible cart items'*/)} { // @ts-ignore const context = { id: 'welcome', scope: 'tree-node', data: { componentType: 'filter', targetType: 'root', // root | testableComposite targetId: null, // string id if testableComposite, index if root (eg: 0 for the first root, 1 for the second root, etc) suggestedScopeExperienceSelector: true, // this one for showing the promo selector for the testables onClose: (data) => { // this is new because we changed the popups arch. // basically we now want to only close it on success. there mya be zombie comments that may suggest otherwise but this is the newest comment i promise if (data.status === 'success') { onClose?.(data); } }, showTabs: false, ...getPopupStackDimensionCalculators(popupsCount) } } as PopupWindowStateContext openTestablePopupWindow<{suggestedScope: string | undefined}>({ // @ts-ignore context, onClose: (data) => { if (data.status !== 'success' || !data.components) { return } // @ts-ignore const saver = new TestablesSaver(context) // @ts-ignore saver.add(data.components, data.extraData) } }) }}>{__('Select Products')}

{__('Or')}

}