Skip to content

Commit

Permalink
MOSIP:32721 - Update API: getAllPolicies() and integrate with View Po…
Browse files Browse the repository at this point in the history
…licy UI (#406)

* MOSIP:32721 - Update API: getAllPolicies() and integrate with View Policy UI

Signed-off-by: sudeep <[email protected]>

* MOSIP:32721 - Update API: getAllPolicies() and integrate with View Policy UI

Signed-off-by: sudeep <[email protected]>

---------

Signed-off-by: sudeep <[email protected]>
  • Loading branch information
Sudeep7353 authored Jun 3, 2024
1 parent cf358da commit 6bc961d
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 126 deletions.
11 changes: 7 additions & 4 deletions pmp-reactjs-ui/public/i18n/ara.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"filterBtn": "منقي",
"partnerId": "معرف الشريك",
"partnerType": "معرف الشريك",
"policyGroup": "مجموعة السياسات",
"policyGroupName": "مجموعة السياسات",
"policyName": "اسم السياسة",
"createdDate": "تاريخ الإنشاء",
"status": "حالة",
Expand All @@ -119,7 +119,7 @@
"partnerId": "معرف الشريك",
"partnerIdName": "اسم معرف الشريك",
"partnerType": "نوع الشريك",
"policyGroup": "مجموعة السياسات",
"policyGroupName": "مجموعة السياسات",
"policyGroupDescription": "وصف مجموعة السياسات",
"policyNameDescription": "وصف اسم السياسة",
"comments": "تعليقات",
Expand Down Expand Up @@ -290,7 +290,10 @@
"PMS_CERTIFICATE_ERROR_001": "حدث خطأ أثناء جلب شهادات الشريك.",
"PMS_CERTIFICATE_ERROR_002": "معرف المستخدم غير موجود.",
"PMS_CERTIFICATE_ERROR_003": "معرف الشريك فارغ أو فارغ.",
"PMS_POLICY_ERROR_001": "اسم مجموعة السياسات فارغ أو فارغ.",
"PMS_POLICY_ERROR_002": "حدث خطأ أثناء جلب سياسات الشركاء."
"PMS_POLICY_ERROR_001": "مجموعة السياسات غير موجودة.",
"PMS_POLICY_ERROR_002": "حدث خطأ أثناء جلب سياسات الشركاء.",
"PMS_POLICY_ERROR_003": "حدث خطأ أثناء جلب جميع معرفات الشركاء المعتمدين مع مجموعات السياسات.",
"PMS_POLICY_ERROR_004": "لم يتم العثور على سياسة المطابقة.",
"PMS_POLICY_ERROR_005": "معرف مجموعة السياسات فارغ."
}
}
11 changes: 7 additions & 4 deletions pmp-reactjs-ui/public/i18n/eng.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"filterBtn": "Filter",
"partnerId": "Partner ID",
"partnerType": "Partner Type",
"policyGroup": "Policy Group",
"policyGroupName": "Policy Group",
"policyName": "Policy Name",
"createdDate": "Created Date",
"status": "Status",
Expand All @@ -119,7 +119,7 @@
"partnerId": "Partner ID",
"partnerIdName": "Partner ID Name",
"partnerType": "Partner Type",
"policyGroup": "Policy Group",
"policyGroupName": "Policy Group",
"policyGroupDescription": "Policy Group Description",
"policyNameDescription": "Policy Name Description",
"comments": "Comments",
Expand Down Expand Up @@ -290,7 +290,10 @@
"PMS_CERTIFICATE_ERROR_001": "Error while fetching partner certificates.",
"PMS_CERTIFICATE_ERROR_002": "User Id does not exists.",
"PMS_CERTIFICATE_ERROR_003": "Partner Id is null or empty.",
"PMS_POLICY_ERROR_001": "Policy Group Name is null or empty.",
"PMS_POLICY_ERROR_002": "Error while fetching partner policies."
"PMS_POLICY_ERROR_001": "Policy Group does not exists.",
"PMS_POLICY_ERROR_002": "Error while fetching partner policies.",
"PMS_POLICY_ERROR_003": "Error while fetching all approved partner Ids with policy groups.",
"PMS_POLICY_ERROR_004": "Matching Policy not found.",
"PMS_POLICY_ERROR_005": "Policy Group Id is empty."
}
}
11 changes: 7 additions & 4 deletions pmp-reactjs-ui/public/i18n/fra.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"filterBtn": "Filtre",
"partnerId": "ID partenaire",
"partnerType": "Type de partenaire",
"policyGroup": "Groupe de politiques",
"policyGroupName": "Groupe de politiques",
"policyName": "Nom de la politique",
"createdDate": "Date de création",
"status": "Statut",
Expand All @@ -120,7 +120,7 @@
"partnerId": "ID partenaire",
"partnerIdName": "Nom du partenaire",
"partnerType": "Type de partenaire",
"policyGroup": "Groupe de politiques",
"policyGroupName": "Groupe de politiques",
"policyGroupDescription": "Description du groupe de stratégies",
"policyNameDescription": "Nom de la stratégie Description",
"comments": "commentaires",
Expand Down Expand Up @@ -291,7 +291,10 @@
"PMS_CERTIFICATE_ERROR_001": "Erreur lors de la récupération des certificats partenaires.",
"PMS_CERTIFICATE_ERROR_002": "L'ID utilisateur n'existe pas.",
"PMS_CERTIFICATE_ERROR_003": "L'ID du partenaire est nul ou vide.",
"PMS_POLICY_ERROR_001": "Le nom du groupe de stratégies est nul ou vide.",
"PMS_POLICY_ERROR_002": "Erreur lors de la récupération des stratégies partenaires."
"PMS_POLICY_ERROR_001": "Le groupe de stratégies n existe pas.",
"PMS_POLICY_ERROR_002": "Erreur lors de la récupération des stratégies partenaires.",
"PMS_POLICY_ERROR_003": "Erreur lors de la récupération de tous les identifiants de partenaires approuvés avec les groupes de stratégies.",
"PMS_POLICY_ERROR_004": "Politique correspondante introuvable.",
"PMS_POLICY_ERROR_005": "LID du groupe de stratégies est vide."
}
}
13 changes: 7 additions & 6 deletions pmp-reactjs-ui/src/pages/policies/Policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ function Policies() {
const [viewPolicyId, setViewPolicyId] = useState(-1);
const defaultFilterQuery = {
partnerId: "",
policyGroup: ""
policyGroupName: ""
};
const [filterQuery, setFilterQuery] = useState({ ...defaultFilterQuery });

const tableHeaders = [
{ id: "partnerId", headerNameKey: 'policies.partnerId' },
{ id: "partnerType", headerNameKey: "policies.partnerType" },
{ id: "policyGroup", headerNameKey: "policies.policyGroup" },
{ id: "policyGroupName", headerNameKey: "policies.policyGroupName" },
{ id: "policyName", headerNameKey: "policies.policyName" },
{ id: "createDate", headerNameKey: "policies.createdDate" },
{ id: "status", headerNameKey: "policies.status" },
Expand Down Expand Up @@ -90,7 +90,7 @@ function Policies() {
const fetchData = async () => {
try {
setDataLoaded(false);
const response = await HttpService.get(getPartnerManagerUrl('/partners/getAllPolicies', process.env.NODE_ENV));
const response = await HttpService.get(getPartnerManagerUrl('/partners/getAllRequestedPolicies', process.env.NODE_ENV));
setFirstTimeLoad(true);
if (response) {
const responseData = response.data;
Expand Down Expand Up @@ -123,7 +123,8 @@ function Policies() {
navigate('/partnermanagement/requestPolicy')
}

const showViewPolicyDetails = (id) => {
const showViewPolicyDetails = (selectedPolicyData) => {
localStorage.setItem('selectedPolicyData', JSON.stringify(selectedPolicyData));
navigate('/partnermanagement/viewPolicyDetails')
};

Expand Down Expand Up @@ -371,7 +372,7 @@ function Policies() {
<tr key={index} className={`border-t-2 text-sm text-[#191919] font-medium ${partner.status.toLowerCase() === "deactivated" ? "text-[#969696]" : "text-[#191919]"}`}>
<td className="px-2">{partner.partnerId}</td>
<td className="px-2">{getPartnerTypeDescription(partner.partnerType, t)}</td>
<td className="px-2">{partner.policyGroup}</td>
<td className="px-2">{partner.policyGroupName}</td>
<td className="px-2">{partner.policyName}</td>
<td className="px-2">{formatDate(partner.createDate, 'dateTime')}</td>
<td className="">
Expand All @@ -384,7 +385,7 @@ function Policies() {
<p onClick={() => setViewPolicyId(index)} className="mr-9 font-semibold mb-0.5 cursor-pointer">...</p>
{
viewPolicyId === index && (
<div onClick={() => showViewPolicyDetails()}
<div onClick={() => showViewPolicyDetails(partner)}
className="absolute bg-white text-xs font-medium rounded-lg shadow-md border">
<p className="px-5 py-2 cursor-pointer">
{t('policies.view')}
Expand Down
6 changes: 3 additions & 3 deletions pmp-reactjs-ui/src/pages/policies/PoliciesFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function PoliciesFilter({ filteredPoliciesList, onFilterChange }) {
const fetchData = async () => {
setPartnerIdData(createDropdownDataList('partnerId', filteredPoliciesList, t));
setPartnerTypeData(createDropdownDataList('partnerType', filteredPoliciesList, t));
setPolicyGroupNameData(createDropdownDataList('policyGroup', filteredPoliciesList, t));
setPolicyGroupNameData(createDropdownDataList('policyGroupName', filteredPoliciesList, t));
setPolicyNameData(createDropdownDataList('policyName', filteredPoliciesList, t));
setStatusData(createDropdownDataList('status', filteredPoliciesList, t));
};
Expand Down Expand Up @@ -46,10 +46,10 @@ function PoliciesFilter({ filteredPoliciesList, onFilterChange }) {
placeHolderKey='policies.selectPartnerType'>
</DropdownComponent>
<DropdownComponent
fieldName='policyGroup'
fieldName='policyGroupName'
dropdownDataList={policyGroupNameData}
onDropDownChangeEvent={onFilterChangeEvent}
fieldNameKey='policies.policyGroup'
fieldNameKey='policies.policyGroupName'
placeHolderKey='policies.selectPolicyGroup'>
</DropdownComponent>
<DropdownComponent
Expand Down
10 changes: 3 additions & 7 deletions pmp-reactjs-ui/src/pages/policies/RequestPolicy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { getPartnerManagerUrl, getPolicyManagerUrl, handleServiceErrors, createDropdownDataList } from '../../utils/AppUtils';
import { getPartnerManagerUrl, getPolicyManagerUrl, handleServiceErrors, createDropdownDataList, moveToPolicies } from '../../utils/AppUtils';
import { HttpService } from '../../services/HttpService';
import LoadingIcon from "../common/LoadingIcon";
import ErrorMessage from "../common/ErrorMessage";
Expand Down Expand Up @@ -32,10 +32,6 @@ function RequestPolicy() {
navigate('/partnermanagement')
};

const moveToPolicies = () => {
navigate('/partnermanagement/policies')
};

useEffect(() => {
const fetchData = async () => {
try {
Expand Down Expand Up @@ -155,7 +151,7 @@ function RequestPolicy() {
<p onClick={() => moveToHome()} className="font-semibold text-tory-blue text-xs cursor-pointer">
{t('commons.home')} /
</p>
<p onClick={() => moveToPolicies()} className="font-semibold text-tory-blue text-xs cursor-pointer">
<p onClick={() => moveToPolicies(navigate)} className="font-semibold text-tory-blue text-xs cursor-pointer">
{t('requestPolicy.policies')}
</p>
</div>
Expand Down Expand Up @@ -226,7 +222,7 @@ function RequestPolicy() {
<div className="flex flex-row px-[3%] py-[2%] justify-between">
<button onClick={() => clearForm()} className="mr-2 w-40 h-12 border-[#1447B2] border rounded-md bg-white text-tory-blue text-base font-semibold">{t('requestPolicy.clearForm')}</button>
<div className="flex flex-row space-x-3 w-full md:w-auto justify-end">
<button onClick={() => moveToPolicies()} className="mr-2 w-full md:w-40 h-12 border-[#1447B2] border rounded-md bg-white text-tory-blue text-base font-semibold">{t('requestPolicy.cancel')}</button>
<button onClick={() => moveToPolicies(navigate)} className="mr-2 w-full md:w-40 h-12 border-[#1447B2] border rounded-md bg-white text-tory-blue text-base font-semibold">{t('requestPolicy.cancel')}</button>
<button disabled={!isFormValid()} className={`mr-2 w-full md:w-40 h-12 border-[#1447B2] border rounded-md text-base font-semibold ${isFormValid() ? 'bg-tory-blue text-white' : 'border-[#A5A5A5] bg-[#A5A5A5] text-white cursor-not-allowed'}`}>{t('requestPolicy.submit')}</button>
</div>
</div>
Expand Down
Loading

0 comments on commit 6bc961d

Please sign in to comment.