-
-
-
Global settings
-
-
-
-
-
-
-
+
+
-
Data elements
+ Global settings
+
+
+
+
+
+
+
+
+
Data elements
+
+
+
+
-
Table data
-
+
How to
diff --git a/apps/modernization-ui/src/apps/dedup-config/DataElementsConfiguration/DataElementsTable.tsx b/apps/modernization-ui/src/apps/dedup-config/DataElementsConfiguration/DataElementsTable.tsx
new file mode 100644
index 0000000000..5135961e00
--- /dev/null
+++ b/apps/modernization-ui/src/apps/dedup-config/DataElementsConfiguration/DataElementsTable.tsx
@@ -0,0 +1,158 @@
+import React, { useEffect, useState } from 'react';
+import { useFormContext, Controller, useWatch } from 'react-hook-form';
+import { DataElement } from '../const/init';
+import { DataTable, Column } from 'design-system/table';
+import { Checkbox } from '@trussworks/react-uswds';
+import { Input } from 'components/FormInputs/Input';
+import { useDataElementsContext } from '../context/DataElementsContext';
+
+const columns = (
+ control: any,
+ handleRowCheckboxChange: (index: number, checked: boolean) => void,
+ checkedState: boolean[],
+ watchedDataElements: DataElement[]
+): Column[] => [
+ {
+ id: 'active',
+ name: 'Active',
+ render: (dataElement, index) => (
+ (
+ {
+ handleRowCheckboxChange(index, e.target.checked);
+ onChange(e.target.checked);
+ }}
+ />
+ )}
+ />
+ )
+ },
+ {
+ id: 'name',
+ name: 'Name',
+ render: (dataElement) => dataElement.name
+ },
+ {
+ id: 'm',
+ name: 'M',
+ render: (dataElement, index) => (
+ (
+
+ )}
+ />
+ )
+ },
+ {
+ id: 'u',
+ name: 'U',
+ render: (dataElement, index) => (
+ (
+
+ )}
+ />
+ )
+ },
+ {
+ id: 'oddsRatio',
+ name: 'Odds ratio',
+ render: (dataElement, index) => {
+ const m = watchedDataElements[index]?.m;
+ const u = watchedDataElements[index]?.u;
+ const oddsRatio = m && u && u !== 0 ? (m / u).toFixed(2) : 'No Data';
+ return oddsRatio;
+ }
+ },
+ {
+ id: 'logOdds',
+ name: 'Log odds',
+ render: (dataElement, index) => {
+ const m = watchedDataElements[index]?.m;
+ const u = watchedDataElements[index]?.u;
+ const logOdds = m && u && u !== 0 && m !== 0 ? Math.log(m / u).toFixed(2) : 'No Data';
+ return logOdds;
+ }
+ },
+ {
+ id: 'threshold',
+ name: 'Threshold',
+ render: (dataElement, index) => (
+ (
+
+ )}
+ />
+ )
+ }
+];
+
+const DataElementsTable = () => {
+ const { control, setValue } = useFormContext<{ dataElements: DataElement[] }>();
+ const { dataElements } = useDataElementsContext();
+ const [checkedState, setCheckedState] = useState([]);
+
+ const watchedDataElements = useWatch({
+ control,
+ name: 'dataElements',
+ defaultValue: dataElements
+ });
+
+ useEffect(() => {
+ setValue('dataElements', dataElements);
+ setCheckedState(dataElements.map((de) => de.active));
+ }, [dataElements, setValue]);
+
+ const handleRowCheckboxChange = (index: number, checked: boolean) => {
+ const updatedCheckedState = [...checkedState];
+ updatedCheckedState[index] = checked;
+ setCheckedState(updatedCheckedState);
+ };
+
+ return (
+
+ id="dataElementsTable"
+ columns={columns(control, handleRowCheckboxChange, checkedState, watchedDataElements)}
+ data={dataElements}
+ />
+ );
+};
+
+export { DataElementsTable };
diff --git a/apps/modernization-ui/src/apps/dedup-config/DataElementsConfiguration/data-elements-table.module.scss b/apps/modernization-ui/src/apps/dedup-config/DataElementsConfiguration/data-elements-table.module.scss
new file mode 100644
index 0000000000..560f9ade10
--- /dev/null
+++ b/apps/modernization-ui/src/apps/dedup-config/DataElementsConfiguration/data-elements-table.module.scss
@@ -0,0 +1,29 @@
+@use 'styles/colors';
+
+.table {
+ width: 100%;
+ tbody tr:nth-child(odd) {
+ background-color: colors.$base-lightest;
+ }
+ th {
+ label::before {
+ margin-top: -0.5rem;
+ content: '';
+ display: inline-block;
+ width: 1rem;
+ height: 1rem;
+ margin-right: 0.5rem;
+ }
+ }
+ td {
+ height: 3rem;
+ label::before {
+ margin-top: -0.75rem;
+ content: '';
+ display: inline-block;
+ width: 1rem;
+ height: 1rem;
+ margin-right: 0.5rem;
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/modernization-ui/src/apps/dedup-config/const/init.ts b/apps/modernization-ui/src/apps/dedup-config/const/init.ts
index d16cb88f95..202ed63b7d 100644
--- a/apps/modernization-ui/src/apps/dedup-config/const/init.ts
+++ b/apps/modernization-ui/src/apps/dedup-config/const/init.ts
@@ -1,19 +1,87 @@
-export const DataElements = {
- "lastName": "",
- "secondLastName": "",
- "firstName": "",
- "middleName": "",
- "secondMiddleName": "",
- "suffix": "",
- "currentSex": "",
- "dateOfBirth": "",
- "ssn": "",
- "idType": "",
- "idAssigningAuthority": "",
- "idValue": "",
- "streetAddress1": "",
- "city": "",
- "state": "",
- "zipCode": "",
- "telephone": ""
- };
\ No newline at end of file
+export type DataElement = {
+ name: string;
+ active: boolean;
+ m: number;
+ u: number;
+ threshold: number;
+};
+
+export const DataElements: DataElement[] = [
+ { name: "lastName", active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: "secondLastName", active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: "firstName", active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: "middleName", active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: "secondMiddleName", active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: "suffix", active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: "currentSex", active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ {
+ name: "dateOfBirth",
+ active: true,
+ m: 0.5,
+ u: 0.5,
+ threshold: 0.5,
+ },
+ {
+ name: "ssn",
+ active: true,
+ m: 0.5,
+ u: 0.5,
+ threshold: 0.5,
+ },
+ {
+ name: "idType",
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5,
+ },
+ {
+ name: "idAssigningAuthority",
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5,
+ },
+ {
+ name: "idValue",
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5,
+ },
+ {
+ name: "streetAddress1",
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5,
+ },
+ {
+ name: "city",
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5,
+ },
+ {
+ name: "state",
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5,
+ },
+ {
+ name: "zip",
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5,
+ },
+ {
+ name: "telephone",
+ active: true,
+ m: 0.5,
+ u: 0.1,
+ threshold: 0.5,
+ }
+];
diff --git a/apps/modernization-ui/src/apps/dedup-config/context/DataElementsContext.tsx b/apps/modernization-ui/src/apps/dedup-config/context/DataElementsContext.tsx
index 347cccf87d..c8635d679b 100644
--- a/apps/modernization-ui/src/apps/dedup-config/context/DataElementsContext.tsx
+++ b/apps/modernization-ui/src/apps/dedup-config/context/DataElementsContext.tsx
@@ -3,30 +3,98 @@ import React, { createContext, useContext, useState } from 'react';
const DataElementsContext = createContext(undefined);
type DataElementsContextProps = {
- dataElements: typeof DataElements | null;
- setDataElements: (dataElements: typeof DataElements) => void;
+ dataElements: DataElement[];
+ setDataElements: (dataElements: DataElement[]) => void;
};
-const DataElements = {
- lastName: '',
- secondLastName: '',
- firstName: '',
- middleName: '',
- secondMiddleName: '',
- suffix: '',
- currentSex: '',
- dateOfBirth: '',
- ssn: '',
- idType: '',
- idAssigningAuthority: '',
- idValue: '',
- streetAddress1: '',
- city: '',
- state: '',
- zipCode: '',
- telephone: ''
+export type DataElement = {
+ name: string;
+ active: boolean;
+ m: number;
+ u: number;
+ threshold: number;
};
+export const DataElements: DataElement[] = [
+ { name: 'lastName', active: false, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: 'secondLastName', active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: 'firstName', active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: 'middleName', active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: 'secondMiddleName', active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: 'suffix', active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ { name: 'currentSex', active: true, m: 0.5, u: 0.5, threshold: 0.5 },
+ {
+ name: 'dateOfBirth',
+ active: true,
+ m: 0.5,
+ u: 0.5,
+ threshold: 0.5
+ },
+ {
+ name: 'ssn',
+ active: true,
+ m: 0.5,
+ u: 0.5,
+ threshold: 0.5
+ },
+ {
+ name: 'idType',
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5
+ },
+ {
+ name: 'idAssigningAuthority',
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5
+ },
+ {
+ name: 'idValue',
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5
+ },
+ {
+ name: 'streetAddress1',
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5
+ },
+ {
+ name: 'city',
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5
+ },
+ {
+ name: 'state',
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5
+ },
+ {
+ name: 'zip',
+ active: true,
+ m: 0.5,
+ u: 0.25,
+ threshold: 0.5
+ },
+ {
+ name: 'telephone',
+ active: true,
+ m: 0.5,
+ u: 0.1,
+ threshold: 0.5
+ }
+];
+
const DataElementsContextProvider: React.FC<{
children: React.ReactNode;
}> = ({ children }) => {
diff --git a/apps/modernization-ui/src/design-system/checkbox/Checkbox.tsx b/apps/modernization-ui/src/design-system/checkbox/Checkbox.tsx
index 6e6278b801..9b0229b0be 100644
--- a/apps/modernization-ui/src/design-system/checkbox/Checkbox.tsx
+++ b/apps/modernization-ui/src/design-system/checkbox/Checkbox.tsx
@@ -2,7 +2,7 @@ import classNames from 'classnames';
import styles from './checkbox.module.scss';
type Props = Omit & {
- label: string;
+ label?: string;
selected?: boolean;
onChange?: (checked: boolean) => void;
};