diff --git a/src/constants.ts b/src/constants.ts index 27039cc..e4ec974 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -117,3 +117,78 @@ export const incomingTransactionsHeaders = [ accessor: "actions", }, ]; + +export const syncTaskTypeDataTypes = [ + { + id: "dataType1", + label: "java.lang.Boolean", + }, + { + id: "dataType1", + label: "java.lang.Character", + }, + { + id: "dataType1", + label: "java.lang.Float", + }, + { + id: "dataType1", + label: "java.lang.Integer", + }, + { + id: "dataType1", + label: "java.lang.String", + }, + { + id: "dataType1", + label: "java.lang.Boolean", + }, + { + id: "dataType1", + label: "org.openmrs.Concept", + }, + { + id: "dataType1", + label: "org.openmrs.Drug", + }, + { + id: "dataType1", + label: "org.openmrs.Encounter", + }, + { + id: "dataType1", + label: "org.openmrs.Order", + }, + { + id: "dataType1", + label: "org.openmrs.TestOrder", + }, + { + id: "dataType1", + label: "org.openmrs.Location", + }, + { + id: "dataType1", + label: "org.openmrs.Patient", + }, + { + id: "dataType1", + label: "org.openmrs.Person", + }, + { + id: "dataType1", + label: "org.openmrs.ProgramWorkflow", + }, + { + id: "dataType1", + label: "org.openmrs.Provider", + }, + { + id: "dataType1", + label: "org.openmrs.User", + }, + { + id: "dataType1", + label: "org.openmrs.util.AttributableDate", + }, +]; diff --git a/src/fhir/sync-task-types/sync-task-type/sync-task-type.component.tsx b/src/fhir/sync-task-types/sync-task-type/sync-task-type.component.tsx new file mode 100644 index 0000000..e8a28b0 --- /dev/null +++ b/src/fhir/sync-task-types/sync-task-type/sync-task-type.component.tsx @@ -0,0 +1,170 @@ +import React, { useState } from "react"; +import { + Button, + Dropdown, + Form, + FormGroup, + Stack, + TextInput, +} from "@carbon/react"; +import { Edit, Save } from "@carbon/react/icons"; +import { useTranslation } from "react-i18next"; +import { syncTaskTypeDataTypes } from "../../../constants"; +import styles from "./sync-task-type.scss"; + +export const SyncTaskTypeRow = ({ rowData }) => { + const { t } = useTranslation(); + + const [isEditMode, setIsEditMode] = useState(false); + + const dataTypesList = syncTaskTypeDataTypes.map((type) => ({ + id: type.id, + label: type.label, + })); + + const normalizeString = (str) => str?.toLowerCase().replace(/\s+/g, ""); + + const findItemByLabel = (apiValue, items) => { + const normalizedApiValue = normalizeString(apiValue); + return items?.find( + (item) => normalizeString(item.label) === normalizedApiValue + ); + }; + + const [selectedDataTypeType, setSelectedDataTypeType] = useState(() => + findItemByLabel(rowData?.dataType, dataTypesList) + ); + + const handleEdit = () => { + setIsEditMode(true); + }; + + const handleSubmit = () => { + setIsEditMode(false); + }; + + const handleCancel = () => { + setIsEditMode(false); + }; + + return ( + <> +
+
+
+ + + + + + + + + + + + + + +
+
+
+
+ + + (item ? item.label : "")} + items={dataTypesList} + label="Select Data Type" + selectedItem={selectedDataTypeType} + onChange={(event) => + setSelectedDataTypeType(event.selectedItem) + } + disabled={!isEditMode} + /> + + + + + + + + +
+
+
+
+ {!isEditMode && ( + + )} + {isEditMode && ( + <> + + + + )} +
+ + ); +}; + +export default SyncTaskTypeRow; diff --git a/src/fhir/sync-task-types/sync-task-type/sync-task-type.scss b/src/fhir/sync-task-types/sync-task-type/sync-task-type.scss new file mode 100644 index 0000000..5e1221b --- /dev/null +++ b/src/fhir/sync-task-types/sync-task-type/sync-task-type.scss @@ -0,0 +1,30 @@ +@use '@carbon/styles/scss/colors'; +@use '@carbon/styles/scss/type'; +@use '@carbon/styles/scss/spacing'; +.formContainer { + width: 100%; + display: flex; +} + +.form { + width: 50%; +} + +.formFirst { + margin-right: 2rem; +} + +.formRight { + margin-top: 0.3rem; +} + +.editButtonsContainer { + display: flex; + margin-top: 1rem; + justify-content: flex-end; + .actionButton { + svg { + margin-right: 0.5rem; + } + } +} \ No newline at end of file diff --git a/src/fhir/sync-task-types/sync-task-types-list.component.tsx b/src/fhir/sync-task-types/sync-task-types-list.component.tsx index a1088da..e6418c9 100644 --- a/src/fhir/sync-task-types/sync-task-types-list.component.tsx +++ b/src/fhir/sync-task-types/sync-task-types-list.component.tsx @@ -24,7 +24,7 @@ import { import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import styles from "../../components/data-table/data-tables.scss"; -// import RowDetails from "./fhir-detail.component"; +import SyncTaskTypeRow from "./sync-task-type/sync-task-type.component"; type FilterProps = { rowIds: Array; @@ -151,7 +151,7 @@ const SyncTaskTypeList: React.FC = ({ columns, data }) => { className={styles.expandedActiveVisitRow} colSpan={headers.length + 1} > - {/* */} + ) : (