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 ( + <> +