Passed
Push — feature/experience-step-functi... ( 5abe99...215b5c )
by Tristan
08:04 queued 03:37
created

EducationSubform.tsx ➔ EducationSubform   B

Complexity

Conditions 1

Size

Total Lines 62
Code Lines 54

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 54
dl 0
loc 62
rs 8.5054
c 0
b 0
f 0
cc 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
import React from "react";
2
import { FormattedMessage, useIntl, defineMessages } from "react-intl";
3
import { FastField } from "formik";
4
import * as Yup from "yup";
5
import CheckboxInput from "../../Form/CheckboxInput";
6
import textToParagraphs from "../../../helpers/textToParagraphs";
7
import { educationMessages } from "../../JobBuilder/Details/JobDetailsMessages";
8
9
export interface EducationFormValues {
10
  useAsEducationRequirement: boolean;
11
}
12
13
export const validationShape = {
14
  useAsEducationRequirement: Yup.boolean(),
15
};
16
17
export interface EducationSubformProps {
18
  jobClassification: string;
19
}
20
21
const messages = defineMessages({
22
  educationJustificationLabel: {
23
    id:
24
      "application.experienceModal.educationSubform.educationJustificationLabel",
25
    defaultMessage:
26
      "Yes, this experience helps me meet the education requirements outlined below.",
27
    description:
28
      "Label for the checkbox that checks whether to use this experience to as education justification.",
29
  },
30
});
31
32
export function EducationSubform({
33
  jobClassification,
34
}: EducationSubformProps): React.ReactElement {
35
  const intl = useIntl();
36
37
  const checkboxKey = "useAsEducationRequirement";
38
  return (
39
    <>
40
      <div data-c-container="medium">
41
        <p
42
          data-c-margin="top(1) bottom(1)"
43
          data-c-font-size="h4"
44
          data-c-font-weight="bold"
45
          data-c-color="c3"
46
        >
47
          <FormattedMessage
48
            id="application.experienceModal.educationSubtitle"
49
            defaultMessage="Use This Experience as an Education Requirement"
50
            description="Subtitle for the use-as-Education-Requirement section."
51
          />
52
        </p>
53
        <p data-c-margin="bottom(1)">
54
          <FormattedMessage
55
            id="application.experienceModal.educationDescription"
56
            defaultMessage="You can select the option below if you feel that this experience helps you meet some or all of the specific education requirements for this job. We've included the requirements below to help refresh your memory."
57
            description="Explanation for the use-as-Education-Requirement section."
58
          />
59
        </p>
60
      </div>
61
      <div data-c-padding="bottom(1)">
62
        <div data-c-container="medium">
63
          <div data-c-grid="gutter(all, 1) middle">
64
            <div data-c-grid-item="base(1of1)">
65
              <FastField
66
                key={checkboxKey}
67
                id={checkboxKey}
68
                name={checkboxKey}
69
                label={intl.formatMessage(messages.educationJustificationLabel)}
70
                component={CheckboxInput}
71
                checkboxBorder
72
              />
73
            </div>
74
          </div>
75
          <div
76
            data-c-background="gray(20)"
77
            data-c-radius="rounded"
78
            data-c-padding="all(1)"
79
            data-c-margin="bottom(1)"
80
          >
81
            {textToParagraphs(
82
              intl.formatMessage(educationMessages[jobClassification]),
83
              {},
84
              {
85
                0: { "data-c-font-weight": "bold" },
86
                5: { "data-c-font-weight": "bold" },
87
              },
88
            )}
89
          </div>
90
        </div>
91
      </div>
92
    </>
93
  );
94
}
95