Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wildberries/confirm-modal-portal

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wildberries/confirm-modal-portal

confirm modal module

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
52
increased by108%
Maintainers
3
Weekly downloads
 
Created
Source

@wildberries/confirm-modal-portal

Build Status

Sollution for confirm modals, connected with redux, based on

@wildberries/ui-kit

Examples of usage

Installation

npm install @wildberries/confirm-modal-portal

Connect to your root reducer

import {
  CONFIRM_MODALS_REDUCER_NAME,
  confirmModalModuleReducer,
} from '@wildberries/confirm-modal-portal';

export const rootReducer = {
  [CONFIRM_MODALS_REDUCER_NAME]: confirmModalModuleReducer,
};

Insert the ConfirmModal component into your project

import React, { memo } from "react";
import { ConfirmModal } from '@wildberries/confirm-modal-portal';

const TestComponent = memo(() => (
    <ConfirmModal />
  )
)

Dispatch setConfirmModalAction to add confirm modal

SetModalAction params:
  • title - title of the modal
  • content - modal content (React component)
  • titleSize - title size
  • size - modal size
  • confirmActionParams - params of modal confirmation process (see below)
  • confirmButtonProps - params of confirm button
  • cancelButtonProps- params of cancel button
  • noPadding - set padding 0
ConfirmActionParams params:
  • requestParamsFormatter - formatter before equest data will be sent
  • request - the request that needs to be confirmed
  • requestParams - params that will be set to the request
  • setErrorAction - the action that will be dispatched when error from the request comes
  • setErrorActionsArray - the array of actions that will be dispatched when error from the request comes
  • setSuccessAction - the action that will be dispatched when success from the request comes
  • setSuccessActionsArray - the array of actions that will be dispatched when success from the request comes
  • notificationSuccessConfig - the text config for the successful notification
  • notificationErrorConfig - the text config for the error notification
  • responseDataFormatter - formatter of the data that goes to the success action (or an array of actions)
  • resetInitialFormValuesAction - resetting form values (RFF needs if connected to the redux)
  • showNotificationError - flag to show error notification when error from the request comes
  • showNotificationSuccess - flag to show success notification when success from the request comes
Please, Be careful, these actions are not from connect - but pure actions:
  • setErrorAction
  • setErrorActionsArray
  • setSuccessAction
  • setSuccessActionsArray
import React from "react";
import {
  setConfirmModalAction,
  ConfirmModalStateType,
  closeConfirmModalAction,
} from '@wildberries/confirm-modal-portal';
import { useDispatch } from "react-redux";

function ExampleComponent() {
  const dispatch = useDispatch();

  const openConfirmModal = () => {
    dispatch(
      this.props.setConfirmModalAction({
        content: <SomeYourContentComponent />,
        confirmActionParams: {
          request: deleteUserFromSupplierRequest,
          requestParams: { foo: 'bar' },
          setSuccessActionsArray: [
            this.props.closeConfirmModal,
            () =>
              this.props.deleteSupplierUser({
                supplierId,
                userId,
              }),
          ],
          notificationSuccessConfig: {title:'Пользователь был удалён'},
          showNotificationError: true,
          showNotificationSuccess: true,
        },
        confirmButtonProps: {
          text: 'Удалить',
        },
        cancelButtonProps: {
          text: 'Отмена',
        },
      })
  }

  return (
    <div className="ExampleComponent">
        <button onClick={openConfirmModal}>button</button>
    </div>
  );
}

export default ExampleComponent;

Please, be careful

  • close modal action always adds to the user redux actions if you need not to close confirm modal after successful request please set notCloseAfterSuccessRequest option to true

FAQs

Package last updated on 04 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc