Skip to content

Commit

Permalink
adopt carbon notification
Browse files Browse the repository at this point in the history
  • Loading branch information
jona42-ui committed Sep 26, 2023
1 parent 5896305 commit 5f6e20e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
39 changes: 28 additions & 11 deletions src/components/custom-annotate.component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useRef, useState } from "react";
import { fabric } from "fabric";
import "./custom-annotate.style.css"; // Import your CSS file for styling

import "./custom-annotate.scss"; // Import your CSS file for styling
import { showToast } from "@openmrs/esm-framework";
import { Button } from "@carbon/react";
import { createAttachment } from "../attachments/attachments.resource";
import { readFileAsString } from "../utils";
Expand Down Expand Up @@ -187,6 +187,7 @@ const SvgEditor = () => {
};

const saveAnnotatedImage = async () => {
// TODO: make this dynamic not hard coded
const patientUuid = "ac64588b-9376-4ef4-b87f-13782647b4c8";
// Check if an image object exists
if (imageObject) {
Expand Down Expand Up @@ -218,16 +219,32 @@ const SvgEditor = () => {
const base64Content = await readFileAsString(file);

// Use createAttachment method to save the annotated image
await createAttachment(patientUuid, {
file,
fileName,
fileType,
fileDescription,
base64Content,
});
try {
await createAttachment(patientUuid, {
file,
fileName,
fileType,
fileDescription,
base64Content,
});

// Show success toast on successful image save
showToast({
description: "Annotated image saved successfully!",
title: "Image Saved",
kind: "success",
critical: true,
});
} catch (error) {
// Show error toast on error
showToast({
description: "Error saving annotated image",
title: "Error",
kind: "error",
critical: true,
});
}
}
// TODO: Use the openmrs framework notification
alert("Annotated image saved successfully!");
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/draw-page.component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useRef } from "react";
import SvgEditor from "./components/custom-annotate.component"; // Update the import path
import "./draw-page.style.css"; // Import the CSS file
import "./draw-page.scss"; // Import the CSS file

const DrawPage: React.FC = () => {
const drawingWidgetRef = useRef<HTMLDivElement>(null);
Expand Down

0 comments on commit 5f6e20e

Please sign in to comment.