diff --git a/src/shared/components/Form/Form.tsx b/src/shared/components/Form/Form.tsx index 74e1f76..a099a33 100644 --- a/src/shared/components/Form/Form.tsx +++ b/src/shared/components/Form/Form.tsx @@ -1,7 +1,7 @@ -import React, { memo, ReactNode, useCallback, useRef, useState } from "react"; +import React, { memo, ReactNode, useCallback, useRef, useState } from 'react'; -import { areEqualShallow } from "Utils/equalityChecks"; -import { useDebounce } from "Hooks/useDebounce"; +import { areEqualShallow } from 'Utils/equalityChecks'; +import { useDebounce } from 'Hooks/useDebounce'; interface Props { id?: string; @@ -38,16 +38,16 @@ const Form = ({ id, className, noValidate = true, submitButton, onSubmit, childr const onSubmitLocal = useDebounce((e: any) => { e.preventDefault(); - formRef.current.classList.add("was-validated"); + formRef.current.classList.add('was-validated'); - let value = ""; + let value = ''; switch (e.target.type) { - case "checkbox": + case 'checkbox': value = e.target.checked; break; - case "text": - case "tel": - case "email": + case 'text': + case 'tel': + case 'email': value = e.target.value.trim(); break; default: @@ -57,7 +57,7 @@ const Form = ({ id, className, noValidate = true, submitButton, onSubmit, childr // This will handle an empty input if (value?.length === 0) { validate({ [e.target.name]: e.target.value, isValid: true }); - formRef.current.classList.remove("was-validated"); + formRef.current.classList.remove('was-validated'); return; } @@ -99,7 +99,7 @@ const Form = ({ id, className, noValidate = true, submitButton, onSubmit, childr }} onSubmit={(submitButton && onSubmitLocal) || submitWhenNoSubmitButton} id={id} - className={`requires-validation ${className || ""}`} + className={`requires-validation ${className || ''}`} noValidate={noValidate} > {children} diff --git a/src/shared/components/Forms/ContractFormsModal/ContractFormsModal.tsx b/src/shared/components/Forms/ContractFormsModal/ContractFormsModal.tsx new file mode 100644 index 0000000..0bba33c --- /dev/null +++ b/src/shared/components/Forms/ContractFormsModal/ContractFormsModal.tsx @@ -0,0 +1,144 @@ +import React, { memo, RefObject } from 'react'; +import { Modal } from 'Components/Modal'; +import { areEqual } from 'Utils/equalityChecks'; +import { ValidateBackGround } from 'Components/Validation'; +import { PurpleButton } from 'Components/Button'; +import { Label } from 'Components/Label'; +import { TextBox } from 'Components/TextBox'; +import { CheckBox } from 'Components/CheckBox'; +import { TextArea } from 'Components/TextArea'; +import { ContractFormsSuccessToast } from '../ContractFormsSuccessToast'; + +import classes from './contractFormsModal.module.css'; + +const templateTags = [ + '~~~name~~~', + '~~~project~~~', + '~~~job_no~~~', + '~~~company~~~', + '~~~current_date~~~', + '~~~date_of_loss~~~', + '~~~company_address~~~', + '~~~policy_holder_name~~~', + '~~~policy_number~~~', + '~~~claim_number~~~', + '~~~input~~~', + '~~~checkbox~~~', + '~~~company_logo~~~', +]; + +interface Props { + isOpen: boolean; + formData: any; + formErrors: any; + title: string; + submitText: string; + showToast: boolean; + toastMessage: string; + onFormSubmit: (e: any) => void; + onClickClose: (e: any) => void; + handleChange: (e: any) => void; + textAreaRef: RefObject; + handleTagClick: (tag: string) => void; + submitting: boolean; +} + +const ContractFormsModal = ({ + isOpen, + title, + submitText, + formData, + formErrors, + showToast, + toastMessage, + onFormSubmit, + onClickClose, + handleChange, + textAreaRef, + handleTagClick, + submitting, +}: Props) => ( + } + > +
+ + + +
{formErrors?.name?.[0]}
+
+ +
+ + +
+ +
+ +
+
+ {templateTags.map((tag) => ( + + ))} +
+
+ {formErrors?.template?.[0] &&

{formErrors?.template?.[0]}

} +