From 1722e1b8ecf660095e19fa987b652a4bc1c9ee23 Mon Sep 17 00:00:00 2001 From: Sudeep7353 <103890430+Sudeep7353@users.noreply.github.com> Date: Tue, 22 Oct 2024 11:59:37 +0530 Subject: [PATCH] MOSIP:36498- UI Development: Server Side Filter (#853) Signed-off-by: sudeep --- pmp-reactjs-ui/public/i18n/ara.json | 8 +- pmp-reactjs-ui/public/i18n/eng.json | 8 +- pmp-reactjs-ui/public/i18n/fra.json | 8 +- .../admin/partners/PartnersListFilter.js | 242 ++++++++---------- .../pages/common/fields/TextInputComponent.js | 33 +++ 5 files changed, 154 insertions(+), 145 deletions(-) create mode 100644 pmp-reactjs-ui/src/pages/common/fields/TextInputComponent.js diff --git a/pmp-reactjs-ui/public/i18n/ara.json b/pmp-reactjs-ui/public/i18n/ara.json index ab247d3e..c16d3f29 100644 --- a/pmp-reactjs-ui/public/i18n/ara.json +++ b/pmp-reactjs-ui/public/i18n/ara.json @@ -568,7 +568,13 @@ "selectEmailAddress": "حدد عنوان البريد الإلكتروني", "selectPolicyGroup": "حدد مجموعة السياسات", "selectStatus": "حدد الحالة", - "errorInPartnersList": "أثناء جلب تفاصيل الشركاء، واجهنا خطأً." + "errorInPartnersList": "أثناء جلب تفاصيل الشركاء، واجهنا خطأً.", + "selectCertUploadStatus": "حدد الشهادة. حالة التحميل", + "applyFilter": "تطبيق الفلتر", + "searchPartnerId": "معرف شريك البحث", + "searchOrganisation": "منظمة البحث", + "searchEmailAddress": "بحث في عنوان البريد الإلكتروني", + "searchPolicyGroup": "مجموعة سياسات البحث" }, "viewPartnerDetails": { "viewPartnerDetails": "عرض تفاصيل الشريك", diff --git a/pmp-reactjs-ui/public/i18n/eng.json b/pmp-reactjs-ui/public/i18n/eng.json index efe8f1bd..59d8d8c5 100644 --- a/pmp-reactjs-ui/public/i18n/eng.json +++ b/pmp-reactjs-ui/public/i18n/eng.json @@ -564,7 +564,13 @@ "selectEmailAddress": "Select Email Address", "selectPolicyGroup": "Select Policy Group", "selectStatus": "Select Status", - "errorInPartnersList": "While fetching partners details, we have encountered with an error." + "errorInPartnersList": "While fetching partners details, we have encountered with an error.", + "selectCertUploadStatus": "Select Cert. Upload Status", + "applyFilter": "Apply Filter", + "searchPartnerId": "Search Partner ID", + "searchOrganisation": "Search Organisation", + "searchEmailAddress": "Search Email Address", + "searchPolicyGroup": "Search Policy Group" }, "viewPartnerDetails": { "viewPartnerDetails": "View Partner Details", diff --git a/pmp-reactjs-ui/public/i18n/fra.json b/pmp-reactjs-ui/public/i18n/fra.json index b7384920..47bdd60d 100644 --- a/pmp-reactjs-ui/public/i18n/fra.json +++ b/pmp-reactjs-ui/public/i18n/fra.json @@ -568,7 +568,13 @@ "selectEmailAddress": "Sélectionnez l'adresse e-mail", "selectPolicyGroup":"Sélectionnez un groupe de stratégies", "selectStatus":"Sélectionnez le statut", - "errorInPartnersList": "Lors de la récupération des détails des partenaires, nous avons rencontré une erreur." + "errorInPartnersList": "Lors de la récupération des détails des partenaires, nous avons rencontré une erreur.", + "selectCertUploadStatus": "Sélectionnez Cert. Statut de téléchargement", + "applyFilter": "Appliquer le filtre", + "searchPartnerId": "ID du partenaire de recherche", + "searchOrganisation": "Rechercher une organisation", + "searchEmailAddress": "Rechercher une adresse e-mail", + "searchPolicyGroup": "Groupe de stratégies de recherche" }, "viewPartnerDetails": { "viewPartnerDetails": "Afficher les détails du partenaire", diff --git a/pmp-reactjs-ui/src/pages/admin/partners/PartnersListFilter.js b/pmp-reactjs-ui/src/pages/admin/partners/PartnersListFilter.js index 0a6f129f..ecfcd175 100644 --- a/pmp-reactjs-ui/src/pages/admin/partners/PartnersListFilter.js +++ b/pmp-reactjs-ui/src/pages/admin/partners/PartnersListFilter.js @@ -1,93 +1,41 @@ import { useState, useEffect } from "react"; import DropdownComponent from "../../common/fields/DropdownComponent.js"; +import TextInputComponent from "../../common/fields/TextInputComponent.js"; import { useTranslation } from "react-i18next"; import { createDropdownData } from "../../../utils/AppUtils.js"; function PartnerListFilter({ filteredPartnersData, onFilterChange }) { - console.log(filteredPartnersData) const { t } = useTranslation(); - const [partnerIdData, setPartnerIdData] = useState([]); - const [partnerTypeData, setPartnerTypeData] = useState([]); - const [organisationNameData, setOrganisationNameData] = useState([]); - const [emailIdData, setEmailIdData] = useState([]); - const [policyGroupData, setPolicyGroupData] = useState([]); - const [statusData, setStatusData] = useState([]); - console.log(partnerIdData) - console.log(partnerTypeData) - useEffect(() => { - const fetchData = async () => { - setPartnerIdData( - createDropdownData( - "partnerID", - "", - true, - filteredPartnersData, - t, - t("partnerList.selectPartnerId") - ) - ); - - setPartnerTypeData( - createDropdownData( - "partnerType", - "", - true, - filteredPartnersData, - t, - t("partnerList.selectPartnerType") - ) - ); - - setOrganisationNameData( - createDropdownData( - "orgName", - "", - true, - filteredPartnersData, - t, - t("partnerList.selectOrganisation") - ) - ); + const [partnerType, setPartnerType] = useState([]); + const [status, setStatus] = useState([]); + const [certUploadStatus, setCertUploadStatus] = useState([]); + const [filters, setFilters] = useState({ + partnerType: "", + status: "", + orgName: "", + emailID: "", + certUploadStatus: "", + policyGroup: "" + }); - setEmailIdData( - createDropdownData( - "emailID", - "", - true, - filteredPartnersData, - t, - t("partnerList.selectEmailAddress") - ) - ); - - setPolicyGroupData( - createDropdownData( - "policyGroup", - "", - true, - filteredPartnersData, - t, - t("partnerList.selectPolicyGroup") - ) - ); - - setStatusData( - createDropdownData( - "status", - "", - true, - filteredPartnersData, - t, - t("rootTrustCertificate.selectStatus") - ) - ); - }; - fetchData(); - }, [t]); + useEffect(() => { + setPartnerType( + createDropdownData("partnerType", "", true, filteredPartnersData, t, t("partnerList.selectPartnerType")) + ); + setStatus( + createDropdownData("status", "", true, filteredPartnersData, t, t("partnerList.selectStatus")) + ); + setCertUploadStatus( + createDropdownData("certificateUploadStatus", "", true, filteredPartnersData, t, t("partnerList.selectCertUploadStatus")) + ); + }, [filteredPartnersData, t]); const onFilterChangeEvent = (fieldName, selectedFilter) => { - onFilterChange(fieldName, selectedFilter); + setFilters((prevFilters) => ({ + ...prevFilters, + [fieldName]: selectedFilter + })); }; const styles = { @@ -95,70 +43,80 @@ function PartnerListFilter({ filteredPartnersData, onFilterChange }) { }; return ( - <> -
- - - - - - +
+ + + + + + + +
+
- +
); } diff --git a/pmp-reactjs-ui/src/pages/common/fields/TextInputComponent.js b/pmp-reactjs-ui/src/pages/common/fields/TextInputComponent.js new file mode 100644 index 00000000..2f8d67d9 --- /dev/null +++ b/pmp-reactjs-ui/src/pages/common/fields/TextInputComponent.js @@ -0,0 +1,33 @@ +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; + +function TextInputComponent({ fieldName, fieldNameKey, placeHolderKey, onTextChange, styleSet, id }) { + const { t } = useTranslation(); + const [inputValue, setInputValue] = useState(''); + + const handleInputChange = (event) => { + const newValue = event.target.value; + setInputValue(newValue); + onTextChange(fieldName, newValue); + }; + + return ( +
+ + + +
+ ); +} + +export default TextInputComponent;