How to use the @commercetools-frontend/constants.NOTIFICATION_KINDS_SIDE.success function in @commercetools-frontend/constants

To help you get started, we’ve selected a few @commercetools-frontend/constants examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commercetools / merchant-center-application-kit / packages / actions-global / src / actions / show-notification.ts View on Github external
if (process.env.NODE_ENV !== 'production')
    if (notification.domain) {
      if (!Object.values(NOTIFICATION_DOMAINS).includes(notification.domain))
        // eslint-disable-next-line no-console
        console.warn(
          `Unknown notification domain "${notification.domain}"`,
          notification
        );
    }
    // eslint-disable-next-line no-console
    else console.warn('Notification is missing domain', notification);

  let dismissAfter = meta.dismissAfter;
  if (!isNumber(dismissAfter))
    dismissAfter =
      notification.kind === NOTIFICATION_KINDS_SIDE.success ? 5000 : 0;

  return addNotification>(notification, {
    ...meta,
    dismissAfter,
  });
}
github commercetools / merchant-center-application-kit / packages / react-notifications / src / components / notifier / notifier.spec.tsx View on Github external
await wait(() => {
      expect(showNotification).toHaveBeenCalledWith(
        expect.objectContaining({
          domain: NOTIFICATION_DOMAINS.SIDE,
          kind: NOTIFICATION_KINDS_SIDE.success,
          text: 'foo',
        }),
        undefined
      );
      expect(dismiss).not.toHaveBeenCalled();
    });
github commercetools / merchant-center-application-kit / packages / react-notifications / src / components / notification / notification.styles.ts View on Github external
const getColorByType = (value: TAppNotificationKind) => {
  switch (value) {
    case NOTIFICATION_KINDS_SIDE.success:
      return customProperties.colorPrimary;
    case NOTIFICATION_KINDS_SIDE.info:
      return customProperties.colorInfo;
    case NOTIFICATION_KINDS_SIDE.error:
      return customProperties.colorError;
    case NOTIFICATION_KINDS_SIDE.warning:
      return customProperties.colorWarning;
    default:
      return 'transparent';
  }
};
github commercetools / merchant-center-application-kit / packages / react-notifications / src / components / notifier / notifier.tsx View on Github external
NOTIFICATION_DOMAINS,
  TAppNotificationDomain,
  TAppNotificationKind,
  NOTIFICATION_KINDS_SIDE,
} from '@commercetools-frontend/constants';

type Props = {
  domain: TAppNotificationDomain;
  kind: TAppNotificationKind;
  text?: string;
  meta?: { [key: string]: unknown };
  dismissAfter?: number;
};
const defaultProps: Pick = {
  domain: NOTIFICATION_DOMAINS.SIDE,
  kind: NOTIFICATION_KINDS_SIDE.success,
};

const Notifier = (props: Props) => {
  const showNotification = globalActions.useShowNotification<
    Props & { id: number }
  >();

  React.useEffect(() => {
    const notification = showNotification(
      {
        id: 0,
        domain: props.domain,
        kind: props.kind,
        text: props.text,
      },
      isNumber(props.dismissAfter)
github commercetools / merchant-center-application-kit / packages / react-notifications / src / components / notifications-list / notifications-list.tsx View on Github external
return (
             {
                dispatch(removeNotification(notification.id));
              }}
            />
          );
        }

        switch (notification.kind) {
          case NOTIFICATION_KINDS_SIDE.error:
          case NOTIFICATION_KINDS_SIDE.warning:
          case NOTIFICATION_KINDS_SIDE.info:
          case NOTIFICATION_KINDS_SIDE.success:
            return (
               {
                  dispatch(removeNotification(notification.id));
                }}
              />
            );
          default:
            return null;
        }
      })}

@commercetools-frontend/constants

Shared constants for MC applications

MIT
Latest version published 3 days ago

Package Health Score

87 / 100
Full package analysis