diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx
index c2eb2294354..cef01edaf16 100644
--- a/src/Components/Facility/ConsultationForm.tsx
+++ b/src/Components/Facility/ConsultationForm.tsx
@@ -49,7 +49,6 @@ import { DraftSection, useAutoSaveReducer } from "../../Utils/AutoSave";
import { FormAction } from "../Form/Utils";
import UserAutocompleteFormField from "../Common/UserAutocompleteFormField";
-
const Loading = loadable(() => import("../Common/Loading"));
const PageTitle = loadable(() => import("../Common/PageTitle"));
diff --git a/src/Components/Patient/PatientNotes.tsx b/src/Components/Patient/PatientNotes.tsx
index 0756883d1d2..d97a7502542 100644
--- a/src/Components/Patient/PatientNotes.tsx
+++ b/src/Components/Patient/PatientNotes.tsx
@@ -5,6 +5,7 @@ import {
getPatientNotes,
addPatientNote,
getPatient,
+ updatePatientNote,
} from "../../Redux/actions";
import * as Notification from "../../Utils/Notifications.js";
import PageTitle from "../Common/PageTitle";
@@ -13,7 +14,9 @@ import { navigate } from "raviger";
import { RESULTS_PER_PAGE_LIMIT } from "../../Common/constants";
import Loading from "../Common/Loading";
import { formatDate } from "../../Utils/utils";
+import CareIcon from "../../CAREUI/icons/CareIcon";
import ButtonV2 from "../Common/components/ButtonV2";
+import moment from "moment";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
interface PatientNotesProps {
@@ -34,6 +37,11 @@ const PatientNotes = (props: PatientNotesProps) => {
const [facilityName, setFacilityName] = useState("");
const [patientName, setPatientName] = useState("");
const [patientActive, setPatientActive] = useState(true);
+ const [editMode, setEditMode] = useState({
+ edit: false,
+ id: "",
+ text: "",
+ });
const fetchData = useCallback(
async (page = 1, status: statusType = { aborted: false }) => {
@@ -84,16 +92,21 @@ const PatientNotes = (props: PatientNotesProps) => {
fetchData(page);
}
- const onAddNote = () => {
- const payload = {
- note: noteField,
- };
- if (!/\S+/.test(noteField)) {
+ const validate = (note: string) => {
+ if (!/\S+/.test(note)) {
Notification.Error({
msg: "Note Should Contain At Least 1 Character",
});
- return;
+ return false;
}
+ return true;
+ };
+
+ const onAddNote = () => {
+ const payload = {
+ note: noteField,
+ };
+ if (!validate(noteField)) return;
dispatch(addPatientNote(props.patientId, payload)).then(() => {
Notification.Success({ msg: "Note added successfully" });
setNoteField("");
@@ -101,6 +114,22 @@ const PatientNotes = (props: PatientNotesProps) => {
});
};
+ const updateNote = (id: string, note: string) => {
+ const payload = {
+ note,
+ };
+ if (!validate(note)) return false;
+ dispatch(updatePatientNote(props.patientId, id, payload)).then(
+ (res: any) => {
+ if (res && res.status === 200) {
+ Notification.Success({ msg: "Note updated successfully" });
+ fetchData();
+ }
+ }
+ );
+ return true;
+ };
+
if (isLoading) {
return