Skip to content

Commit

Permalink
feat(integration): changes done
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalEsMagico committed Nov 16, 2023
1 parent c25d0e7 commit 95b4b16
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/app/question-bank/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const QuestionBank = () => {
if (typeof option == 'number') setCurrentCompetency(option);
}}
width='714px'
placeholder='Department'
placeholder='Competency'
paddingY='2px'
errorMessage={currentCompetency === null ? showError : ''}
/>
Expand Down
7 changes: 7 additions & 0 deletions src/app/setup-new-configuration/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -77,6 +81,7 @@ const SetupNewSurvey = ({ visible }: { visible: boolean }) => {
<SetupConfigurationForm
onClose={() => setIsOpen(false)}
setIsSuccessPopUpOpen={setIsSuccessPopUpOpen}
handleFetchConfigData={() => setFetchData(true)}
/>
</CommonModal>
{isSuccessPopUpOpen && (
Expand Down Expand Up @@ -116,6 +121,8 @@ const SetupNewSurvey = ({ visible }: { visible: boolean }) => {

{/* survey config table, search functionality and pagination component */}
<SurveyTable
fetchData={fetchData}
setFetchData={setFetchData}
setIsSuccessPopUpOpen={setIsSuccessPopUpOpen}
handleEditMessage={() => setIsNewForm(false)}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/app/wpcas/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type SearchInputType = {
type UserListType = {
userId: string;
userName: string;
wpcas: string;
wpcasScore: string;
surveysFilled: number;
surveysToBeFilled: number;
dateOfJoining: Date;
Expand Down
4 changes: 2 additions & 2 deletions src/components/navbar/SideNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const SideNavbar = () => {
<Link href='/wpcas'>
<div className={`flex `}>
<WpcasIcon className='mr-2 w-5' />
WPCAS
WPCAS Overview
</div>
</Link>
</li>
Expand All @@ -55,7 +55,7 @@ const SideNavbar = () => {
}`}
>
<ListIcon className='mr-2 w-3' />
Setup New Configuration
Setup New Survey
</li>
</Link>
<Link href='/question-bank'>
Expand Down
2 changes: 1 addition & 1 deletion src/components/questionBank/QuestionUploadAndDownload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down
11 changes: 8 additions & 3 deletions src/components/wpcasOverView/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
MdOutlineKeyboardArrowLeft,
MdOutlineKeyboardArrowRight,
} from 'react-icons/md';
import { toast } from 'react-toastify';

type PropsType = {
handlePageSize: (value: number) => void;
Expand All @@ -24,9 +25,13 @@ const Pagination = ({
const [pageNumber, setPageNumber] = useState('');

const handleSearch = (e: React.KeyboardEvent<HTMLInputElement>) => {
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`);
}
}
};

Expand Down
24 changes: 22 additions & 2 deletions src/components/wpcasOverView/SurveyTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<SurveyDataType[]>([]);
const [isOpen, setIsOpen] = useState(false);
Expand Down Expand Up @@ -63,7 +67,7 @@ const SurveyTable = ({
}
})();
}
}, [fetchData]);
}, [fetchData, setFetchData]);

return (
<div className='relative h-[52vh] overflow-x-auto overflow-y-auto shadow-md sm:rounded-md '>
Expand Down Expand Up @@ -133,8 +137,24 @@ const SurveyTable = ({
</tr>
)}

{!loading && !error && userSurveyData.length == 0 && (
<tr
className={`border-b bg-white hover:bg-gray-50 ${outfit.className}`}
>
<td
align='center'
colSpan={4}
className={` px-6 py-[14px] text-center
text-sm font-normal text-[#272728]`}
>
No Survey Configuration
</td>
</tr>
)}

{!loading &&
!error &&
userSurveyData.length > 0 &&
userSurveyData?.map((user) => {
const { endTime, startTime, surveyName, id } = user;
return (
Expand Down
71 changes: 44 additions & 27 deletions src/components/wpcasOverView/UserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,34 +95,51 @@ const UserTable = ({
</tr>
</thead>
<tbody>
{currentData?.map((user: UserListType) => {
return (
<tr
key={user?.userId}
className={`border-b bg-white hover:bg-gray-50 ${outfit.className}`}
{currentData.length == 0 && (
<tr
className={`border-b bg-white hover:bg-gray-50 ${outfit.className}`}
>
<td
align='center'
colSpan={6}
className={` px-6 py-[14px] text-center
text-sm font-normal text-[#272728]`}
>
<td className='px-6 py-[14px] text-sm font-normal text-[#272728]'>
{user?.userId}
</td>
<td className='px-6 py-[14px] text-sm font-normal text-[#272728]'>
{user?.userName}
</td>
<td className='px-6 py-[14px] text-sm font-normal text-[#272728]'>
{user?.wpcas}
</td>
No Result Found
</td>
</tr>
)}
{currentData.length > 0 &&
currentData?.map((user: UserListType) => {
return (
<tr
key={user?.userId}
className={`border-b bg-white hover:bg-gray-50 ${outfit.className}`}
>
<td className='px-6 py-[14px] text-sm font-normal text-[#272728]'>
{user?.userId}
</td>
<td className='px-6 py-[14px] text-sm font-normal text-[#272728]'>
{user?.userName}
</td>
<td className='px-6 py-[14px] text-center text-sm font-normal text-[#272728]'>
{user?.wpcasScore ? user?.wpcasScore : '--'}
</td>

<td className='px-6 py-[14px] text-center text-sm font-normal text-[#272728]'>
{user?.surveysFilled}
</td>
<td className='px-6 py-[14px] text-center text-sm font-normal text-[#272728]'>
{user?.surveysToBeFilled}
</td>
<td className='px-6 py-[14px] text-center text-sm font-normal text-[#272728]'>
{new Date(user?.dateOfJoining).toLocaleDateString('en-GB')}
</td>
</tr>
);
})}
<td className='px-6 py-[14px] text-center text-sm font-normal text-[#272728]'>
{user?.surveysFilled}
</td>
<td className='px-6 py-[14px] text-center text-sm font-normal text-[#272728]'>
{user?.surveysToBeFilled}
</td>
<td className='px-6 py-[14px] text-center text-sm font-normal text-[#272728]'>
{new Date(user?.dateOfJoining).toLocaleDateString(
'en-GB'
)}
</td>
</tr>
);
})}
</tbody>
</table>
<Pagination
Expand Down
7 changes: 6 additions & 1 deletion src/services/bultTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ export const uploadTemplate = async (
// Make a POST request to backend
await axios.post(
'http://localhost:3000/api/question-bank/upload',
formData
formData,
{
headers: {
'Content-Type': 'multipart/form-data', // Set the content type to multipart/form-data
},
}
);

setShowSuccessPopUp(true);
Expand Down

0 comments on commit 95b4b16

Please sign in to comment.