diff --git a/src/Payments.Mvc/ClientApp/src/components/payInvoiceAction.tsx b/src/Payments.Mvc/ClientApp/src/components/payInvoiceAction.tsx new file mode 100644 index 00000000..f2faed16 --- /dev/null +++ b/src/Payments.Mvc/ClientApp/src/components/payInvoiceAction.tsx @@ -0,0 +1,107 @@ +import * as React from 'react'; +import { formatCurrencyLocale } from '../utils/currency'; + +interface IProps { + dueDate: string | null; + errorMessage: string; + isSaving: boolean; + isValid: boolean; + isValidating: boolean; + onSubmit: () => void; + total: number; +} + +export default class PayInvoiceAction extends React.Component { + public render() { + const { + dueDate, + errorMessage, + isSaving, + isValid, + isValidating, + onSubmit, + total + } = this.props; + + return ( +
+ {formatCurrencyLocale(total)} + + {dueDate && ( + + Due{' '} + {new Date(dueDate).toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric' + })} + + )} + + {errorMessage && ( +
+ {errorMessage} +
+ )} + + {isValidating && ( +
+ + Validating form... +
+ )} + + {!isValidating && !isValid && !isSaving && ( +
+ + Please complete all required fields before submitting: +
    +
  • At least one valid debit chart string is required
  • +
  • All chart strings must be validated successfully
  • +
  • + Total debit amounts must equal the invoice total ( + {formatCurrencyLocale(total)}) +
  • +
  • All amounts must be greater than zero
  • +
+
+ )} + + {!isValidating && isValid && !isSaving && ( +
+ + Form is valid and ready to submit +
+ )} + +
+