/*
 *
 * SmsWrapper
 *
 */
import PropTypes from 'prop-types';
import React from 'react';
import SmsCreate from '../Sms/Create';
import { isTraiDLTEnable } from '../../utils/common';
import SmsEdit from '../Sms/Edit';
import SmsTraiCreate from '../SmsTrai/Create';
import SmsTraiEdit from '../SmsTrai/Edit';
const SmsWrapper = (props) => {
  const {
    isCreateSms,
    isEditSms,
    setIsLoadingContent,
    location,
    isGetFormData,
    getFormSubscriptionData,
    isFullMode,
    templateData,
    getDefaultTags,
    forwardedTags,
    selectedOfferDetails,
    onPreviewContentClicked,
    onTestContentClicked,
    onCreateComplete,
    handleClose,
    smsRegister,
    onShowTemplates,
    eventContextTags,
    waitEventContextTags,
    showLiquidErrorInFooter,
    getLiquidTags,
    showTestAndPreviewSlidebox,
    handleTestAndPreview,
    handleCloseTestAndPreview,
    isTestAndPreviewMode,
    onValidationFail,
    } = props;

  const smsProps = {
    onCreateComplete,
    setIsLoadingContent,
    location,
    route: { name: 'sms' },
    isGetFormData,
    getFormSubscriptionData,
    getDefaultTags,
    isFullMode,
    forwardedTags,
    selectedOfferDetails,
    onPreviewContentClicked,
    onTestContentClicked,
    eventContextTags,
    waitEventContextTags,
    showLiquidErrorInFooter,
    getLiquidTags,
    showTestAndPreviewSlidebox,
    handleTestAndPreview,
    handleCloseTestAndPreview,
    isTestAndPreviewMode,
    onValidationFail,
  };
  const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
  return <>
    {
      isCreateSms && (isTraiDlt ?
        <SmsTraiCreate
          isComponent
          {...smsProps}
          onShowTemplates={onShowTemplates}
          /> :
          <SmsCreate
            isComponent {
              ...smsProps
            }
          />
      )
    }
    {isEditSms && (isTraiDlt ?
      <SmsTraiEdit
        {...smsProps}
        params={{id: templateData._id}}
        templateData={templateData}
        handleClose={handleClose}
          /> : <SmsEdit
            {...smsProps}
            params={{id: templateData._id}}
            templateData={templateData}
          />
      )}
      </>;
};

export default SmsWrapper;
