Advertisement
Guest User

React snippet1

a guest
Jan 24th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import './handoff.scss';
  3. import PropsTypes from 'prop-types';
  4. import classNames from 'classnames';
  5. import LoaderOrComponent from '../../LoaderOrComponent';
  6.  
  7. const HandoffComponent = (props) => {
  8.   const {buttons, t, isIdCard, startMakePhoto, images, isValidForm, sendPhoto, errors, isLoading, isManualCapture, manualCapture, isManualLoading} = props;
  9.  
  10.   return (
  11.     <div className="handoff">
  12.       <h1 className="handoff__title">{isIdCard ? t('bgv.scanYourIDcard') : t('bgv.scanYourPassport')}</h1>
  13.       <ul>
  14.         <li>{t('bgv.rulesForScanning1')}</li>
  15.         <li>{isIdCard ? t('bgv.makeSureTheBarcode') : t('bgv.rulesForScanning2')}</li>
  16.         <li>{t('bgv.rulesForScanning3')}</li>
  17.         <li>{isIdCard ? t('bgv.theCardShouldHaveAllCornersVisible') : t('bgv.rulesForScanning4')}</li>
  18.       </ul>
  19.       <div className="handoff__button-container">
  20.         {
  21.           buttons.map((it, ind) =>
  22.             images[ind]
  23.               ? (
  24.                 <div
  25.                   className={
  26.                     classNames({
  27.                       'handoff__button-container__image': true,
  28.                       'with-error': errors[ind],
  29.                     })
  30.                   }
  31.                 >
  32.                   <img src={images[ind]}/>
  33.                   <p onClick={() => isManualCapture ? manualCapture(ind) : startMakePhoto(ind)}>
  34.                     {`${t('bgv.button-Rescan')} ${it.label}`}
  35.                   </p>
  36.                   <i className={classNames({
  37.                     fa: true,
  38.                     'fa-check': !errors[ind],
  39.                     'fa-times': errors[ind],
  40.                   })} aria-hidden="true"/>
  41.                 </div>
  42.               )
  43.               : (
  44.                 <button
  45.                   onClick={() => isManualCapture ? manualCapture(ind) : startMakePhoto(ind)}
  46.                   className="handoff__open-camera"
  47.                 >
  48.                   <LoaderOrComponent isLoading={isManualLoading[ind]}>
  49.                     <i className="fa fa-camera" aria-hidden="true"/>
  50.                     <span>{isManualCapture ? it.manualLabel : it.label}</span>
  51.                   </LoaderOrComponent>
  52.                 </button>
  53.               )
  54.           )
  55.         }
  56.       </div>
  57.       <div className="handoff__bottom">
  58.         <LoaderOrComponent
  59.           isLoading={isLoading.sendingPhoto}>
  60.           <button
  61.             onClick={sendPhoto}
  62.             disabled={!isValidForm}
  63.             className="terms-of-use__button-agree">
  64.             {t('bgv.submit')}
  65.           </button>
  66.         </LoaderOrComponent>
  67.       </div>
  68.     </div>
  69.   );
  70. };
  71.  
  72. HandoffComponent.propTypes = {
  73.   buttons: PropsTypes.array,
  74.   errors: PropsTypes.array,
  75.   images: PropsTypes.array,
  76.   t: PropsTypes.func,
  77.   startMakePhoto: PropsTypes.func,
  78.   sendPhoto: PropsTypes.func,
  79.   urlParams: PropsTypes.object,
  80.   isIdCard: PropsTypes.bool,
  81.   isValidForm: PropsTypes.bool,
  82.   isLoading: PropsTypes.bool,
  83. };
  84.  
  85. export default HandoffComponent;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement