@@ -228,7 +236,6 @@ export const ResponsibilitiesCax = () => {
loading={loading}
/>
- {
switch (status) {
@@ -76,21 +76,20 @@ export const DragDrop = () => {
const { t } = useTranslation()
const dispatch = useDispatch()
- const { data: status, error: statusError } = useFetchApplicationsQuery()
+ const { data: status } = useFetchApplicationsQuery()
const obj = status[status.length - 1]
const applicationId = obj['applicationId']
const [fileError, setFileError] = useState('')
+ const [deleteDocResponse, setDeleteDocResponse] = useState({severity: SeverityType.ERROR, message: ''})
const currentActiveStep = useSelector(getCurrentStep)
- const { data: documents } = useFetchDocumentsQuery(applicationId)
+ const { data: documents, error: documentError } = useFetchDocumentsQuery(applicationId)
const [fetchDocumentByDocumentId] = useFetchDocumentByDocumentIdMutation()
const [updateStatus] = useUpdateStatusMutation()
const [updateDocument] = useUpdateDocumentMutation()
const [removeDocument] = useRemoveDocumentMutation()
- if (statusError) toast.error(toast.error(t('registration.statusApplicationError')))
-
const manageFileStatus = async (fileDetails: FileStatus) => {
switch (fileDetails.stats) {
case 'done':
@@ -133,14 +132,15 @@ export const DragDrop = () => {
}
const deleteDocumentFn = async (documentId) => {
+ setDeleteDocResponse({severity: SeverityType.ERROR, message: ''})
await removeDocument(documentId)
.unwrap()
.then(() => {
- toast.success(t('documentUpload.deleteSuccess'))
+ setDeleteDocResponse({severity: SeverityType.SUCCESS, message: t('documentUpload.deleteSuccess')})
})
.catch((errors: any) => {
console.log('errors', errors)
- toast.error(t('documentUpload.deleteError'))
+ setDeleteDocResponse({severity: SeverityType.ERROR, message: t('documentUpload.deleteError')})
})
}
@@ -148,7 +148,6 @@ export const DragDrop = () => {
documentId: string,
documentName: string
) => {
- //dispatch(fetchDocumentByDocumentId({ documentId, documentName }))
try {
const response = await fetchDocumentByDocumentId(documentId).unwrap()
const fileType = response.headers.get('content-type')
@@ -160,6 +159,14 @@ export const DragDrop = () => {
}
}
+ const renderSnackbar = () => {
+ let message = t('registration.apiError')
+ if(deleteDocResponse.message) message = deleteDocResponse.message
+ return (
+
+ )
+ }
+
return (
<>
@@ -213,11 +220,10 @@ export const DragDrop = () => {
{document.documentName}
- {`${getStatusText(document.status)} ${
- document.progress && document?.progress !== 100
+ {`${getStatusText(document.status)} ${document.progress && document?.progress !== 100
? document?.progress
: ''
- }`}
+ }`}
+ {(documentError || deleteDocResponse.message) &&
+ renderSnackbar()
+ }
{
const { t } = useTranslation()
const history = useHistory()
- const { data: status, error: statusError } = useFetchApplicationsQuery()
+ const { data: status } = useFetchApplicationsQuery()
const [updateInvitation] = useUpdateInvitationMutation()
const [updateStatus] = useUpdateStatusMutation()
- if (statusError) toast.error(toast.error(t('registration.statusApplicationError')))
-
useEffect(() => {
updateInvitation().unwrap()
}, [])
diff --git a/src/components/verifyRegistration.tsx b/src/components/verifyRegistration.tsx
index 258814b5..eb38f25f 100644
--- a/src/components/verifyRegistration.tsx
+++ b/src/components/verifyRegistration.tsx
@@ -25,7 +25,6 @@ import { FooterButton } from './footerButton'
import { useDispatch, useSelector } from 'react-redux'
import { useHistory } from 'react-router-dom'
import { useState } from 'react'
-import { ToastContainer, toast } from 'react-toastify'
import { useFetchApplicationsQuery } from '../state/features/application/applicationApiSlice'
import { useFetchDocumentsQuery } from '../state/features/applicationDocuments/applicationDocumentsApiSlice'
import {
@@ -36,6 +35,7 @@ import {
useFetchRegistrationDataQuery,
useUpdateRegistrationMutation,
} from '../state/features/applicationVerifyRegister/applicationVerifyRegisterApiSlice'
+import { Notify } from './Snackbar'
export const VerifyRegistration = () => {
const { t } = useTranslation()
@@ -45,17 +45,16 @@ export const VerifyRegistration = () => {
const currentActiveStep = useSelector(getCurrentStep)
const [loading, setLoading] = useState(false)
+ const [submitError, setSubmitError] = useState(false)
- const { data: status, error: statusError } = useFetchApplicationsQuery()
+ const { data: status } = useFetchApplicationsQuery()
const obj = status[status.length - 1]
const applicationId = obj['applicationId']
-
- if (statusError) toast.error(toast.error(t('registration.statusApplicationError')))
- const { data: registrationData } =
+ const { data: registrationData, error: dataError } =
useFetchRegistrationDataQuery(applicationId)
- const { data: documents } = useFetchDocumentsQuery(applicationId)
+ const { data: documents, error: documentsError } = useFetchDocumentsQuery(applicationId)
const [updateRegistration] = useUpdateRegistrationMutation()
const backClick = () => {
@@ -73,7 +72,7 @@ export const VerifyRegistration = () => {
.catch((errors: any) => {
console.log('errors', errors)
setLoading(false)
- toast.error(t('verifyRegistration.submitErrorMessage'))
+ setSubmitError(true)
})
}
@@ -91,6 +90,14 @@ export const VerifyRegistration = () => {
const hasDocuments = () => documents && documents.length > 0
+ const renderSnackbar = () => {
+ let message = t('registration.apiError')
+ if(submitError) message = t('verifyRegistration.submitErrorMessage')
+ return (
+
+ )
+ }
+
return (
<>
@@ -229,9 +236,10 @@ export const VerifyRegistration = () => {
-
-
+ {(dataError || documentsError || submitError) &&
+ renderSnackbar()
+ }