From 95b4b16f1da3b83cfccf08c667186456821196d3 Mon Sep 17 00:00:00 2001 From: faisalEsMagico Date: Thu, 16 Nov 2023 12:20:15 +0530 Subject: [PATCH] feat(integration): changes done --- src/app/question-bank/page.tsx | 2 +- src/app/setup-new-configuration/page.tsx | 7 ++ src/app/wpcas/page.tsx | 2 +- src/components/navbar/SideNavbar.tsx | 4 +- .../QuestionUploadAndDownload.tsx | 2 +- src/components/wpcasOverView/Pagination.tsx | 11 ++- src/components/wpcasOverView/SurveyTable.tsx | 24 ++++++- src/components/wpcasOverView/UserTable.tsx | 71 ++++++++++++------- src/services/bultTemplate.ts | 7 +- 9 files changed, 92 insertions(+), 38 deletions(-) diff --git a/src/app/question-bank/page.tsx b/src/app/question-bank/page.tsx index 01d73cb..a143764 100644 --- a/src/app/question-bank/page.tsx +++ b/src/app/question-bank/page.tsx @@ -77,7 +77,7 @@ const QuestionBank = () => { if (typeof option == 'number') setCurrentCompetency(option); }} width='714px' - placeholder='Department' + placeholder='Competency' paddingY='2px' errorMessage={currentCompetency === null ? showError : ''} /> diff --git a/src/app/setup-new-configuration/page.tsx b/src/app/setup-new-configuration/page.tsx index 8c2892c..2b738e9 100644 --- a/src/app/setup-new-configuration/page.tsx +++ b/src/app/setup-new-configuration/page.tsx @@ -35,6 +35,10 @@ const SetupNewSurvey = ({ visible }: { visible: boolean }) => { const [isOpen, setIsOpen] = useState(visible); const [isSuccessPopUpOpen, setIsSuccessPopUpOpen] = useState(false); const [isNewForm, setIsNewForm] = useState(false); + + // to fetch survey config details after new survey form create or update + const [fetchData, setFetchData] = useState(true); + const handleAssessesFileDownload = () => { (async () => { const response = await downloadAssessesList(); @@ -77,6 +81,7 @@ const SetupNewSurvey = ({ visible }: { visible: boolean }) => { setIsOpen(false)} setIsSuccessPopUpOpen={setIsSuccessPopUpOpen} + handleFetchConfigData={() => setFetchData(true)} /> {isSuccessPopUpOpen && ( @@ -116,6 +121,8 @@ const SetupNewSurvey = ({ visible }: { visible: boolean }) => { {/* survey config table, search functionality and pagination component */} setIsNewForm(false)} /> diff --git a/src/app/wpcas/page.tsx b/src/app/wpcas/page.tsx index a6cd0d0..0ae936b 100644 --- a/src/app/wpcas/page.tsx +++ b/src/app/wpcas/page.tsx @@ -15,7 +15,7 @@ export type SearchInputType = { type UserListType = { userId: string; userName: string; - wpcas: string; + wpcasScore: string; surveysFilled: number; surveysToBeFilled: number; dateOfJoining: Date; diff --git a/src/components/navbar/SideNavbar.tsx b/src/components/navbar/SideNavbar.tsx index 3d47b42..657acdf 100644 --- a/src/components/navbar/SideNavbar.tsx +++ b/src/components/navbar/SideNavbar.tsx @@ -39,7 +39,7 @@ const SideNavbar = () => {
- WPCAS + WPCAS Overview
@@ -55,7 +55,7 @@ const SideNavbar = () => { }`} > - Setup New Configuration + Setup New Survey diff --git a/src/components/questionBank/QuestionUploadAndDownload.tsx b/src/components/questionBank/QuestionUploadAndDownload.tsx index 1959563..a59be8d 100644 --- a/src/components/questionBank/QuestionUploadAndDownload.tsx +++ b/src/components/questionBank/QuestionUploadAndDownload.tsx @@ -27,7 +27,7 @@ const QuestionUploadAndDownload = () => { // Make a POST request to backend await axios.post( - 'http://localhost:5000/api/question-bank/upload', + 'http://localhost:3000/api/question-bank/upload', formData ); diff --git a/src/components/wpcasOverView/Pagination.tsx b/src/components/wpcasOverView/Pagination.tsx index 875ff9e..3da3f70 100644 --- a/src/components/wpcasOverView/Pagination.tsx +++ b/src/components/wpcasOverView/Pagination.tsx @@ -3,6 +3,7 @@ import { MdOutlineKeyboardArrowLeft, MdOutlineKeyboardArrowRight, } from 'react-icons/md'; +import { toast } from 'react-toastify'; type PropsType = { handlePageSize: (value: number) => void; @@ -24,9 +25,13 @@ const Pagination = ({ const [pageNumber, setPageNumber] = useState(''); const handleSearch = (e: React.KeyboardEvent) => { - if (e.keyCode === 13 && parseInt(pageNumber) <= totalPages) { - handlePage(parseInt(pageNumber)); - setPageNumber(''); + if (e.keyCode === 13) { + if (parseInt(pageNumber) <= totalPages) { + handlePage(parseInt(pageNumber)); + setPageNumber(''); + } else { + toast.error(`page ${pageNumber} not found`); + } } }; diff --git a/src/components/wpcasOverView/SurveyTable.tsx b/src/components/wpcasOverView/SurveyTable.tsx index 03f182a..81e09af 100644 --- a/src/components/wpcasOverView/SurveyTable.tsx +++ b/src/components/wpcasOverView/SurveyTable.tsx @@ -13,17 +13,21 @@ import { getConfigurationList } from '@/services/configurationServices'; type PropType = { setIsSuccessPopUpOpen: (value: boolean) => void; handleEditMessage: () => void; + setFetchData: (arg: boolean) => void; + fetchData: boolean; }; const SurveyTable = ({ setIsSuccessPopUpOpen, handleEditMessage, + setFetchData, + fetchData, }: PropType) => { const [loading, setLoading] = useState(false); const [error, setError] = useState(false); // to fetch survey config details after new survey form create or update - const [fetchData, setFetchData] = useState(true); + // const [fetchData, setFetchData] = useState(true); const [userSurveyData, setUserSurveyData] = useState([]); const [isOpen, setIsOpen] = useState(false); @@ -63,7 +67,7 @@ const SurveyTable = ({ } })(); } - }, [fetchData]); + }, [fetchData, setFetchData]); return (
@@ -133,8 +137,24 @@ const SurveyTable = ({ )} + {!loading && !error && userSurveyData.length == 0 && ( + + + No Survey Configuration + + + )} + {!loading && !error && + userSurveyData.length > 0 && userSurveyData?.map((user) => { const { endTime, startTime, surveyName, id } = user; return ( diff --git a/src/components/wpcasOverView/UserTable.tsx b/src/components/wpcasOverView/UserTable.tsx index 8eada99..0165779 100644 --- a/src/components/wpcasOverView/UserTable.tsx +++ b/src/components/wpcasOverView/UserTable.tsx @@ -9,7 +9,7 @@ import SearchUser from '@/components/wpcasOverView/SearchUser'; export type UserListType = { userId: string; userName: string; - wpcas: string; + wpcasScore: string; surveysFilled: number; surveysToBeFilled: number; dateOfJoining: Date; @@ -95,34 +95,51 @@ const UserTable = ({ - {currentData?.map((user: UserListType) => { - return ( - + - - {user?.userId} - - - {user?.userName} - - - {user?.wpcas} - + No Result Found + + + )} + {currentData.length > 0 && + currentData?.map((user: UserListType) => { + return ( + + + {user?.userId} + + + {user?.userName} + + + {user?.wpcasScore ? user?.wpcasScore : '--'} + - - {user?.surveysFilled} - - - {user?.surveysToBeFilled} - - - {new Date(user?.dateOfJoining).toLocaleDateString('en-GB')} - - - ); - })} + + {user?.surveysFilled} + + + {user?.surveysToBeFilled} + + + {new Date(user?.dateOfJoining).toLocaleDateString( + 'en-GB' + )} + + + ); + })}