From 197907fa2c574e388e8794306785f53d12aad289 Mon Sep 17 00:00:00 2001 From: Anil_Kumar_Majji <106086523+Anil-kumar-Majji@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:01:44 +0530 Subject: [PATCH] MOSIP-36598: UI Development Create Policy Group Signed-off-by: Anil_Kumar_Majji <106086523+Anil-kumar-Majji@users.noreply.github.com> --- pmp-reactjs-ui/public/i18n/ara.json | 5 +- pmp-reactjs-ui/public/i18n/eng.json | 5 +- pmp-reactjs-ui/public/i18n/fra.json | 4 +- .../admin/policyManager/CreatePolicyGroup.js | 136 ++++++++++-------- 4 files changed, 85 insertions(+), 65 deletions(-) diff --git a/pmp-reactjs-ui/public/i18n/ara.json b/pmp-reactjs-ui/public/i18n/ara.json index 51d55800..808296e1 100644 --- a/pmp-reactjs-ui/public/i18n/ara.json +++ b/pmp-reactjs-ui/public/i18n/ara.json @@ -604,7 +604,10 @@ "enterNameforPolicyGroup": "أدخل اسمًا لمجموعة السياسات", "policyGroupDescription":"وصف مجموعة السياسات", "enterPolicyGroupDescription": "أدخل وصفًا حول مجموعة السياسات هنا", - "errorInCreatePolicyGroup": "أثناء إنشاء السياسة، واجهنا خطأ" + "errorInCreatePolicyGroup": "أثناء إنشاء السياسة، واجهنا خطأ", + "creatPolicyGroupSuccessHeader": "تم إنشاء مجموعة السياسات بنجاح", + "creatPolicyGroupSuccessDescription": "Lorem Ipsum" + }, "policyGroupList": { "policies": "السياسات", diff --git a/pmp-reactjs-ui/public/i18n/eng.json b/pmp-reactjs-ui/public/i18n/eng.json index 0caf5d10..2aaf5e0c 100644 --- a/pmp-reactjs-ui/public/i18n/eng.json +++ b/pmp-reactjs-ui/public/i18n/eng.json @@ -600,7 +600,10 @@ "enterNameforPolicyGroup": "Enter name for Policy Group", "policyGroupDescription":"Policy Group Description", "enterPolicyGroupDescription": "Enter description about Policy Group here", - "errorInCreatePolicyGroup": "While Creating Policy, we have encountered with an error." + "errorInCreatePolicyGroup": "While Creating Policy, we have encountered with an error.", + "creatPolicyGroupSuccessHeader": "Policy Group created successfully!", + "creatPolicyGroupSuccessDescription": "Lorem Ipsum" + }, "policyGroupList": { "policies": "Policies", diff --git a/pmp-reactjs-ui/public/i18n/fra.json b/pmp-reactjs-ui/public/i18n/fra.json index dc8127f4..8bdf31bc 100644 --- a/pmp-reactjs-ui/public/i18n/fra.json +++ b/pmp-reactjs-ui/public/i18n/fra.json @@ -604,7 +604,9 @@ "enterNameforPolicyGroup": "Entrez le nom du groupe de stratégies", "policyGroupDescription":"Description du groupe de stratégies", "enterPolicyGroupDescription": "Entrez la description du groupe de stratégies ici", - "errorInCreatePolicyGroup": "Lors de la création de la stratégie, nous avons rencontré une erreur" + "errorInCreatePolicyGroup": "Lors de la création de la stratégie, nous avons rencontré une erreur", + "creatPolicyGroupSuccessHeader": "Groupe de stratégies créé avec succès !", + "creatPolicyGroupSuccessDescription": "Lorem Ipsum" }, "policyGroupList": { "policies": "Politiques", diff --git a/pmp-reactjs-ui/src/pages/admin/policyManager/CreatePolicyGroup.js b/pmp-reactjs-ui/src/pages/admin/policyManager/CreatePolicyGroup.js index 71b6f638..36045e45 100644 --- a/pmp-reactjs-ui/src/pages/admin/policyManager/CreatePolicyGroup.js +++ b/pmp-reactjs-ui/src/pages/admin/policyManager/CreatePolicyGroup.js @@ -8,6 +8,7 @@ import Title from '../../common/Title'; import LoadingIcon from '../../common/LoadingIcon'; import ErrorMessage from '../../common/ErrorMessage'; import { HttpService } from '../../../services/HttpService'; +import Confirmation from '../../common/Confirmation'; function CreatePolicyGroup() { @@ -22,6 +23,8 @@ function CreatePolicyGroup() { const [isSubmitClicked, setIsSubmitClicked] = useState(false); const [validationError, setValidationError] = useState(""); const [createPolicySuccess, setCreatePolicySuccess] = useState(false); + const [confirmationData, setConfirmationData] = useState({}); + let isCancelledClicked = false; const blocker = useBlocker( @@ -83,33 +86,39 @@ function CreatePolicyGroup() { setIsSubmitClicked(true); setErrorCode(""); setErrorMsg(""); - // let request = createRequest({ - // name: trimAndReplace(policyGroupName), - // desc: trimAndReplace(policyGroupDesc) - // }); - // try { - // const response = await HttpService.post(getPolicyManagerUrl(`/policies/group/new`, process.env.NODE_ENV), request, { - // headers: { - // 'Content-Type': 'application/json' - // } - // }); - // if (response) { - // const responseData = response.data; - // if (responseData && responseData.response) { - // const resData = responseData.response; - // console.log(`Response data: ${resData}`); - - // } else { - // handleServiceErrors(responseData, setErrorCode, setErrorMsg); - // } - // } else { - // setErrorMsg(t('createPolicyGroup.errorInCreatePolicyGroup')); - // } - // setDataLoaded(false); - // } catch (err) { - // setErrorMsg(err); - // console.log("Error fetching data: ", err); - // } + let request = createRequest({ + name: trimAndReplace(policyGroupName), + desc: trimAndReplace(policyGroupDesc) + }); + try { + const response = await HttpService.post(getPolicyManagerUrl(`/policies/group/new`, process.env.NODE_ENV), request, { + headers: { + 'Content-Type': 'application/json' + } + }); + if (response) { + const responseData = response.data; + if (responseData && responseData.response) { + const resData = responseData.response; + console.log(resData); + const requireData = { + backUrl: "/partnermanagement/admin/policy-manager/policy-group-list", + header: "createPolicyGroup.creatPolicyGroupSuccessHeader", + description: "createPolicyGroup.creatPolicyGroupSuccessDescription" + } + setConfirmationData(requireData); + setCreatePolicySuccess(true); + } else { + handleServiceErrors(responseData, setErrorCode, setErrorMsg); + } + } else { + setErrorMsg(t('createPolicyGroup.errorInCreatePolicyGroup')); + } + setDataLoaded(false); + } catch (err) { + setErrorMsg(err); + console.log("Error fetching data: ", err); + } setIsSubmitClicked(false); } @@ -140,49 +149,52 @@ function CreatePolicyGroup() {
{t('requestPolicy.mandatoryFieldsMsg1')} * {t('requestPolicy.mandatoryFieldsMsg2')}
-