diff --git a/src/components/invoice-card/invoice.tsx b/src/components/invoice-card/invoice.tsx deleted file mode 100644 index 9d7e86a..0000000 --- a/src/components/invoice-card/invoice.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import React, { useState } from 'react'; -import styles from './invoice.module.scss'; -import { ReactComponent as ChevronBack } from 'ionicons/dist/svg/chevron-back.svg'; -import { format } from 'date-fns'; -import { IonButton, IonDatetime, IonInput } from '@ionic/react'; - -type OwnProps = { - invoice: { - id: string, - date: string, - status: string, - dateOfPayment?: string, - referenceNumber?: string, - }, - client: { - name: string, - logo: string, - project: { - name: string, - contract: { - name: string, - amount: string, - }, - } - } -} - -export const InvoiceCard: React.FC = (props) => { - const [showDetails, setShowDetails] = useState(false); - const [formInputs, setFormInputs] = useState<{ - dateOfPayment: string, - referenceNumber: string, - }>({ - dateOfPayment: props.invoice.dateOfPayment ? props.invoice.dateOfPayment.toString() : '', - referenceNumber: props.invoice.referenceNumber ? props.invoice.referenceNumber : '', - }); - - let statusClass = ''; - - switch (props.invoice.status) { - case 'due': statusClass = styles.due; break; - case 'over due': statusClass = styles.overDue; break; - case 'paid': statusClass = styles.paid; break; - case 'cancelled': statusClass = styles.cancelled; break; - default: break; - } - - return
-
setShowDetails(true)}> -
- logo -
-
-
Invoice ID: {props.invoice.id}
-

{props.client.project.contract.amount}

-

{props.client.project.contract.name}

-
-
- {props.invoice.status} -
-
- - { showDetails &&
-
-
- setShowDetails(false)} fill={'clear'} size={'small'}> -

Pending Invoice

-
-
    -
  • - -

    {props.invoice.id}

    -
  • - -
  • - -

    {format(new Date(props.invoice.date), 'dd MMMM yyyy')}

    -
  • - -
  • - -

    {props.client.name}

    -
  • - -
  • - -

    {props.client.project.name}

    -
  • - -
  • - -

    {props.client.project.contract.name}

    -
  • - -
  • - -

    {props.client.project.contract.amount}

    -
  • -
- -
-
- - setFormInputs({ - dateOfPayment: e.detail.value? e.detail.value.toString() : '', - referenceNumber: formInputs.referenceNumber, - })}> -
- -
- - setFormInputs({ - dateOfPayment: formInputs.dateOfPayment, - referenceNumber: e.detail.value? e.detail.value.toString() : '', - })}> -
- - {(props.invoice.status !== 'cancelled' && props.invoice.status !== 'paid' || formInputs.dateOfPayment !== props.invoice.dateOfPayment || formInputs.dateOfPayment !== props.invoice.date) &&
- Cancel Invoice - setShowDetails(false)}> Paid -
} -
-
-
} - -
-} \ No newline at end of file diff --git a/src/components/invoice-card/invoice.module.scss b/src/components/item-card/itemCard.module.scss similarity index 96% rename from src/components/invoice-card/invoice.module.scss rename to src/components/item-card/itemCard.module.scss index 993a171..51a8a13 100644 --- a/src/components/invoice-card/invoice.module.scss +++ b/src/components/item-card/itemCard.module.scss @@ -63,9 +63,10 @@ height: 7px; border-radius: 50%; background-color: var(--grey); + margin-right: 5px; } - &.due { + &.warning { color: var(--warning); &::before { @@ -73,7 +74,7 @@ } } - &.overDue { + &.danger { color: var(--red); &::before { @@ -81,7 +82,7 @@ } } - &.paid { + &.success { color: var(--teal); &::before { diff --git a/src/components/item-card/itemCard.tsx b/src/components/item-card/itemCard.tsx new file mode 100644 index 0000000..750f99c --- /dev/null +++ b/src/components/item-card/itemCard.tsx @@ -0,0 +1,102 @@ +import React, { useState } from 'react'; +import styles from './itemCard.module.scss'; +import { ReactComponent as ChevronBack } from 'ionicons/dist/svg/chevron-back.svg'; +import { IonButton } from '@ionic/react'; + +type OwnProps = { + leftImage?: string, + heading: { + name: string, + value: string + }, + value: string, + description?: string, + rightText?: { + name: string, + type: 'success' | 'danger' | 'warning' | undefined + }, + details?: Array<{ + name: string, + value: string + }>, + form?: JSX.Element +} + +// Card - Image on the left, heading-value-description in the middle and status or any text on the right. eg: Pending invoice cards + +export const ItemCard: React.FC = (props) => { + const [showDetails, setShowDetails] = useState(false); + + let statusClass = ''; + + if (props.rightText && props.rightText.type) { + switch(props.rightText.type) { + case 'success' : statusClass = styles.success; break; + case 'danger' : statusClass = styles.danger; break; + case 'warning' : statusClass = styles.warning; break; + default: statusClass = ''; + } + } + + return
+
setShowDetails(true)}> +
+ +
+
+
{ props.heading.name }: {props.heading.value}
+

{props.value}

+

{props.description}

+
+ + { props.rightText &&
+ { props.rightText.name } +
} +
+ + { showDetails && props.details &&
{ + if (e.target.className.toString().includes('backdrop')) { + setShowDetails(false); + } + }}> +
+
+ setShowDetails(false)} fill={'clear'} size={'small'}> +

Pending Invoice

+
+ +
    + { props.details.map((detail, key) => { + return
  • + +

    { detail.value }

    +
  • + }) } +
+ + { props.form } +
+
} + +
+} + + +{/*
+
+ + +
+ +
+ + +
+ +
+ Cancel Invoice + setShowDetails(false)}> Paid +
+
*/} \ No newline at end of file diff --git a/src/components/transaction-card/transaction.module.scss b/src/components/transaction-card/transaction.module.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/transaction-card/transaction.tsx b/src/components/transaction-card/transaction.tsx deleted file mode 100644 index 8941254..0000000 --- a/src/components/transaction-card/transaction.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import styles from './invoice.module.scss'; -import { format } from 'date-fns'; - - -export const TransactionCard: React.FC = () => { - return
- -
-} \ No newline at end of file diff --git a/src/pages/accounts/accounts.tsx b/src/pages/accounts/accounts.tsx index b8ce317..e92a868 100644 --- a/src/pages/accounts/accounts.tsx +++ b/src/pages/accounts/accounts.tsx @@ -2,7 +2,8 @@ import { IonContent, IonPage } from '@ionic/react'; import { ReactComponent as CogIcon } from 'ionicons/dist/svg/cog-outline.svg'; import { ReactComponent as LineChartIcon } from 'ionicons/dist/svg/stats-chart.svg'; import styles from './accounts.module.scss'; -import { InvoiceCard } from '../../components/invoice-card/invoice'; +import { ItemCard } from '../../components/item-card/itemCard'; +import { format } from 'date-fns'; const sampleInvoiceData = [{ invoice: { @@ -102,46 +103,39 @@ const Accounts: React.FC = () => { {sampleInvoiceData.map((invoice, key) => { - return - })} - - -
-
-
Pending Invoices
- See All -
- - {sampleInvoiceData.map((invoice, key) => { - return - })} -
- -
-
-
Pending Invoices
- See All -
- - {sampleInvoiceData.map((invoice, key) => { - return - })} -
- -
-
-
Pending Invoices
- See All -
- - {sampleInvoiceData.map((invoice, key) => { - return + return })}
- - );