import { Delete } from '@wix/wix-ui-icons-common'; import React from 'react'; import { CollectionOptimisticActions, DeleteManyParams, FiltersMap, } from '@wix/bex-core'; import { ActionCellAPI } from '../../state'; export interface DeleteSecondaryActionProps extends DeleteManyParams { /** * Actions for performing optimistic updates on the collection. * These updates are applied immediately for better user experience * while waiting for the server response. * @external */ optimisticActions: CollectionOptimisticActions; /** * API for interacting with the action cell. * This API provides methods for manipulating and accessing the action cell's state. * @external */ actionCellAPI: ActionCellAPI; } export function deleteSecondaryAction( props: DeleteSecondaryActionProps, ) { const { optimisticActions, actionCellAPI: { openConfirmDeleteModal, collection, keyedItem }, ...deleteManyParams } = props; const { translate: t } = collection; return { dataHook: 'collection-delete-action', text: t('cairo.delete.button'), icon: , onClick: () => { openConfirmDeleteModal({ primaryButtonOnClick: () => { optimisticActions.deleteOne(keyedItem.item, deleteManyParams); }, }); }, }; }