From 45944530711707ecc828251edd8ec1b599779318 Mon Sep 17 00:00:00 2001 From: rachana-egov <137176770+rachana-egov@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:31:52 +0530 Subject: [PATCH] Added updated api for census and workflow integration (#1598) * added updated api for census and workflow integration * updated approve popup to workflow popup * updated workflow action * resolved coderabbit comments --------- Co-authored-by: rachana-egov Co-authored-by: Nipun Arora --- .../example/public/index.html | 2 +- .../packages/css/package.json | 2 +- .../css/src/pages/employee/index.scss | 2 +- .../css/src/pages/employee/villageView.scss | 16 + .../microplan/src/components/WorkflowPopUp.js | 104 +++ .../components/editVillagePopulationPopUP.js | 56 +- .../microplan/src/components/securityPopUp.js | 8 +- .../src/components/timelinePopUpWrapper.js | 753 +----------------- .../src/pages/employee/viewVillage.js | 15 +- health/micro-ui/web/public/index.html | 2 +- 10 files changed, 203 insertions(+), 757 deletions(-) create mode 100644 health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/WorkflowPopUp.js diff --git a/health/micro-ui/web/micro-ui-internals/example/public/index.html b/health/micro-ui/web/micro-ui-internals/example/public/index.html index 9ed9ac3fe67..53afaafba1c 100644 --- a/health/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/health/micro-ui/web/micro-ui-internals/example/public/index.html @@ -16,7 +16,7 @@ /> --> - + diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/package.json b/health/micro-ui/web/micro-ui-internals/packages/css/package.json index 2e0739dde41..da0398fe077 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/health/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-health-css", - "version": "0.1.3", + "version": "0.1.4", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss b/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss index a1a54d026fe..54f1db47c7d 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss +++ b/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss @@ -1146,5 +1146,5 @@ tbody { } .digit-action-bar-wrap div { - width: 100%; + width: unset; } \ No newline at end of file diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/villageView.scss b/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/villageView.scss index b2be946938f..fb71b5622e1 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/villageView.scss +++ b/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/villageView.scss @@ -56,4 +56,20 @@ .middle-child { margin-bottom: 1.5rem; +} + +.comment-label { + margin-bottom: .25rem; + @extend .typography.label; + color: theme(digitv2.lightTheme.text-primary); +} + +.comment-label .required { + color: theme(digitv2.alert.error); +} + +.security-question-label { + margin-bottom: 1rem; + @extend .typography.heading-m; + color: theme(digitv2.lightTheme.text-primary); } \ No newline at end of file diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/WorkflowPopUp.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/WorkflowPopUp.js new file mode 100644 index 00000000000..85c1ee88c8c --- /dev/null +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/WorkflowPopUp.js @@ -0,0 +1,104 @@ +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { PopUp, Button, TextArea, ErrorMessage } from "@egovernments/digit-ui-components"; +import { useMyContext } from "../utils/context"; // Ensure that the translation function `t` is handled here + + +{/* use this component for comment like this + setShowPopup(false)} + onSubmit={(comment) => console.log("Submitted comment:", comment)} + census={censusData} +/> */} + +const WorkflowPopUp = ({ onClose, onSubmit, heading }) => { + const { state } = useMyContext(); // Extract state from context + const { t } = useTranslation(); + + const [comment, setComment] = useState(""); // Track TextArea input + const [error, setError] = useState(false); // Track error state + + // Handle TextArea input change + const handleTextAreaChange = (e) => { + setComment(e.target.value); + if (e.target.value.trim()) { + setError(false); // Reset error when input is not empty + } + }; + + // Handle keypress "Enter" to submit the form + const handleKeyPress = (e) => { + if (e.key === "Enter") { + handleSave(); + } + }; + + // Handle Save + const handleSave = () => { + if (!comment.trim()) { + setError(true); // Show error if TextArea is empty + return; // Do not proceed further + } + + // Send the comment to the parent component or handle it here + if (onSubmit) { + onSubmit(comment); // Pass the comment via onSubmit prop + } + + // Close the popup after submitting the comment + onClose(); + }; + + return ( + +
+ {t(`HCM_MICROPLAN_ADD_COMMENT_LABEL`)}{" "} + * +
+