• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

baltimorecounty / react-transient-tax / 4329464609

pending completion
4329464609

push

github

GitHub
Bump minimist, mkdirp and loader-fs-cache

61 of 445 branches covered (13.71%)

Branch coverage included in aggregate %.

291 of 802 relevant lines covered (36.28%)

1.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

2.27
/src/components/forms/BasicInformationForm.jsx
1
import * as Yup from "yup";
2

3
import { Form, Formik } from "formik";
4
import React, { useState } from "react";
5
import { IEMessage } from "../../common/Constants";
6
import AddressLookupField from "../../components/formik/AddressLookupField";
7
import BasicErrorMessage from "../BasicErrorMessage";
8
import Field from "../formik/Field";
9
import PromptIfDirty from "../PromptIfDirty";
10
import { VerifyAddress } from "../../services/ApiService";
11

12
const BasicInformationForm = (props) => {
1✔
13
  const { nextButton, prevButton, onValidSubmission, initialValues } = props;
×
14
  const [isValidAddressMessage, setIsValidAddressMessage] = useState("");
×
15

16
  const ValidateAddress = async (addressValue) => {
×
17
    try {
×
18
      const response = await VerifyAddress(addressValue);
×
19
      const { Address: { AddressId = 0 } = {} } = response;
×
20

21
      return AddressId;
×
22
    } catch (ex) {
23
      return null;
×
24
    }
25
  };
26

27
  const handleAddressChange = () => {
×
28
    setIsValidAddressMessage("");
×
29
  };
30
  const ShowIEMessage = () => {
×
31
    var ua = window.navigator.userAgent;
×
32
    var msie = ua.indexOf("MSIE ");
×
33

34
    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv:11\./)) {
×
35
      // If Internet Explorer, return true
36
      //  change it to "true" after testing because i am testing in non IE browser
37
      return true;
×
38
    } // If another browser, return false
39
    else {
40
      //  change it to "false" after testing because i am testing in non IE browser
41
      return false;
×
42
    }
43
  };
44
  const isItIEBrowser = ShowIEMessage();
×
45
  const { IEMessageLabel } = IEMessage;
×
46
  return (
×
47
    <Formik
48
      initialValues={initialValues}
49
      onSubmit={async (values) => {
50
        setIsValidAddressMessage("");
×
51
        const { businessAddress, address } = values;
×
52
        const shouldGeocode = Object.keys(address).length === 0;
×
53
        const addressId = shouldGeocode
×
54
          ? await ValidateAddress(businessAddress)
55
          : address.AddressId;
56
        if (addressId) {
×
57
          onValidSubmission(values);
×
58
        } else {
59
          setIsValidAddressMessage(
×
60
            "Please enter a valid Baltimore County address."
61
          );
62
        }
63
      }}
64
      validationSchema={Yup.object({
65
        businessName: Yup.string().required("Required"),
66
        businessAddress: Yup.string().required(
67
          "A valid Baltimore County address is required"
68
        ),
69
      })}
70
    >
71
      {(props) => (
72
        <Form>
×
73
          <PromptIfDirty />
74
          <div>
75
            {isItIEBrowser && (
×
76
              <div className="dg_alert status warning">
77
                <span className="dg_alert__status">Warning</span>
78
                <p>{IEMessageLabel} </p>
79
              </div>
80
            )}
81

82
            <Field
83
              id="tradeAlias"
84
              name="tradeAlias"
85
              type="text"
86
              label="Trade Alias"
87
              autoFocus
88
            />
89
            <Field
90
              id="tradeAliasAddress"
91
              name="tradeAliasAddress"
92
              type="text"
93
              label="Trade Alias Address"
94
              autoFocus
95
            />
96
            <Field
97
              id="businessName"
98
              name="businessName"
99
              type="text"
100
              label="Business Name"
101
              autoFocus
102
            />
103
            <AddressLookupField
104
              id="businessAddress"
105
              name="businessAddress"
106
              label="Business Address"
107
              minLength={3}
108
              onChange={handleAddressChange}
109
            />
110
            {isValidAddressMessage && (
×
111
              <BasicErrorMessage message={isValidAddressMessage} />
112
            )}
113
            {props.isSubmitting ? <p>Validating address...</p> : null}
×
114
          </div>
115

116
          <div className="tt_form-controls">
117
            {prevButton}
118
            {nextButton}
119
          </div>
120
        </Form>
121
      )}
122
    </Formik>
123
  );
124
};
125

126
export default BasicInformationForm;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc