diff --git a/src/common/enums.ts b/src/common/enums.ts index 90b595384..149a3ae3a 100644 --- a/src/common/enums.ts +++ b/src/common/enums.ts @@ -75,7 +75,7 @@ export enum BulkIssuanceHistoryData { completed = 'Process Completed', interrupted= 'Process Interrupted', retry= 'Process Reinitiated', - partially_completed= "Process Failed" + partially_completed= "Partially Completed", } export enum BulkIssuanceStatus { diff --git a/src/components/AlertComponent/index.tsx b/src/components/AlertComponent/index.tsx index 0f9c4d719..7552a232a 100644 --- a/src/components/AlertComponent/index.tsx +++ b/src/components/AlertComponent/index.tsx @@ -1,5 +1,5 @@ -import React from "react"; -import type { IAlertComponent } from "./interface"; +import React from 'react'; +import type { IAlertComponent } from './interface'; export const AlertComponent = ({ message, @@ -7,7 +7,7 @@ export const AlertComponent = ({ viewButton, onAlertClose, path = '', -}:IAlertComponent) => { +}: IAlertComponent) => { const getAlertClass = () => { switch (type) { case 'warning': diff --git a/src/components/Issuance/BulkIssuance.tsx b/src/components/Issuance/BulkIssuance.tsx index 7f243998f..5ece10f30 100644 --- a/src/components/Issuance/BulkIssuance.tsx +++ b/src/components/Issuance/BulkIssuance.tsx @@ -1,5 +1,5 @@ import { Button, Card, Pagination } from 'flowbite-react'; -import React, { Attributes, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import Select from 'react-select'; import { DownloadCsvTemplate, getSchemaCredDef, getCsvFileData, @@ -29,7 +29,6 @@ const BulkIssuance = () => { const [uploadedFileName, setUploadedFileName] = useState(''); const [uploadedFile, setUploadedFile] = useState(null); const [openModal, setOpenModal] = useState(false); - const [message, setMessage] = useState(''); const [searchText, setSearchText] = useState(''); const [uploadMessage, setUploadMessage] = useState(null) const [success, setSuccess] = useState(null); @@ -112,19 +111,31 @@ const BulkIssuance = () => { if (fileUrl) { downloadFile(fileUrl, 'downloadedFile.csv'); setSuccess('File downloaded successfully'); + setTimeout(()=>{ + setSuccess(null) + },5000) setProcess(false); } else { setUploadMessage({message: 'File URL is missing in the response', type: "failure"}); + setTimeout(()=>{ + setUploadMessage(null) + },5000) setSuccess(null) setFailure(null) } } else { setUploadMessage({message: 'API request was not successful', type: "failure"}); + setTimeout(()=>{ + setUploadMessage(null) + },5000) setSuccess(null) setFailure(null) } } catch (error) { setUploadMessage({message: error as string, type: "failure"}); + setTimeout(()=>{ + setUploadMessage(null) + },5000) setSuccess(null) setFailure(null) } @@ -160,6 +171,7 @@ const BulkIssuance = () => { useEffect(() => { SOCKET.emit('bulk-connection') SOCKET.on('bulk-issuance-process-completed', () => { + setSuccess(null) console.log(`bulk-issuance-process-completed`); toast.success('Issuance process completed', { position: 'top-right', @@ -171,10 +183,10 @@ const BulkIssuance = () => { progress: undefined, theme: 'colored', }); - setSuccess("Issuance process completed") }); SOCKET.on('error-in-bulk-issuance-process', () => { + setFailure(null) console.log(`error-in-bulk-issuance-process-initiated`); toast.error('Issuance process failed. Please retry', { position: 'top-right', @@ -186,7 +198,6 @@ const BulkIssuance = () => { progress: undefined, theme: 'colored', }); - setFailure("Issuance process failed, please retry") }); }, []) @@ -196,6 +207,9 @@ const BulkIssuance = () => { if (file.type !== 'text/csv') { setUploadMessage({message:'Invalid file type. Please select only CSV files.', type: "failure"}); + setTimeout(()=>{ + setUploadMessage(null) + },5000) setSuccess(null) setFailure(null) return; @@ -225,9 +239,15 @@ const BulkIssuance = () => { setRequestId(data?.data); setIsFileUploaded(true); setUploadMessage({message: data?.message, type: "success"}); + setTimeout(()=>{ + setUploadMessage(null) + },5000) await handleCsvFileData(data?.data); } else { setUploadMessage({message: response as string, type: "failure"}); + setTimeout(()=>{ + setUploadMessage(null) + },5000) setSuccess(null) setFailure(null) } @@ -346,6 +366,9 @@ const BulkIssuance = () => { handleResetForConfirm() } else { setFailure(response as string); + setTimeout(()=>{ + setFailure(null) + },5000) setLoading(false); } } else { @@ -353,7 +376,7 @@ const BulkIssuance = () => { setFailure(response as string); setTimeout(() => { setFailure(null); - }, 4000); + }, 5000); } }; @@ -375,18 +398,6 @@ const BulkIssuance = () => {
- {(success || failure) && ( - { - setSuccess(null); - setFailure(null); - }} - viewButton={Boolean((success && success === "Issuance process completed") || (failure && failure === "Issuance process failed, please retry"))} - path={pathRoutes.organizations.Issuance.history} - /> - )}

@@ -423,6 +434,18 @@ const BulkIssuance = () => { View History

+ {(success || failure) && ( + { + setSuccess(null); + setFailure(null); + }} + viewButton={Boolean((success && success === "Issuance process completed") || (failure && failure === "Issuance process failed, please retry"))} + path={pathRoutes.organizations.Issuance.history} + /> + )}
@@ -755,7 +778,6 @@ const BulkIssuance = () => {