Passed
Push — feature/experience-form-modals ( 7402c2...37703b )
by Tristan
03:49
created

resources/assets/js/components/Application/ExperienceModals/EducationSubform.tsx   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 103
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 83
mnd 0
bc 0
fnc 1
dl 0
loc 103
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
B EducationSubform.tsx ➔ EducationSubform 0 66 1
1
import React from "react";
2
import { FormattedMessage, useIntl, defineMessages } from "react-intl";
3
import { Field, FastField } from "formik";
4
import * as Yup from "yup";
5
import CheckboxInput from "../../Form/CheckboxInput";
6
7
export interface EducationFormValues {
8
  useAsEducationRequirement: boolean;
9
}
10
11
export const validationShape = {
12
  useAsEducationRequirement: Yup.boolean(),
13
};
14
15
export interface EducationSubformProps {
16
  educationRequirement: {
17
    title: string;
18
    description: string;
19
  };
20
  equivalentRequirment: {
21
    title: string;
22
    description: string;
23
  };
24
}
25
26
const messages = defineMessages({
27
  educationJustificationLabel: {
28
    id: "experienceModal.educationSubform.educationJustificationLabel",
29
    defaultMessage:
30
      "Yes, this experience helps me meet the education requirements outlined below.",
31
    description:
32
      "Label for the checkbox that checks whether to use this experience to as education justification.",
33
  },
34
});
35
36
export function EducationSubform({
37
  educationRequirement,
38
  equivalentRequirment,
39
}: EducationSubformProps): React.ReactElement {
40
  const intl = useIntl();
41
42
  const checkboxKey = "useAsEducationRequirement";
43
  return (
44
    <>
45
      <div data-c-container="medium">
46
        <p
47
          data-c-margin="top(1) bottom(1)"
48
          data-c-font-size="h4"
49
          data-c-font-weight="bold"
50
          data-c-color="c3"
51
        >
52
          <FormattedMessage
53
            id="experienceModal.educationSubtitle"
54
            defaultMessage="Use This Experience as an Education Requirement"
55
            description="Subtitle for the use-as-Education-Requirement section."
56
          />
57
        </p>
58
        <p data-c-margin="bottom(1)">
59
          <FormattedMessage
60
            id="experienceModal.educationDescription"
61
            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."
62
            description="Explanation for the use-as-Education-Requirement section."
63
          />
64
        </p>
65
      </div>
66
      <div data-c-padding="bottom(1)">
67
        <div data-c-container="medium">
68
          <div data-c-grid="gutter(all, 1) middle">
69
            <div data-c-input="checkbox(group)" data-c-grid-item="base(1of1)">
70
              <FastField
71
                key={checkboxKey}
72
                id={checkboxKey}
73
                name={checkboxKey}
74
                label={intl.formatMessage(messages.educationJustificationLabel)}
75
                component={CheckboxInput}
76
                grid="base(1of2"
77
              />
78
            </div>
79
          </div>
80
          <div
81
            data-c-background="gray(20)"
82
            data-c-radius="rounded"
83
            data-c-padding="all(1)"
84
            data-c-margin="bottom(1)"
85
          >
86
            <p data-c-font-weight="bold">{educationRequirement.title}</p>
87
            <p>{educationRequirement.description}</p>
88
            <p data-c-margin="tb(1)">
89
              <FormattedMessage
90
                id="experienceModal.educationSubform.or"
91
                defaultMessage="OR"
92
                description="Conjunction used to join alternative experience requirements (ie Experience OR Equivalent Experience)."
93
              />
94
            </p>
95
            <p data-c-font-weight="bold">{equivalentRequirment.title}</p>
96
            <p>{equivalentRequirment.description}</p>
97
          </div>
98
        </div>
99
      </div>
100
    </>
101
  );
102
}
103