Ionic + React accounts android app and PWA
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

103 lignes
3.4 KiB

  1. import React, { useState } from 'react';
  2. import styles from './itemCard.module.scss';
  3. import { ReactComponent as ChevronBack } from 'ionicons/dist/svg/chevron-back.svg';
  4. import { IonButton } from '@ionic/react';
  5. type OwnProps = {
  6. leftImage?: string,
  7. heading: {
  8. name: string,
  9. value: string
  10. },
  11. value: string,
  12. description?: string,
  13. rightText?: {
  14. name: string,
  15. type: 'success' | 'danger' | 'warning' | undefined
  16. },
  17. details?: Array<{
  18. name: string,
  19. value: string
  20. }>,
  21. form?: JSX.Element,
  22. }
  23. // Card - Image on the left, heading-value-description in the middle and status or any text on the right.
  24. // Eg: Pending invoice cards. Follow input form patter from the commented card in the end of this file
  25. export const ItemCard: React.FC<OwnProps> = (props) => {
  26. const [showDetails, setShowDetails] = useState<boolean>(false);
  27. let statusClass = '';
  28. if (props.rightText && props.rightText.type) {
  29. switch(props.rightText.type) {
  30. case 'success' : statusClass = styles.success; break;
  31. case 'danger' : statusClass = styles.danger; break;
  32. case 'warning' : statusClass = styles.warning; break;
  33. default: statusClass = '';
  34. }
  35. }
  36. return <div>
  37. <section className={styles.card} onClick={() => setShowDetails(true)}>
  38. <figure>
  39. <img src={props.leftImage} />
  40. </figure>
  41. <div className={styles.contentHolder}>
  42. <h6> { props.heading.name }: {props.heading.value} </h6>
  43. <h2> {props.value} </h2>
  44. <p> {props.description} </p>
  45. </div>
  46. { props.rightText && <div className={styles.status}>
  47. <span
  48. className={statusClass}> { props.rightText.name } </span>
  49. </div> }
  50. </section>
  51. { showDetails && props.details && <div className={styles.backdrop} onClick={(e: any) => {
  52. if (e.target.className.toString().includes('backdrop')) {
  53. setShowDetails(false);
  54. }
  55. }}>
  56. <section className={styles.cardDetails}>
  57. <header>
  58. <IonButton onClick={() => setShowDetails(false)} fill={'clear'} size={'small'}> <ChevronBack /> </IonButton>
  59. <h4> Pending Invoice </h4>
  60. </header>
  61. <ul>
  62. { props.details.map((detail, key) => {
  63. return <li key={key}>
  64. <label> { detail.name } </label>
  65. <p> { detail.value } </p>
  66. </li>
  67. }) }
  68. </ul>
  69. { props.form }
  70. </section>
  71. </div> }
  72. </div>
  73. }
  74. {/* <section className={styles.form}>
  75. <div className={styles.inputHolder}>
  76. <label> Payment Date </label>
  77. <IonDatetime mode={'ios'} placeholder={'DD/MM/YYYY'} displayFormat={'DD/MM/YYYY'}></IonDatetime>
  78. </div>
  79. <div className={styles.inputHolder}>
  80. <label> Reference No. </label>
  81. <IonInput placeholder={'Enter here'}></IonInput>
  82. </div>
  83. <div className={styles.buttonsHolder}>
  84. <IonButton fill={'outline'} className={styles.cancel} shape={'round'}> Cancel Invoice </IonButton>
  85. <IonButton fill={'solid'} className={styles.approve} shape={'round'}
  86. onClick={() => setShowDetails(false)}> Paid </IonButton>
  87. </div>
  88. </section> */}