Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react'
  2. import { AntCol as Col, AntRow as Row, Alert, icons, Icon, CardHeader, Card, Button } from 'lean-theme'
  3. import { useTranslation } from 'react-i18next'
  4. import { viewDependentsStatuses } from '../../../constants'
  5. import styles from './DependentsList.module.scss'
  6. import { useRouter } from '../../hooks/'
  7.  
  8. const Dependent = ({ nationalId, dependentDetail }) => (
  9.     <>
  10.         <div className={styles['dependent-detail']}>
  11.             <span className={styles['dependent-Icon']}>
  12.                 <Icon svg={icons.DEPENDENT_ICON} additions={['fit-to-wrapper']} />
  13.             </span>
  14.             <span className={styles['dependent-info']}>{dependentDetail}</span>
  15.         </div>
  16.         <div className={styles['dependent-detail']}>
  17.             <span className={styles['user-Icon']}>
  18.                 <Icon svg={icons.USER} additions={['fit-to-wrapper']} />
  19.             </span>
  20.             <span className={styles['dependent-info']}>{nationalId}</span>
  21.         </div>
  22.     </>
  23. )
  24.  
  25. export const DependentsList = ({ dependents }) => {
  26.     const [t] = useTranslation()
  27.  
  28.     const {
  29.         history: { push }
  30.     } = useRouter()
  31.  
  32.     const goToAddDependent = () => push('/add-user')
  33.  
  34.     return (
  35.         <Row gutter={20} type="flex">
  36.             {dependents.map(({ cardHeader, dependentDetail, nationalId, status }, index) => {
  37.                 let statusClass = []
  38.  
  39.                 const isRequestPending = status === viewDependentsStatuses.PENDING
  40.                 status === viewDependentsStatuses.FEMALE && statusClass.push('female')
  41.                 status === viewDependentsStatuses.MALE && statusClass.push('male')
  42.                 return (
  43.                     <Col span={8} key={index} className={styles['Col']}>
  44.                         <Card
  45.                             additions={['dependents-list']}
  46.                             title={
  47.                                 <CardHeader
  48.                                     nativeIcon="user"
  49.                                     title={cardHeader}
  50.                                     iconAdditions={['dependents-list', ...statusClass]}
  51.                                 />
  52.                             }
  53.                             actions={
  54.                                 isRequestPending
  55.                                     ? []
  56.                                     : [
  57.                                           <>
  58.                                               <Icon type="edit" />
  59.                                               &nbsp;
  60.                                               {t('viewDependents.update')}
  61.                                           </>,
  62.                                           <Icon type="ellipsis" />
  63.                                       ]
  64.                             }
  65.                             content={
  66.                                 <div className={styles['content']}>
  67.                                     {isRequestPending ? (
  68.                                         <Alert
  69.                                             message={t('viewDependents.pendingVerification')}
  70.                                             className={styles['Alert']}
  71.                                         />
  72.                                     ) : (
  73.                                         <Dependent nationalId={nationalId} dependentDetail={dependentDetail} />
  74.                                     )}
  75.                                 </div>
  76.                             }
  77.                         />
  78.                     </Col>
  79.                 )
  80.             })}
  81.             <Col span={8} className={styles['Col']}>
  82.                 <Button additions={['add-new-dependent']} type="dashed" icon="plus-circle" onClick={goToAddDependent}>
  83.                     {t('viewDependents.addDependent')}
  84.                 </Button>
  85.             </Col>
  86.         </Row>
  87.     )
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement