Skip to content

Modal Actions

Shows a modal and returns a Promise that resolves when the modal closes. Depending on the user decision, the Promise resolves with true (confirmed) or false (dismissed).

import { showModal } from '@shopgate/engage/core';
dispatch(showModal({
confirm: null,
title: 'Modal title',
message: 'modal.message',
params: {
param: 'Modal Param',
}
}));
  • options (Object) required: Options used by the modal.
    • title (string) required: The title for the modal (i18n placeholder support from v6.5.0).
    • message (string) : The message for the modal (i18n placeholder support from v6.7.0).
    • confirm (string): The confirmation button label.
    • dismiss (string): The dismiss button label.
    • params (Object): Extra parameters for i18n placeholders.

Closes an open modal and resolves the mapped Promise.

import { closeModal } from '@shopgate/engage/core';
dispatch(closeModal(123, true))
  • id (number): The ID of the modal to close.
  • confirmed (boolean): Whether the modal is confirmed or not.