diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 67b4b3c7f..56f3eb6fb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,9 @@ name: Deploy on: push: - branches: develop-fixed-dco + branches: fix/minified-issue-on-various-components pull_request: - branches: develop-fixed-dco + branches: fix/minified-issue-on-various-components jobs: deploy: diff --git a/src/commonComponents/ConfirmationModal.tsx b/src/commonComponents/ConfirmationModal.tsx index 40a3e655a..63f1ca49c 100644 --- a/src/commonComponents/ConfirmationModal.tsx +++ b/src/commonComponents/ConfirmationModal.tsx @@ -8,10 +8,10 @@ interface IProps { onSuccess: (flag: boolean) => void; message: string | ReactElement |React.ReactNode; isProcessing: boolean; - success: string | null; - failure: string | null; - setFailure: (flag: string | null) => void; - setSuccess: (flag: string | null) => void; + success: string; + failure: string; + setFailure: (flag: string) => void; + setSuccess: (flag: string) => void; buttonTitles: string[]; loading:boolean; warning?:String @@ -83,7 +83,7 @@ const ConfirmationModal = ({ openModal, closeModal, onSuccess, message, isProces message={success} type={'success'} onAlertClose={() => { - setSuccess && setSuccess(null); + setSuccess && setSuccess(''); }} /> @@ -94,7 +94,7 @@ const ConfirmationModal = ({ openModal, closeModal, onSuccess, message, isProces message={failure} type={'failure'} onAlertClose={() => { - setFailure && setFailure(null); + setFailure && setFailure(''); }} /> diff --git a/src/commonComponents/DeviceDetailsCard.tsx b/src/commonComponents/DeviceDetailsCard.tsx index 85374e645..14fa6667c 100644 --- a/src/commonComponents/DeviceDetailsCard.tsx +++ b/src/commonComponents/DeviceDetailsCard.tsx @@ -7,14 +7,15 @@ import type { AxiosResponse } from "axios"; import { apiStatusCodes } from "../config/CommonConstant"; import { dateConversion } from "../utils/DateConversion"; import DateTooltip from "../components/Tooltip"; +import React from "react"; interface IResponseMessages {type: "error" | "success", message: string} const DeviceDetails = (props: { deviceFriendlyName: string, createDateTime: string, credentialID: string, refreshList: () => void, disableRevoke: boolean, responseMessages: (value: IResponseMessages) => void }) => { const [openModal, setOpenModal] = useState(false); const [openEditModel, setOpenEditModel] = useState(false) - const [editSuccess, setEditSuccess] = useState(null) - const [editfailure, setEditFailure] = useState(null) + const [editSuccess, setEditSuccess] = useState('') + const [editfailure, setEditFailure] = useState('') const handleDeleteModel = (flag: boolean) => { setOpenModal(flag) } diff --git a/src/commonComponents/EditPopup.tsx b/src/commonComponents/EditPopup.tsx index c37225817..7b29fb8dd 100644 --- a/src/commonComponents/EditPopup.tsx +++ b/src/commonComponents/EditPopup.tsx @@ -2,6 +2,7 @@ import { Button, Label, Modal } from 'flowbite-react'; import { Field, Form, Formik } from 'formik'; import * as yup from 'yup'; import { useRef } from 'react'; +import React from 'react'; const EditModal = (props: { openModal: boolean; diff --git a/src/commonComponents/PasseyAddDevicePopup.tsx b/src/commonComponents/PasseyAddDevicePopup.tsx index 8fd0cdb15..1f0e81fb0 100644 --- a/src/commonComponents/PasseyAddDevicePopup.tsx +++ b/src/commonComponents/PasseyAddDevicePopup.tsx @@ -20,9 +20,9 @@ const PasskeyAddDevice = (props: { registerWithPasskey: (flag: boolean) => Promise } ) => { - const [fidoUserError, setFidoUserError] = useState(null) + const [fidoUserError, setFidoUserError] = useState('') const [nextflag, setNextFlag] = useState(false) - const [success, setSuccess] = useState(null) + const [success, setSuccess] = useState('') const [passwordVisible, setPasswordVisible] = useState(false); const savePassword = async (values: PasswordValue) => { @@ -60,8 +60,8 @@ const PasskeyAddDevice = (props: { { - setSuccess(null) - setFidoUserError(null) + setSuccess('') + setFidoUserError('') } } > diff --git a/src/components/AddOrganizationInEcosystem.tsx b/src/components/AddOrganizationInEcosystem.tsx deleted file mode 100644 index ebfb9b1f1..000000000 --- a/src/components/AddOrganizationInEcosystem.tsx +++ /dev/null @@ -1,434 +0,0 @@ - -import type { AxiosResponse } from 'axios'; -import { useEffect, useState } from 'react'; -import type { ChangeEvent } from 'react'; -import type { TableData } from '../commonComponents/datatable/interface'; -import { apiStatusCodes, storageKeys } from '../config/CommonConstant'; -import { AlertComponent } from './AlertComponent'; -import BreadCrumbs from './BreadCrumbs'; -import { getFromLocalStorage, removeFromLocalStorage, setToLocalStorage } from '../api/Auth'; -import SortDataTable from '../commonComponents/datatable/SortDataTable'; -import { getOrganizations } from '../api/organization'; -import CustomAvatar from '../components/Avatar'; - -import type { Organisation } from '../components/organization/interfaces'; -import { Roles } from '../utils/enums/roles'; -import { Button } from 'flowbite-react'; -import { addOrganizationInEcosystem } from '../api/ecosystem'; -import { pathRoutes } from '../config/pathRoutes'; - - -const initialPageState = { - page: 1, - search: '', - sortingOrder: 'desc', - pageSize: 10, - role: Roles.OWNER -}; - -interface IErrorOrg { - id: string; - error: string; -} - -interface IErrorResponse { - statusCode: number; - message: string; - data?: { - orgId: string; - } - error?: string; -} - -interface ICurrentPage { - page: number; - pageSize: number; - search: string; - role: string; -} - -const AddOrganizationInEcosystem = () => { - const [listAPIParameter, setListAPIParameter] = useState(initialPageState); - const [errorList, setErrorList] = useState([]); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - const [success, setSuccess] = useState(null); - const [localOrgs, setLocalOrgs] = useState([]); - const [pageInfo, setPageInfo] = useState({ - totalItem: 0, - nextPage: 0, - lastPage: 0, - }); - const [totalPages, setTotalPages] = useState(0); - const [loader, setLoader] = useState(false); - const [organizationsList, setOrganizationsList] = useState | null>(null); - const [tableData, setTableData] = useState([]) - - const selectOrganization = async (item: Organisation, checked: boolean) => { - try { - const index = localOrgs?.length > 0 ? localOrgs.findIndex(ele => ele === item.id) : -1 - - if (index === -1) { - setLocalOrgs((prev: string[]) => [...prev, item.id]) - } else { - const updateLocalOrgs = [...localOrgs] - if (!checked) { - updateLocalOrgs.splice(index, 1); - } - setLocalOrgs(updateLocalOrgs) - } - } catch (error) { - throw new Error(`SELECTED ORGANIZATION:::${error}`); - } - } - - const generateTable = async (organizationsList: Organisation[] | null) => { - const id = await getFromLocalStorage(storageKeys.ECOSYSTEM_ID); - const connections = organizationsList && organizationsList?.length > 0 && organizationsList?.map((ele: Organisation) => { - const isChecked = localOrgs.includes(ele.id) - const alreadyAdded = ele.ecosystemOrgs?.some(item => item.ecosystemId === id) - const title = alreadyAdded ? "Already exists in the ecosystem" : "" - const error = errorList.find(item => item.id === ele.id)?.error || ele.error; - - return { - data: [ - { - data: ( -
- ) => { - const inputElement = event.target as HTMLInputElement; - - const updateOrgList: Organisation[] = organizationsList?.map(item => { - if (item.id === ele.id) { - selectOrganization(item, inputElement.checked) - return { - ...item, - checked: inputElement.checked - } - } - return item - }) - setOrganizationsList(updateOrgList) - }} - disabled={alreadyAdded} - defaultChecked={(ele.checked || isChecked) && !alreadyAdded} - className={`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded-lg dark:ring-offset-gray-800 dark:bg-gray-700 dark:border-gray-600 disabled:opacity-100 ${alreadyAdded ? "cursor-not-allowed" : "cursor-pointer"}`} - /> -
- ), - }, - { - data: ( -
-
- {(ele?.logoUrl) ? - : - } -
-
- {ele.name} -
-
- ) - }, - { data: (
{ele.id}
) }, - { - data: ( -
- { - ele?.roles?.length > 0 && ele?.roles?.map(item => ( - - {item} - - )) - } -
- ), - }, - { - data: ( -
- { -
{error || "-"}
- } -
- ), - } - ], - }; - }); - setTableData(connections); - } - - useEffect(() => { - generateTable(organizationsList); - }, [organizationsList, localOrgs]) - - const getOwnerOrganizations = async (currentPage: ICurrentPage) => { - setLoading(true); - const response = await getOrganizations( - currentPage.page, - currentPage.pageSize, - currentPage.search, - currentPage.role - ); - const { data } = response as AxiosResponse; - - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const totalPages = data?.data?.totalPages; - const orgList = data?.data?.organizations.map((userOrg: Organisation) => { - const roles: string[] = userOrg.userOrgRoles.map( - (role) => role.orgRole.name, - ); - userOrg.roles = roles; - return userOrg; - }); - setPageInfo({ - ...pageInfo, - totalItem: data?.data?.totalCount, - lastPage: data?.data?.totalPages, - nextPage: listAPIParameter?.page + 1 - }) - setOrganizationsList(orgList); - setTotalPages(totalPages); - } else { - setError(response as string); - } - setLoading(false); - }; - - const header = [ - { columnName: '', width: 'w-0.5' }, - { columnName: 'Organization' }, - { columnName: 'Id' }, - { columnName: 'Role(s)' }, - { columnName: 'Error' }, - ]; - - //onChange of Search input text - const searchInputChange = (e: ChangeEvent) => { - setListAPIParameter({ - ...listAPIParameter, - search: e.target.value, - page: 1, - }); - }; - - const refreshPage = () => { - setLocalOrgs([]); - getOwnerOrganizations(listAPIParameter); - }; - - const updateLocalOrgs = async () => { - const res = await getFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM) - const selectedOrg = res ? JSON.parse(res) : [] - setLocalOrgs(selectedOrg); - - const err = await getFromLocalStorage(storageKeys.ERROR_ORG_IN_ECOSYSTEM) - const errOrgs = err ? JSON.parse(err) : [] - setErrorList(errOrgs); - } - - const handleAddOrganization = async () => { - const orgId = (await getFromLocalStorage(storageKeys.ORG_ID)) || ''; - const ecosystemId = - (await getFromLocalStorage(storageKeys.ECOSYSTEM_ID)) || ''; - setLoader(true); - try { - const response = await addOrganizationInEcosystem( - localOrgs, - ecosystemId, - orgId, - ); - const { data } = response as AxiosResponse; - setLoader(false); - setLocalOrgs([]); - setErrorList([]); - setOrganizationsList( - (prevState) => - prevState?.map((org) => ({ ...org, checked: false, error: '' })) || - [], - ); - - switch (data?.statusCode) { - case apiStatusCodes.API_STATUS_CREATED: - await removeFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM); - setSuccess(data.message); - setTimeout(() => { - window.location.href = pathRoutes.ecosystem.dashboard; - }, 1000); - break; - - case apiStatusCodes.API_STATUS_PARTIALLY_COMPLETED: - await removeFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM); - const errors = data?.data?.filter( - (item: IErrorResponse) => - item.statusCode !== apiStatusCodes.API_STATUS_CREATED, - ); - const errorData = errors.map((item: IErrorResponse) => ({ - id: item?.data?.orgId || '', - error: item.message, - })); - await setToLocalStorage( - storageKeys.ERROR_ORG_IN_ECOSYSTEM, - JSON.stringify(errorData), - ); - setErrorList(errorData); - setLocalOrgs([]); - - const updateWithError = - organizationsList && organizationsList?.length > 0 - ? organizationsList?.map((item) => ({ - ...item, - error: - errors?.find( - (ele: IErrorResponse) => ele?.data?.orgId === item.id, - )?.message || '', - checked: false - })) - : []; - setSuccess(data?.message); - setOrganizationsList(updateWithError); - setErrorList([]); - break; - default: - setError((response as string) || data?.message); - setErrorList([]); - setLocalOrgs([]); - setOrganizationsList( - (prevState) => - prevState?.map((org) => ({ - ...org, - checked: false, - error: '', - })) || [], - ); - - break; - } - } catch (error) { - setError(error.message as string); - setLoader(false); - setLocalOrgs([]); - setErrorList([]); - setOrganizationsList( - (prevState) => - prevState?.map((org) => ({ ...org, checked: false, error: '' })) || - [], - ); - } - }; - - useEffect(() => { - const clearLocalStorage = async () => { - await removeFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM); - await removeFromLocalStorage(storageKeys.ERROR_ORG_IN_ECOSYSTEM); - }; - clearLocalStorage(); - refreshPage(); - - }, []); - - useEffect(() => { - getOwnerOrganizations(listAPIParameter); - updateLocalOrgs() - }, [listAPIParameter]); - - useEffect(() => { - updateLocalOrgs(); - (async () => { - await removeFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM); - await removeFromLocalStorage(storageKeys.ERROR_ORG_IN_ECOSYSTEM); - })() - }, []) - - useEffect(() => { - (async () => { - await setToLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM, JSON.stringify(localOrgs)) - })() - }, [localOrgs]) - - return ( -
- -
-

- Add Organizations -

-
- {(error || success) && ( - { - setError(null); - setSuccess(null); - }} - /> - )} - { - setListAPIParameter((prevState) => ({ - ...prevState, - page, - })); - }} - totalPages={totalPages} - pageInfo={pageInfo} - isHeader={true} - isSearch={true} - isRefresh={true} - isSort={false} - message={'No Organizations'} - discription={"You don't have any Organization to add"} - itemPerPage={listAPIParameter.pageSize} - > -
- -
-
- ); -}; - -export default AddOrganizationInEcosystem; diff --git a/src/components/AlertComponent/index.tsx b/src/components/AlertComponent/index.tsx index 7552a232a..e48a3c734 100644 --- a/src/components/AlertComponent/index.tsx +++ b/src/components/AlertComponent/index.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import type { IAlertComponent } from './interface'; export const AlertComponent = ({ @@ -22,7 +21,7 @@ export const AlertComponent = ({ }; return ( - message !== null && ( + message && (
{ const [loading, setLoading] = useState(false); - const [success, setSuccess] = useState(null); - const [error, setError] = useState(null); + const [success, setSuccess] = useState(''); + const [error, setError] = useState(''); const [passwordVisibility, setPasswordVisibility] = useState({ currentPassword: false, newPassword: false, @@ -78,8 +78,8 @@ const KeyClockResetPassword = (props: IProps) => { message={ success ?? error} type={success ? 'success' : 'failure'} onAlertClose={() => { - setError(null); - setSuccess(null); + setError(''); + setSuccess(''); }} /> { onSubmit={(values: IValues) => submitUpdatePassword(values)} > {(formikHandlers): JSX.Element => ( + <>
@@ -241,6 +242,8 @@ const KeyClockResetPassword = (props: IProps) => {
+ + )} diff --git a/src/components/Authentication/ResetPassword.tsx b/src/components/Authentication/ResetPassword.tsx index 64bbba5b5..014452ef4 100644 --- a/src/components/Authentication/ResetPassword.tsx +++ b/src/components/Authentication/ResetPassword.tsx @@ -59,7 +59,7 @@ const EyeIconInvisible = () => ( const ResetPassword = () => { const [loading, setLoading] = useState(false); - const [erroMsg, setErrMsg] = useState(null); + const [erroMsg, setErrMsg] = useState(''); const [message, setMessage] = useState(''); const [passwordVisible, setPasswordVisible] = useState(false); const [confirmPasswordVisible, setConfirmPasswordVisible] = useState(false); @@ -138,7 +138,7 @@ const ResetPassword = () => { {(message || erroMsg) && ( setErrMsg(null)} + onDismiss={() => setErrMsg('')} >

{message || erroMsg}

diff --git a/src/components/Authentication/SignInUser.tsx b/src/components/Authentication/SignInUser.tsx index a3fc01fa4..72e6d2185 100644 --- a/src/components/Authentication/SignInUser.tsx +++ b/src/components/Authentication/SignInUser.tsx @@ -13,22 +13,21 @@ import { envConfig } from '../../config/envConfig'; import { validEmail } from '../../utils/TextTransform'; interface emailValue { - email: string | null; + email: string; } const resetPasswordSuccess = '?isPasswordSet=true'; const SignInUser = () => { - const [email, setEmail] = useState(null); - const [fidoUserError, setFidoUserError] = useState(''); - const [success, setSuccess] = useState(null); - const [failure, setFailur] = useState(null); + const [email, setEmail] = useState(); + const [success, setSuccess] = useState(''); + const [failure, setFailur] = useState(''); const [loading, setLoading] = useState(false); const [currentComponent, setCurrentComponent] = useState('email'); const [isEmailValid, setIsEmailValid] = useState(false); const [isPasskeySuccess, setIsPasskeySuccess] = useState(false); - const [userLoginEmail, setUserLoginEmail] = useState(null); - const nextButtonRef = useRef(null); + const [userLoginEmail, setUserLoginEmail] = useState(''); + const nextButtonRef = useRef(); const successMessage = `Congratulations!! 🎉 You have successfully registered on ${envConfig.PLATFORM_DATA.name} 🚀` @@ -133,14 +132,14 @@ const SignInUser = () => {
- {(success || failure || fidoUserError) && ( + {(success || failure) && ( setSuccess(null)} + onDismiss={() => setSuccess('')} > -

{success || failure || fidoUserError}

+

{success || failure}

)} diff --git a/src/components/Authentication/SignInUserPasskey.tsx b/src/components/Authentication/SignInUserPasskey.tsx index f1aca8a2a..6e5042ea8 100644 --- a/src/components/Authentication/SignInUserPasskey.tsx +++ b/src/components/Authentication/SignInUserPasskey.tsx @@ -32,8 +32,8 @@ const SignInUserPasskey = (signInUserProps: signInUserProps) => { const [showSignInUserPassword, setShowSignInUserPassword] = useState(false); const [fidoLoader, setFidoLoader] = useState(false); const [fidoUserError, setFidoUserError] = useState(''); - const [failure, setFailure] = useState(null); - const [success, setSuccess] = useState(null); + const [failure, setFailure] = useState(''); + const [success, setSuccess] = useState(''); const [isDevice, setIsDevice] = useState(false); const handleSvgClick = () => { @@ -202,8 +202,8 @@ const SignInUserPasskey = (signInUserProps: signInUserProps) => { className='mb-4' color={success ? 'success' : 'failure'} onDismiss={() => { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); setFidoUserError(''); }} > diff --git a/src/components/Authentication/SignInUserPassword.tsx b/src/components/Authentication/SignInUserPassword.tsx index dec3d7768..542825ebd 100644 --- a/src/components/Authentication/SignInUserPassword.tsx +++ b/src/components/Authentication/SignInUserPassword.tsx @@ -34,8 +34,8 @@ interface SignInUser3Props { const SignInUserPassword = (signInUserProps: SignInUser3Props) => { const [email, setEmail] = useState(signInUserProps?.email); const [fidoUserError, setFidoUserError] = useState(''); - const [success, setSuccess] = useState(null); - const [failure, setFailure] = useState(null); + const [success, setSuccess] = useState(''); + const [failure, setFailure] = useState(''); const [isForgotPassLoading, setForgotPassLoading] = useState(false); const [loading, setLoading] = useState(false); const [currentComponent, setCurrentComponent] = useState('email'); @@ -174,8 +174,8 @@ const SignInUserPassword = (signInUserProps: SignInUser3Props) => { className="mb-4" color={success ? 'success' : 'failure'} onDismiss={() => { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); }} > diff --git a/src/components/Authentication/SignUpUser.tsx b/src/components/Authentication/SignUpUser.tsx index 41df2bcfc..80cdae7d3 100644 --- a/src/components/Authentication/SignUpUser.tsx +++ b/src/components/Authentication/SignUpUser.tsx @@ -26,7 +26,7 @@ const SignUpUser = () => { const [loading, setLoading] = useState(false) const [verifyLoader, setVerifyLoader] = useState(false) - const [erroMsg, setErrMsg] = useState(null) + const [erroMsg, setErrMsg] = useState('') const [verificationSuccess, setVerificationSuccess] = useState('') const [email, setEmail] = useState('') const [nextflag, setNextFlag] = useState(false) @@ -119,7 +119,7 @@ const SignUpUser = () => { { - setErrMsg(null); + setErrMsg(''); setVerificationSuccess(''); }} > diff --git a/src/components/Authentication/SignUpUserPasskey.tsx b/src/components/Authentication/SignUpUserPasskey.tsx index 18e616501..0c3e971d6 100644 --- a/src/components/Authentication/SignUpUserPasskey.tsx +++ b/src/components/Authentication/SignUpUserPasskey.tsx @@ -27,10 +27,10 @@ interface passwordValues { const SignUpUserPasskey = ({ email, firstName, lastName }: { email: string, firstName: string; lastName: string }) => { const [loading, setLoading] = useState(false) - const [erroMsg, setErrMsg] = useState(null) + const [erroMsg, setErrMsg] = useState('') const [verificationSuccess, setVerificationSuccess] = useState('') - const [addSuccess, setAddSuccess] = useState(null) - const [addfailure, setAddFailure] = useState(null) + const [addSuccess, setAddSuccess] = useState('') + const [addfailure, setAddFailure] = useState('') const [emailAutoFill, setEmailAutoFill] = useState('') const [fidoError, setFidoError] = useState("") const [currentComponent, setCurrentComponent] = useState('email'); @@ -205,7 +205,7 @@ const SignUpUserPasskey = ({ email, firstName, lastName }: { email: string, firs { - setAddSuccess(null) + setAddSuccess('') setFidoError('') setErrMsg('') }} diff --git a/src/components/Authentication/SignUpUserPassword.tsx b/src/components/Authentication/SignUpUserPassword.tsx index b0257fb8a..4f4a5a2d9 100644 --- a/src/components/Authentication/SignUpUserPassword.tsx +++ b/src/components/Authentication/SignUpUserPassword.tsx @@ -39,7 +39,7 @@ const SignUpUserPassword = ({ lastName: string; }) => { const [loading, setLoading] = useState(false); - const [erroMsg, setErrMsg] = useState(null); + const [erroMsg, setErrMsg] = useState(''); const [verificationSuccess] = useState(''); const [passwordVisible, setPasswordVisible] = useState(false); const [confirmPasswordVisible, setConfirmPasswordVisible] = useState(false); @@ -116,7 +116,7 @@ const SignUpUserPassword = ({ {(verificationSuccess || erroMsg) && ( setErrMsg(null)} + onDismiss={() => setErrMsg('')} >

{verificationSuccess || erroMsg}

diff --git a/src/components/ConnectionsList/index.tsx b/src/components/ConnectionsList/index.tsx index eadaaf2c3..978dc92b4 100644 --- a/src/components/ConnectionsList/index.tsx +++ b/src/components/ConnectionsList/index.tsx @@ -16,6 +16,7 @@ import { getFromLocalStorage } from '../../api/Auth'; import { getOrgDetails } from '../../config/ecosystem'; import type { IConnectionList } from '../../components/Issuance/interface'; import SortDataTable from '../../commonComponents/datatable/SortDataTable'; +import React from 'react'; const initialPageState = { itemPerPage: 10, @@ -29,7 +30,7 @@ const ConnectionList = () => { const [listAPIParameter, setListAPIParameter] = useState(initialPageState); const [connectionList, setConnectionList] = useState([]); const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const [totalItem, setTotalItem] = useState(0); const [pageInfo, setPageInfo] = useState({ totalItem: '', @@ -80,7 +81,7 @@ const ConnectionList = () => { }; }); setConnectionList(connections); - setError(null); + setError(''); } else { setConnectionList([]); } @@ -143,7 +144,7 @@ const ConnectionList = () => { message={error} type={'failure'} onAlertClose={() => { - setError(null); + setError(''); }} /> )} diff --git a/src/components/CreateOrgModal/index.tsx b/src/components/CreateOrgModal/index.tsx index 291c52798..10f5bebbc 100644 --- a/src/components/CreateOrgModal/index.tsx +++ b/src/components/CreateOrgModal/index.tsx @@ -50,7 +50,7 @@ const CreateOrgModal = (props: IProps) => { name: '', description: '', }); - const [errMsg, setErrMsg] = useState(null); + const [errMsg, setErrMsg] = useState(''); const [imgError, setImgError] = useState(''); @@ -198,7 +198,7 @@ const CreateOrgModal = (props: IProps) => { }); props.setOpenModal(false); setImgError(' ') - setErrMsg(null); + setErrMsg(''); }} > Create {popupName} @@ -207,7 +207,7 @@ const CreateOrgModal = (props: IProps) => { message={errMsg} type={'failure'} onAlertClose={() => { - setErrMsg(null); + setErrMsg(''); }} /> diff --git a/src/components/Issuance/BulkIssuance.tsx b/src/components/Issuance/BulkIssuance.tsx index 9133b77ab..f2fd58317 100644 --- a/src/components/Issuance/BulkIssuance.tsx +++ b/src/components/Issuance/BulkIssuance.tsx @@ -40,8 +40,8 @@ const BulkIssuance = () => { const [openModal, setOpenModal] = useState(false); const [searchText, setSearchText] = useState(''); const [uploadMessage, setUploadMessage] = useState(null) - const [success, setSuccess] = useState(null); - const [failure, setFailure] = useState(null); + const [success, setSuccess] = useState(''); + const [failure, setFailure] = useState(''); const [mounted, setMounted] = useState(false) const [schemaType, setSchemaType]= useState(); const [selectedTemplate, setSelectedTemplate] = useState(); @@ -139,8 +139,8 @@ const BulkIssuance = () => { setCredentialOptionsData(dropDownOptions); } else { setUploadMessage({message: response as string, type: "failure"}); - setSuccess(null) - setFailure(null) + setSuccess('') + setFailure('') } setLoading(false); } @@ -173,15 +173,15 @@ const BulkIssuance = () => { setCredentialOptionsData(dropDownOptions); } else { setUploadMessage({message: response as string, type: "failure"}); - setSuccess(null) - setFailure(null) + setSuccess('') + setFailure('') } setLoading(false); } } catch (error) { setUploadMessage({ message: (error as Error).message, type: "failure" }); - setSuccess(null) - setFailure(null) + setSuccess('') + setFailure('') } }; @@ -230,7 +230,7 @@ const BulkIssuance = () => { downloadFile(fileUrl, 'downloadedFile.csv'); setSuccess('File downloaded successfully'); setTimeout(()=>{ - setSuccess(null) + setSuccess('') },5000) setProcess(false); } else { @@ -238,24 +238,24 @@ const BulkIssuance = () => { setTimeout(()=>{ setUploadMessage(null) },5000) - setSuccess(null) - setFailure(null) + setSuccess('') + setFailure('') } } else { setUploadMessage({message: 'API request was not successful', type: "failure"}); setTimeout(()=>{ setUploadMessage(null) },5000) - setSuccess(null) - setFailure(null) + setSuccess('') + setFailure('') } } catch (error) { setUploadMessage({message: error as string, type: "failure"}); setTimeout(()=>{ setUploadMessage(null) },5000) - setSuccess(null) - setFailure(null) + setSuccess('') + setFailure('') } } @@ -289,7 +289,7 @@ const BulkIssuance = () => { useEffect(() => { SOCKET.emit('bulk-connection') SOCKET.on('bulk-issuance-process-completed', () => { - setSuccess(null) + setSuccess('') console.log(`bulk-issuance-process-completed`); toast.success('Issuance process completed', { position: 'top-right', @@ -304,7 +304,7 @@ const BulkIssuance = () => { }); SOCKET.on('error-in-bulk-issuance-process', () => { - setFailure(null) + setFailure('') console.log(`error-in-bulk-issuance-process-initiated`); toast.error('Issuance process failed. Please retry', { position: 'top-right', @@ -328,8 +328,8 @@ const BulkIssuance = () => { setTimeout(()=>{ setUploadMessage(null) },5000) - setSuccess(null) - setFailure(null) + setSuccess('') + setFailure('') return; } try { @@ -366,8 +366,8 @@ const BulkIssuance = () => { setTimeout(()=>{ setUploadMessage(null) },5000) - setSuccess(null) - setFailure(null) + setSuccess('') + setFailure('') } setLoading(false); } catch (err) { @@ -469,7 +469,7 @@ const BulkIssuance = () => { const handleReset = () => { handleDiscardFile(); setCredentialSelected(null); - setSuccess(null); + setSuccess(''); onClear() }; const handleResetForConfirm = () => { @@ -493,7 +493,7 @@ const BulkIssuance = () => { } else { setFailure(response as string); setTimeout(()=>{ - setFailure(null) + setFailure('') },5000) setLoading(false); } @@ -501,7 +501,7 @@ const BulkIssuance = () => { setLoading(false); setFailure(response as string); setTimeout(() => { - setFailure(null); + setFailure(''); }, 5000); } }; @@ -578,8 +578,8 @@ const BulkIssuance = () => { message={success ?? failure} type={success ? 'success' : 'failure'} onAlertClose={() => { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); }} viewButton={Boolean((success && success === "Issuance process completed") || (failure && failure === "Issuance process failed, please retry"))} path={pathRoutes.organizations.Issuance.history} diff --git a/src/components/Issuance/ConnectionList.tsx b/src/components/Issuance/ConnectionList.tsx index a0d60ee9c..1c7af8a6d 100644 --- a/src/components/Issuance/ConnectionList.tsx +++ b/src/components/Issuance/ConnectionList.tsx @@ -43,7 +43,7 @@ const ConnectionList = (props: { const [loading, setLoading] = useState(false); const [totalItem, setTotalItem] = useState(0); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const [pageInfo, setPageInfo] = useState({ totalItem: '', nextPage: '', @@ -167,7 +167,7 @@ const ConnectionList = (props: { lastPage: lastPage, }); setConnectionList(data?.data?.data); - setError(null); + setError(''); } else { setConnectionList([]); } @@ -273,7 +273,7 @@ const ConnectionList = (props: { message={error} type={'failure'} onAlertClose={() => { - setError(null); + setError(''); }} /> { const [schemaState, setSchemaState] = useState({ @@ -25,7 +26,7 @@ const CredDefSelection = () => { }); const [loading, setLoading] = useState(true); const [schemaLoader, setSchemaLoader] = useState(true); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const [credDefList, setCredDefList] = useState([]); const [schemaDetailsState, setSchemaDetailsState] = useState({ schemaId: '', @@ -206,7 +207,7 @@ const CredDefSelection = () => { message={error} type={'failure'} onAlertClose={() => { - setError(null); + setError(''); }} /> { const [batchName, setBatchName] = useState(''); const [openResetModal, setOpenResetModal] = useState(false); const [attributes, setAttributes] = useState([]); - const [success, setSuccess] = useState(null); - const [failure, setFailure] = useState(null); + const [success, setSuccess] = useState(''); + const [failure, setFailure] = useState(''); const [isEditing, setIsEditing] = useState(false); const [issueLoader, setIssueLoader] = useState(false); const inputRef = useRef(null); @@ -136,8 +136,8 @@ const EmailIssuance = () => { setCredentialOptions(options); } else { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); } setLoading(false); } @@ -166,8 +166,8 @@ const EmailIssuance = () => { })); setCredentialOptions(options); } else { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); } setLoading(false); } @@ -175,8 +175,8 @@ const EmailIssuance = () => { setCredentialOptions(options); } catch (error) { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); } }; @@ -294,7 +294,7 @@ const EmailIssuance = () => { setSuccess(data?.message); setOpenModal(false); setTimeout(() => { - setSuccess(null); + setSuccess(''); }, 3000); handleReset(); setTimeout(() => { @@ -312,7 +312,7 @@ const EmailIssuance = () => { setOpenModal(false); setIssueLoader(false); setTimeout(() => { - setFailure(null); + setFailure(''); }, 4000); } } @@ -378,8 +378,8 @@ const EmailIssuance = () => { message={success ?? failure} type={success ? 'success' : 'failure'} onAlertClose={() => { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); }} /> )} diff --git a/src/components/Issuance/History.tsx b/src/components/Issuance/History.tsx index 8dff2b4e3..30458ebe6 100644 --- a/src/components/Issuance/History.tsx +++ b/src/components/Issuance/History.tsx @@ -20,6 +20,7 @@ import { import { ToastContainer, toast } from 'react-toastify'; import SortDataTable from '../../commonComponents/datatable/SortDataTable'; import type { IConnectionListAPIParameter } from '../../api/connection'; +import React from 'react'; const HistoryBulkIssuance = () => { const initialPageState = { @@ -32,8 +33,8 @@ const HistoryBulkIssuance = () => { const [listAPIParameter, setListAPIParameter] = useState(initialPageState); const [connectionList, setConnectionList] = useState([]); const [loading, setLoading] = useState(true); - const [failure, setFailure] = useState(null); - const [success, setSuccess] = useState(null); + const [failure, setFailure] = useState(''); + const [success, setSuccess] = useState(''); const [totalItem, setTotalItem] = useState(0); const [pageInfo, setPageInfo] = useState({ totalItem: '', @@ -65,7 +66,7 @@ const HistoryBulkIssuance = () => { setLoading(false); setFailure(retryIssunace as string); setTimeout(() => { - setFailure(null); + setFailure(''); }, 4000); } }; @@ -81,7 +82,7 @@ const HistoryBulkIssuance = () => { useEffect(() => { SOCKET.emit('bulk-connection'); SOCKET.on('bulk-issuance-process-retry-completed', () => { - setSuccess(null); + setSuccess(''); console.log(`bulk-issuance-process-retry-completed`); toast.success('Issuance process completed', { position: 'top-right', @@ -97,7 +98,7 @@ const HistoryBulkIssuance = () => { }); SOCKET.on('error-in-bulk-issuance-retry-process', () => { - setFailure(null); + setFailure(''); console.log(`error-in-bulk-issuance-retry-process-initiated`); toast.error('Issuance process failed. Please retry', { position: 'top-right', @@ -313,8 +314,8 @@ const HistoryBulkIssuance = () => { message={success ?? failure} type={success ? 'success' : 'failure'} onAlertClose={() => { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); }} /> )} diff --git a/src/components/Issuance/HistoryDetails.tsx b/src/components/Issuance/HistoryDetails.tsx index 08409f0b3..2f605947f 100644 --- a/src/components/Issuance/HistoryDetails.tsx +++ b/src/components/Issuance/HistoryDetails.tsx @@ -12,6 +12,7 @@ import type { AxiosResponse } from 'axios'; import { BulkIssuanceStatus } from '../../common/enums'; import SortDataTable from '../../commonComponents/datatable/SortDataTable'; import type { IConnectionListAPIParameter } from '../../api/connection'; +import React from 'react'; interface IProps { requestId: string; @@ -29,7 +30,7 @@ const HistoryDetails = ({ requestId }: IProps) => { const [listAPIParameter, setListAPIParameter] = useState(initialPageState); const [historyList, setHistoryList] = useState([]); const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const [totalItem, setTotalItem] = useState(0); const [pageInfo, setPageInfo] = useState({ totalItem: '', @@ -162,7 +163,7 @@ const HistoryDetails = ({ requestId }: IProps) => { message={error} type={'failure'} onAlertClose={() => { - setError(null); + setError(''); }} /> diff --git a/src/components/Issuance/Issuance.tsx b/src/components/Issuance/Issuance.tsx index 2b8e283fc..d734fb17b 100644 --- a/src/components/Issuance/Issuance.tsx +++ b/src/components/Issuance/Issuance.tsx @@ -46,12 +46,12 @@ const IssueCred = () => { IssuanceFormPayload[] >([]); const [issuanceLoader, setIssuanceLoader] = useState(false); - const [failure, setFailure] = useState(null); + const [failure, setFailure] = useState(''); const [schemaAttributesDetails, setSchemaAttributesDetails] = useState< IAttribute[] >([]); - const [success, setSuccess] = useState(null); - const [error, setError] = useState(null); + const [success, setSuccess] = useState(''); + const [error, setError] = useState(''); const [w3cSchema, setW3CSchema]= useState(false); const [credentialType, setCredentialType] = useState(); const [schemaType, setSchemaType] = useState(); @@ -395,8 +395,8 @@ const getSelectedUsers = async (): Promise => { message={success ?? error} type={success ? 'success' : 'failure'} onAlertClose={() => { - setError(null); - setSuccess(null); + setError(''); + setSuccess(''); }} />

@@ -442,7 +442,7 @@ const getSelectedUsers = async (): Promise => {
{failure && (
- setFailure(null)}> + setFailure('')}>

{failure}

diff --git a/src/components/Issuance/IssuedCrdentials.tsx b/src/components/Issuance/IssuedCrdentials.tsx index 95ebd77c0..a039202c9 100644 --- a/src/components/Issuance/IssuedCrdentials.tsx +++ b/src/components/Issuance/IssuedCrdentials.tsx @@ -34,7 +34,7 @@ const initialPageState = { const CredentialList = () => { const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const [issuedCredList, setIssuedCredList] = useState([]); const [walletCreated, setWalletCreated] = useState(false); const [listAPIParameter, setListAPIParameter] = @@ -152,7 +152,7 @@ const CredentialList = () => { }, ); setIssuedCredList(credentialList); - setError(null); + setError(''); } else { setIssuedCredList([]); } @@ -280,7 +280,7 @@ const CredentialList = () => { message={error} type={'failure'} onAlertClose={() => { - setError(null); + setError(''); }} /> {!walletCreated && !loading ? ( diff --git a/src/components/Profile/AddPasskey.tsx b/src/components/Profile/AddPasskey.tsx index 0c5547d58..2d0dc5e2c 100644 --- a/src/components/Profile/AddPasskey.tsx +++ b/src/components/Profile/AddPasskey.tsx @@ -33,10 +33,10 @@ const AddPasskey = ({ responseMessages }: { responseMessages: (value: IResponse const [fidoLoader, setFidoLoader] = useState(true); const [OrgUserEmail, setOrgUserEmail] = useState(''); const [deviceList, setDeviceList] = useState([]); - const [addSuccess, setAddSuccess] = useState(null); - const [editSuccess, setEditSuccess] = useState(null); - const [editFailure, setEditFailure] = useState(null); - const [addfailure, setAddFailure] = useState(null); + const [addSuccess, setAddSuccess] = useState(''); + const [editSuccess, setEditSuccess] = useState(''); + const [editFailure, setEditFailure] = useState(''); + const [addfailure, setAddFailure] = useState(''); const [disableFlag, setDisableFlag] = useState(false); const [isDevice, setIsDevice] = useState(false); @@ -207,7 +207,7 @@ const AddPasskey = ({ responseMessages }: { responseMessages: (value: IResponse { - setAddSuccess(null); + setAddSuccess(''); setFidoError(''); setAddFailure(''); }} @@ -242,8 +242,8 @@ const AddPasskey = ({ responseMessages }: { responseMessages: (value: IResponse message={editSuccess ?? editFailure} type={editSuccess ? 'success' : 'error'} onAlertClose={() => { - setEditSuccess(null); - setEditFailure(null); + setEditSuccess(''); + setEditFailure(''); }} /> )} diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx index 8287afd8f..11f246f40 100644 --- a/src/components/Profile/EditUserProfile.tsx +++ b/src/components/Profile/EditUserProfile.tsx @@ -33,8 +33,8 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: const [loading, setLoading] = useState(false) const [isImageEmpty, setIsImageEmpty] = useState(true) - const [success, setSuccess] = useState(null) - const [failure, setFailure] = useState(null) + const [success, setSuccess] = useState('') + const [failure, setFailure] = useState('') const [initialProfileData, setInitialProfileData] = useState({ profileImg: userProfileInfo?.profileImg || "", @@ -209,8 +209,8 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: { - setSuccess(null) - setFailure(null) + setSuccess('') + setFailure('') }} > diff --git a/src/components/Profile/UserProfile.tsx b/src/components/Profile/UserProfile.tsx index b894c29d8..8d8f1f5d0 100644 --- a/src/components/Profile/UserProfile.tsx +++ b/src/components/Profile/UserProfile.tsx @@ -12,7 +12,7 @@ import EditUserProfile from './EditUserProfile'; const UserProfile = ({ noBreadcrumb }: { noBreadcrumb?: boolean }) => { const [isEditProfileOpen, setIsEditProfileOpen] = useState(false); - const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(null); + const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(); const fetchUserProfile = async () => { try { diff --git a/src/components/Resources/Schema/Create.tsx b/src/components/Resources/Schema/Create.tsx index 2f2634f56..a0b283a30 100644 --- a/src/components/Resources/Schema/Create.tsx +++ b/src/components/Resources/Schema/Create.tsx @@ -48,8 +48,8 @@ interface IPopup { } const CreateSchema = () => { - const [failure, setFailure] = useState(null); - const [success, setSuccess] = useState(null); + const [failure, setFailure] = useState(''); + const [success, setSuccess] = useState(''); const [isEcosystemData, setIsEcosystemData] = useState(); const [orgId, setOrgId] = useState(''); const [createLoader, setCreateLoader] = useState(false); @@ -166,7 +166,7 @@ const CreateSchema = () => { setCreateLoader(false); setLoading(true); setTimeout(() => { - setSuccess(null); + setSuccess(''); window.location.href = pathRoutes?.organizations?.schemas; }, 1500); setTimeout(() => { @@ -183,7 +183,7 @@ const CreateSchema = () => { setCreateLoader(false); setFailure(createSchema as string); setTimeout(() => { - setFailure(null); + setFailure(''); }, 2000); } setTimeout(() => { @@ -216,13 +216,13 @@ const CreateSchema = () => { window.location.href = `${envConfig.PUBLIC_ECOSYSTEM_FRONT_END_URL}${pathRoutes.organizations.createSchema}` setTimeout(() => { - setSuccess(null); + setSuccess(''); }, 2000); } else { setCreateLoader(false); setFailure(createSchema as string); setTimeout(() => { - setFailure(null); + setFailure(''); }, 2000); } setTimeout(() => { diff --git a/src/components/Resources/Schema/SchemasList.tsx b/src/components/Resources/Schema/SchemasList.tsx index e7edeb7a1..251cac626 100644 --- a/src/components/Resources/Schema/SchemasList.tsx +++ b/src/components/Resources/Schema/SchemasList.tsx @@ -41,7 +41,7 @@ const SchemaList = (props: { const verificationFlag = props.verificationFlag ?? false; const [schemaList, setSchemaList] = useState([]); - const [schemaListErr, setSchemaListErr] = useState(''); + const [schemaListErr, setSchemaListErr] = useState(''); const [loading, setLoading] = useState(true); const [allSchemaFlag, setAllSchemaFlag] = useState(false); const [orgId, setOrgId] = useState(''); diff --git a/src/components/Resources/Schema/ViewSchema.tsx b/src/components/Resources/Schema/ViewSchema.tsx index c52dacd19..b61bf5f4c 100644 --- a/src/components/Resources/Schema/ViewSchema.tsx +++ b/src/components/Resources/Schema/ViewSchema.tsx @@ -63,15 +63,15 @@ const initialPageState = { }; const ViewSchemas = ({ schemaId }: { schemaId: string }) => { - const [schemaDetails, setSchemaDetails] = useState(null); + const [schemaDetails, setSchemaDetails] = useState(); const [credDeffList, setCredDeffList] = useState([]); const [loading, setLoading] = useState(true); const [createloader, setCreateLoader] = useState(false); const [credDeffloader, setCredDeffloader] = useState(false); - const [success, setSuccess] = useState(null); - const [credDefListErr, setCredDefListErr] = useState(null); - const [schemaDetailErr, setSchemaDetailErr] = useState(null); - const [failure, setFailure] = useState(null); + const [success, setSuccess] = useState(''); + const [credDefListErr, setCredDefListErr] = useState(''); + const [schemaDetailErr, setSchemaDetailErr] = useState(''); + const [failure, setFailure] = useState(''); const [orgId, setOrgId] = useState(''); const [credDefAuto, setCredDefAuto] = useState(''); const [ledgerPlatformLoading, setLedgerPlatformLoading] = useState(false); @@ -438,8 +438,8 @@ const ViewSchemas = ({ schemaId }: { schemaId: string }) => { { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); }} > @@ -501,7 +501,7 @@ const ViewSchemas = ({ schemaId }: { schemaId: string }) => {
{schemaDetailErr && ( - setSchemaDetailErr(null)}> + setSchemaDetailErr('')}>

{schemaDetailErr}

diff --git a/src/components/Setting/index.tsx b/src/components/Setting/index.tsx index 6b307cf87..1963facd2 100644 --- a/src/components/Setting/index.tsx +++ b/src/components/Setting/index.tsx @@ -16,14 +16,14 @@ import { EmptyListMessage } from '../EmptyListComponent'; const Index = () => { const [loading, setLoading] = useState(true); - const [clientId, setClientId] = useState(null); - const [clientSecret, setClientSecret] = useState(null); - const [success, setSuccess] = useState(null); - const [failure, setFailure] = useState(null); - const [warning, setWarning] = useState(null); + const [clientId, setClientId] = useState(''); + const [clientSecret, setClientSecret] = useState(''); + const [success, setSuccess] = useState(''); + const [failure, setFailure] = useState(''); + const [warning, setWarning] = useState(''); const [hideCopy, setHideCopy] = useState(true); const [userRoles, setUserRoles] = useState([]); - const [orgnizationId, setOrgnizationId] = useState(null); + const [orgnizationId, setOrgnizationId] = useState(''); const [buttonDisplay, setButtonDisplay] = useState(true); const [regenerate, setRegenerate] = useState(false); @@ -71,8 +71,8 @@ const Index = () => { setClientSecret(data?.data?.clientSecret); setButtonDisplay(true); } else { - setClientId(null); - setClientSecret(null); + setClientId(''); + setClientSecret(''); } } catch (error) { setFailure(error as string); @@ -111,8 +111,8 @@ const Index = () => { message={success ?? failure} type={success ? 'success' : 'failure'} onAlertClose={() => { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); }} /> )} @@ -186,8 +186,8 @@ const Index = () => { message={warning} type={'warning'} onAlertClose={() => { - setWarning(null); - setFailure(null); + setWarning(''); + setFailure(''); }} /> )} diff --git a/src/components/User/UserDashBoard.tsx b/src/components/User/UserDashBoard.tsx index 5c6f5b547..3e7a991a0 100644 --- a/src/components/User/UserDashBoard.tsx +++ b/src/components/User/UserDashBoard.tsx @@ -52,20 +52,17 @@ interface ICredDef { } const UserDashBoard = () => { - const [message, setMessage] = useState(''); - const [ecoMessage, setEcoMessage] = useState(''); + const [message, setMessage] = useState(''); + const [ecoMessage, setEcoMessage] = useState(''); const [viewButton, setViewButton] = useState(false); - const [error, setError] = useState(''); + const [error, setError] = useState(''); const [currentPage, setCurrentPage] = useState(initialPageState); - const [organizationsList, setOrganizationList] = - useState | null>(null); + const [organizationsList, setOrganizationList] = useState([]); - const [activityList, setActivityList] = useState | null>( - null, - ); + const [activityList, setActivityList] = useState([]); const [orgCount, setOrgCount] = useState(0); const [schemaCount, setSchemaCount] = useState(0); - const [schemaList, setSchemaList] = useState | null>(null); + const [schemaList, setSchemaList] = useState([]); const [schemaListAPIParameter, setSchemaListAPIParameter] = useState({ itemPerPage: itemPerPage, page: 1, diff --git a/src/components/Verification/ConnectionList.tsx b/src/components/Verification/ConnectionList.tsx index e40c1cb22..e47266b66 100644 --- a/src/components/Verification/ConnectionList.tsx +++ b/src/components/Verification/ConnectionList.tsx @@ -34,7 +34,7 @@ const ConnectionList = (props: { const [listAPIParameter, setListAPIParameter] = useState(initialPageState); const [totalItem, setTotalItem] = useState(0); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const [pageInfo, setPageInfo] = useState({ totalItem: '', nextPage: '', @@ -134,7 +134,7 @@ const ConnectionList = (props: { ); setConnectionList(connections); - setError(null); + setError(''); } else { setConnectionList([]); } @@ -216,7 +216,7 @@ const ConnectionList = (props: { message={error} type={'failure'} onAlertClose={() => { - setError(null); + setError(''); }} /> { const [schemaState, setSchemaState] = useState({ schemaName: '', version: '' }) const [loading, setLoading] = useState(true) const [schemaLoader, setSchemaLoader] = useState(true) - const [error, setError] = useState(null) + const [error, setError] = useState('') const [credDefList, setCredDefList] = useState([]) const [schemaDetailsState, setSchemaDetailsState] = useState({ schemaId: '', issuerDid: '', attributes: [], createdDateTime: '' }) @@ -155,7 +156,7 @@ const CredDefSelection = () => { message={error} type={'failure'} onAlertClose={() => { - setError(null) + setError('') }} /> { }}> diff --git a/src/components/Verification/EmailAttributesSelection.tsx b/src/components/Verification/EmailAttributesSelection.tsx index 070397062..4435316cc 100644 --- a/src/components/Verification/EmailAttributesSelection.tsx +++ b/src/components/Verification/EmailAttributesSelection.tsx @@ -15,15 +15,16 @@ import CustomCheckbox from '../../commonComponents/CustomCheckbox'; import { getOrganizationById } from '../../api/organization'; import type { AxiosResponse } from 'axios'; import { DidMethod } from '../../common/enums'; +import React from 'react'; const EmailAttributesSelection = () => { const [attributeList, setAttributeList] = useState([]); - const [proofReqSuccess, setProofReqSuccess] = useState(null); - const [errMsg, setErrMsg] = useState(null); + const [proofReqSuccess, setProofReqSuccess] = useState(''); + const [errMsg, setErrMsg] = useState(''); const [display, setDisplay] = useState(false); const [loading, setLoading] = useState(true); - const [attributeData, setAttributeData] = useState( - null, + const [attributeData, setAttributeData] = useState( + [], ); const [w3cSchema, setW3cSchema] = useState(false); @@ -95,7 +96,7 @@ const EmailAttributesSelection = () => { const handleSubmit = () => { - setErrMsg(null); + setErrMsg(''); if (w3cSchema) { redirectToAppropriatePage(); @@ -358,8 +359,8 @@ const EmailAttributesSelection = () => { { - setProofReqSuccess(null); - setErrMsg(null); + setProofReqSuccess(''); + setErrMsg(''); }} > {proofReqSuccess ?? errMsg} diff --git a/src/components/Verification/EmailCredDefSelection.tsx b/src/components/Verification/EmailCredDefSelection.tsx index 9652e06fe..49561245e 100644 --- a/src/components/Verification/EmailCredDefSelection.tsx +++ b/src/components/Verification/EmailCredDefSelection.tsx @@ -17,7 +17,7 @@ import CustomCheckbox from "../../commonComponents/CustomCheckbox"; const EmailCredDefSelection = () => { const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const [credDefList, setCredDefList] = useState([]); const [searchValue, setSearchValue] = useState(''); const [selectedCredDefs, setSelectedCredDefs] = useState([]); @@ -166,7 +166,7 @@ const EmailCredDefSelection = () => { message={error} type={'failure'} onAlertClose={() => { - setError(null); + setError(''); }} /> )} diff --git a/src/components/Verification/EmailVerification.tsx b/src/components/Verification/EmailVerification.tsx index 76c0924fb..9317054fe 100644 --- a/src/components/Verification/EmailVerification.tsx +++ b/src/components/Verification/EmailVerification.tsx @@ -16,7 +16,7 @@ import React from 'react'; const EmailVerification = () => { const [loading, setLoading] = useState(false); - const [errorMessage, setErrorMessage] = useState(null); + const [errorMessage, setErrorMessage] = useState(''); const [emailInputs, setEmailInputs] = useState([{ value: '' }]); const [w3cSchema, setW3cSchema] = useState(false); @@ -61,7 +61,7 @@ const EmailVerification = () => { const handleSubmit = async (values: IEmailValues) => { setLoading(true); - setErrorMessage(null); + setErrorMessage(''); try { let payload; @@ -227,7 +227,7 @@ const EmailVerification = () => { message={errorMessage} type={errorMessage ? 'failure' : 'success'} onAlertClose={() => { - setErrorMessage(null); + setErrorMessage(''); }} /> )} diff --git a/src/components/Verification/Verification.tsx b/src/components/Verification/Verification.tsx index 0c4c420d7..a2f3b94e9 100644 --- a/src/components/Verification/Verification.tsx +++ b/src/components/Verification/Verification.tsx @@ -26,8 +26,8 @@ import { DidMethod, RequestType } from '../../common/enums'; const VerificationCred = () => { const [attributeList, setAttributeList] = useState([]); - const [proofReqSuccess, setProofReqSuccess] = useState(null); - const [errMsg, setErrMsg] = useState(null); + const [proofReqSuccess, setProofReqSuccess] = useState(''); + const [errMsg, setErrMsg] = useState(''); const [display, setDisplay] = useState(false); const [schemaDetails, setSchemaDetails] = useState({ schemaName: '', @@ -44,11 +44,11 @@ const VerificationCred = () => { }); const [w3cSchema, setW3CSchema] = useState(false); const [requestType, setRequestType] = useState(); - const [failure, setFailure] = useState(null); + const [failure, setFailure] = useState(''); const [loading, setLoading] = useState(true); const [requestLoader, setRequestLoader] = useState(false); - const [attributeData, setAttributeData] = useState( - null, + const [attributeData, setAttributeData] = useState( + [], ); useEffect(() => { @@ -541,8 +541,8 @@ const VerificationCred = () => { { - setProofReqSuccess(null); - setErrMsg(null); + setProofReqSuccess(''); + setErrMsg(''); }} > {proofReqSuccess || errMsg} diff --git a/src/components/Verification/VerificationCredentialList.tsx b/src/components/Verification/VerificationCredentialList.tsx index 145d79c4c..04ae45405 100644 --- a/src/components/Verification/VerificationCredentialList.tsx +++ b/src/components/Verification/VerificationCredentialList.tsx @@ -43,9 +43,10 @@ const VerificationCredentialList = () => { const [verificationList, setVerificationList] = useState([]); const [openModal, setOpenModal] = useState(false); const [requestId, setRequestId] = useState(''); - const [errMsg, setErrMsg] = useState(null); + const [errMsg, setErrMsg] = useState(''); const [proofReqSuccess, setProofReqSuccess] = useState(''); - const [userData, setUserData] = useState(null); + // FIXME:give initial state for userData + const [userData, setUserData] = useState(); const [view, setView] = useState(false); const [walletCreated, setWalletCreated] = useState(false); const [listAPIParameter, setListAPIParameter] = @@ -242,7 +243,7 @@ const VerificationCredentialList = () => { ); setVerificationList(credentialList); - setErrMsg(null); + setErrMsg(''); } else { setVerificationList([]); } @@ -384,7 +385,7 @@ const VerificationCredentialList = () => {
setErrMsg(null)} + onDismiss={() => setErrMsg('')} >

{proofReqSuccess || errMsg}

diff --git a/src/components/Verification/VerificationSchemasList.tsx b/src/components/Verification/VerificationSchemasList.tsx index 35a3d25cc..168c1deaa 100644 --- a/src/components/Verification/VerificationSchemasList.tsx +++ b/src/components/Verification/VerificationSchemasList.tsx @@ -22,7 +22,7 @@ import type { IAttributesDetails, ISchema, ISchemaData } from './interface'; const VerificationSchemasList = () => { const [schemasList, setSchemasList] = useState([]); - const [schemasDetailsErr, setSchemasDetailsErr] = useState(''); + const [schemasDetailsErr, setSchemasDetailsErr] = useState(''); const [loading, setLoading] = useState(true); const [allSchemasFlag, setAllSchemasFlag] = useState(false); const [schemasListParameter, setSchemasListParameter] = useState({ @@ -309,7 +309,7 @@ const VerificationSchemasList = () => {
{schemasDetailsErr && ( - setSchemasDetailsErr(null)}> + setSchemasDetailsErr('')}>

{schemasDetailsErr}

diff --git a/src/components/organization/Dashboard.tsx b/src/components/organization/Dashboard.tsx index b9b8560b1..31d04abde 100644 --- a/src/components/organization/Dashboard.tsx +++ b/src/components/organization/Dashboard.tsx @@ -17,6 +17,7 @@ import { Roles } from '../../utils/enums/roles'; import WalletSpinup from './walletCommonComponents/WalletSpinup'; import { envConfig } from '../../config/envConfig'; import { pathRoutes } from '../../config/pathRoutes'; +import React from 'react'; const initialPageState = { pageNumber: 1, @@ -26,20 +27,20 @@ const initialPageState = { const Dashboard = () => { - const [orgData, setOrgData] = useState(null); + // FIXME: initial state of setOrgData and setOrgDashboard + const [orgData, setOrgData] = useState(undefined); const [walletStatus, setWalletStatus] = useState(false); - const [orgDashboard, setOrgDashboard] = useState(null); + const [orgDashboard, setOrgDashboard] = useState(undefined); const [success, setSuccess] = useState(''); const [failure, setFailure] = useState(''); - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState(true); const [userRoles, setUserRoles] = useState([]); const [orgSuccess, setOrgSuccess] = useState(''); const [openModal, setOpenModal] = useState(false); const [currentPage, setCurrentPage] = useState(initialPageState); const [ecoCount, setEcoCount] = useState(0); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const [redirectToEndorsment, setRedirectToEndorsment] = useState(); - const [ecosystemUserRoles, setEcosystemUserRoles] = useState(''); @@ -162,7 +163,7 @@ const Dashboard = () => { setSuccess(''); setFailure(''); }, 3000); - }, [success !== null, failure !== null]); + }, [success !== '', failure !== '']); const setWalletSpinupStatus = (status: boolean) => { setSuccess('Wallet created successfully'); @@ -319,7 +320,7 @@ const Dashboard = () => { {(success || failure) && ( setFailure(null)} + onDismiss={() => setFailure('')} >

{success || failure}

diff --git a/src/components/organization/DeleteOrganization.tsx b/src/components/organization/DeleteOrganization.tsx index 75269fedc..df79aa1e8 100644 --- a/src/components/organization/DeleteOrganization.tsx +++ b/src/components/organization/DeleteOrganization.tsx @@ -26,11 +26,11 @@ import { EcosystemRoles } from "../../common/enums"; const DeleteOrganizations = () => { const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - const [organizationData, setOrganizationData] = useState(null); + const [error, setError] = useState(''); + const [organizationData, setOrganizationData] = useState(); const [deleteLoading, setDeleteLoading] = useState(false); const [isWalletPresent, setIsWalletPresent] = useState(false); - const [message, setMessage] = useState(null); + const [message, setMessage] = useState(''); const [showPopup, setShowPopup] = useState(false); const [deleteAction, setDeleteAction] = useState<() => void>(() => {}); const [confirmMessage, setConfirmMessage] = useState(''); @@ -302,8 +302,8 @@ const DeleteOrganizations = () => { message={message ?? error} type={message ? "success" : "failure"} onAlertClose={() => { - setMessage(null); - setError(null); + setMessage(''); + setError(''); }} /> diff --git a/src/components/organization/EditOrgdetailsModal.tsx b/src/components/organization/EditOrgdetailsModal.tsx index 3058e5594..94f1e8d16 100644 --- a/src/components/organization/EditOrgdetailsModal.tsx +++ b/src/components/organization/EditOrgdetailsModal.tsx @@ -56,7 +56,7 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { } }, [props.orgData, props.openModal]); - const [erroMsg, setErrMsg] = useState(null); + const [erroMsg, setErrMsg] = useState(''); const [imgError, setImgError] = useState(''); @@ -145,7 +145,7 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { website: props?.orgData?.website ?? '', }); props.setOpenModal(false); - setErrMsg(null); + setErrMsg(''); }} > Edit Organization @@ -154,7 +154,7 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { message={erroMsg} type={'failure'} onAlertClose={() => { - setErrMsg(null); + setErrMsg(''); }} /> { +const OrganizationDetails = ({ orgData }: { orgData: Organisation }) => { const { org_agents } = orgData as Organisation; const agentData: OrgAgent | null = org_agents.length > 0 ? org_agents[0] : null; const [loading, setLoading] = useState(true); - const [connectionData, setConnectionData] = useState(null); + const [connectionData, setConnectionData] = useState(); const createQrConnection = async () => { setLoading(true); diff --git a/src/components/organization/OrganizationsList.tsx b/src/components/organization/OrganizationsList.tsx index 810498810..33ea7a207 100644 --- a/src/components/organization/OrganizationsList.tsx +++ b/src/components/organization/OrganizationsList.tsx @@ -21,6 +21,7 @@ import { import { EmptyListMessage } from '../EmptyListComponent'; import CustomSpinner from '../CustomSpinner'; import CreateOrgModal from '../CreateOrgModal'; +import React from 'react'; const initialPageState = { pageNumber: 1, @@ -32,8 +33,8 @@ const initialPageState = { const OrganizationsList = () => { const [openModal, setOpenModal] = useState(false); const [loading, setLoading] = useState(true); - const [message, setMessage] = useState(null); - const [error, setError] = useState(null); + const [message, setMessage] = useState(''); + const [error, setError] = useState(''); const [currentPage, setCurrentPage] = useState(initialPageState); const onPageChange = (page: number) => { setCurrentPage({ @@ -43,8 +44,7 @@ const OrganizationsList = () => { }; const [searchText, setSearchText] = useState(''); - const [organizationsList, setOrganizationsList] = - useState | null>(null); + const [organizationsList, setOrganizationsList] =useState([]); const props = { openModal, setOpenModal }; @@ -53,6 +53,7 @@ const OrganizationsList = () => { }; const getAllOrganizations = async () => { + try { setLoading(true); const response = await getOrganizations( currentPage.pageNumber, @@ -78,10 +79,14 @@ const OrganizationsList = () => { totalCount: totalCount, }); } else { - setError(response as string); - } - setLoading(false); - }; + setError(data?.message || 'Unable to fetch organizations'); + } + } catch (err) { + setError('An error occurred while fetching organizations'); + } finally { + setLoading(false); + } +}; useEffect(() => { let getData: NodeJS.Timeout; @@ -232,8 +237,8 @@ const OrganizationsList = () => { /> ); } - return ( +
@@ -281,8 +286,8 @@ const OrganizationsList = () => { message={message || error} type={message ? 'success' : 'failure'} onAlertClose={() => { - setMessage(null); - setError(null); + setMessage(''); + setError(''); }} /> diff --git a/src/components/organization/PublicOrganizationDetails.tsx b/src/components/organization/PublicOrganizationDetails.tsx index 5b967d1ef..59b0b352c 100644 --- a/src/components/organization/PublicOrganizationDetails.tsx +++ b/src/components/organization/PublicOrganizationDetails.tsx @@ -12,9 +12,9 @@ import { Card } from "flowbite-react"; const PublicOrganizationDetails = ({ orgSlug }: { orgSlug: string }) => { - const [orgData, setOrgData] = useState(null); + const [orgData, setOrgData] = useState(); const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const getOrganizationData = async () => { setLoading(true); @@ -57,7 +57,7 @@ const PublicOrganizationDetails = ({ orgSlug }: { orgSlug: string }) => { message={error} type={'failure'} onAlertClose={() => { - setError(null); + setError(''); }} /> )} diff --git a/src/components/organization/configuration-settings/CreateDid.tsx b/src/components/organization/configuration-settings/CreateDid.tsx index 2171810db..6820a257d 100644 --- a/src/components/organization/configuration-settings/CreateDid.tsx +++ b/src/components/organization/configuration-settings/CreateDid.tsx @@ -16,6 +16,7 @@ import { getFromLocalStorage } from '../../../api/Auth'; import { ethers } from 'ethers'; import { envConfig } from '../../../config/envConfig'; import { CommonConstants, Network, DidMethod } from '../../../common/enums'; +import React from 'react'; interface IPolygonKeys { privateKey: string; @@ -26,17 +27,17 @@ interface IPolygonKeys { const CreateDIDModal = (props: EditOrgdetailsModalProps) => { const [loading, setLoading] = useState(false); const [isLoading, setIsLoading] = useState(false); - const [errMsg, setErrMsg] = useState(null); - const [successMsg, setSuccessMsg] = useState(null); + const [errMsg, setErrMsg] = useState(''); + const [successMsg, setSuccessMsg] = useState(''); const [seed, setSeed] = useState(''); const [generatedKeys, setGeneratedKeys] = useState(null); - const [ledgerValue, setLedgerValue] = useState(null); - const [method, setMethod] = useState(null); - const [networkValue, setNetworkValue] = useState(null); - const [completeDidMethodValue, setCompleteDidMethodValue] = useState(null); + const [ledgerValue, setLedgerValue] = useState(''); + const [method, setMethod] = useState(''); + const [networkValue, setNetworkValue] = useState(''); + const [completeDidMethodValue, setCompleteDidMethodValue] = useState(''); const [havePrivateKey, setHavePrivateKey] = useState(false); const [privateKeyValue, setPrivateKeyValue] = useState(''); - const [walletErrorMessage, setWalletErrorMessage] = useState(null); + const [walletErrorMessage, setWalletErrorMessage] = useState(''); const formikRef = useRef>(null); @@ -114,7 +115,7 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { if (parseFloat(etherBalance) < CommonConstants.BALANCELIMIT) { setWalletErrorMessage('You have insufficient funds.'); } else { - setWalletErrorMessage(null); + setWalletErrorMessage(''); } @@ -129,7 +130,7 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { if (privateKeyValue && privateKeyValue.length === 64) { checkBalance(privateKeyValue, Network.TESTNET); } else { - setWalletErrorMessage(null); + setWalletErrorMessage(''); } }, [privateKeyValue]); @@ -204,11 +205,11 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { useEffect(() => { if (havePrivateKey) { setPrivateKeyValue(''); - setWalletErrorMessage(null); + setWalletErrorMessage(''); setGeneratedKeys(null); } else { setPrivateKeyValue(''); - setWalletErrorMessage(null); + setWalletErrorMessage(''); } }, [havePrivateKey]); @@ -221,7 +222,7 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { { - setErrMsg(null); + setErrMsg(''); setGeneratedKeys(null); setHavePrivateKey(false); props.setOpenModal(false); @@ -234,8 +235,8 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { message={successMsg ?? errMsg} type={successMsg ? 'success' : 'failure'} onAlertClose={() => { - setErrMsg(null); - setSuccessMsg(null); + setErrMsg(''); + setSuccessMsg(''); }} /> { value={formikHandlers.values.privatekey} onChange={(e) => { formikHandlers.setFieldValue('privatekey', e.target.value); - setWalletErrorMessage(null); + setWalletErrorMessage(''); checkBalance(e.target.value, Network.TESTNET); }} placeholder="Enter private key" /> diff --git a/src/components/organization/configuration-settings/DidList.tsx b/src/components/organization/configuration-settings/DidList.tsx index 1c7485bad..a48f3558b 100644 --- a/src/components/organization/configuration-settings/DidList.tsx +++ b/src/components/organization/configuration-settings/DidList.tsx @@ -12,9 +12,9 @@ import { Roles } from "../../../utils/enums/roles" const DIDList = () => { const [didList, setDidList] = useState([]); - const [showPopup, setShowPopup] = useState(false); - const [erroMsg, setErrMsg] = useState(null); - const [successMsg, setSuccessMsg] = useState(null); + const [showPopup, setShowPopup] = useState(false); + const [erroMsg, setErrMsg] = useState(''); + const [successMsg, setSuccessMsg] = useState(''); const [userRoles, setUserRoles] = useState([]); const setPrimaryDid = async (id: string, did: string) => { try { @@ -71,8 +71,8 @@ const DIDList = () => { message={successMsg ?? erroMsg} type={successMsg ? 'success' : 'failure'} onAlertClose={() => { - setErrMsg(null); - setSuccessMsg(null); + setErrMsg(''); + setSuccessMsg(''); }} />
diff --git a/src/components/organization/interfaces/index.ts b/src/components/organization/interfaces/index.ts index e0b7b526c..1074e043f 100644 --- a/src/components/organization/interfaces/index.ts +++ b/src/components/organization/interfaces/index.ts @@ -174,12 +174,13 @@ export interface ILogoImage { imagePreviewUrl: string | ArrayBuffer | null | File; fileName: string; } +// FIXME: export interface EditOrgdetailsModalProps { openModal: boolean; setMessage: (message: string) => void; setOpenModal: (flag: boolean) => void; onEditSucess?: () => void; - orgData: Organisation | null; + orgData: Organisation; } export interface IOrgInfo { name: string; diff --git a/src/components/organization/invitations/Invitations.tsx b/src/components/organization/invitations/Invitations.tsx index 42edd75df..2e5cadf47 100644 --- a/src/components/organization/invitations/Invitations.tsx +++ b/src/components/organization/invitations/Invitations.tsx @@ -36,9 +36,9 @@ const Invitations = () => { const [loading, setLoading] = useState(false) const [deleteLoading, setDeleteLoading] = useState(false) const [selectedInvitation, setSelectedInvitation] = useState('') - const [message, setMessage] = useState(null) + const [message, setMessage] = useState('') const [showPopup, setShowPopup] = useState(false) - const [error, setError] = useState(null) + const [error, setError] = useState('') const [roles, setRoles] = useState([]); const [currentPage, setCurrentPage] = useState(initialPageState); @@ -49,7 +49,7 @@ const Invitations = () => { }) }; const [searchText, setSearchText] = useState(""); - const [invitationsList, setInvitationsList] = useState | null>(null) + const [invitationsList, setInvitationsList] = useState([]) const props = { openModal, setOpenModal }; const getAllInvitations = async () => { @@ -145,8 +145,8 @@ const Invitations = () => { message={message || error} type={message ? 'success' : 'failure'} onAlertClose={() => { - setMessage(null) - setError(null) + setMessage('') + setError('') }} /> {loading ? ( @@ -242,8 +242,8 @@ const Invitations = () => { onClick={() => { setSelectedInvitation(invitation.id) setShowPopup(true) - setError(null) - setMessage(null) + setError('') + setMessage('') }} color="bg-white" className="ml-5 p-0 font-normal items-center mt-5 text-sm text-primary-700 border border-blue-700 text-center hover:!bg-primary-800 hover:text-white rounded-lg focus:ring-4 focus:ring-primary-300 sm:w-auto dark:hover:bg-primary-700 dark:text-white dark:bg-primary-700 dark:focus:ring-blue-800" diff --git a/src/components/organization/invitations/ReceivedInvitations.tsx b/src/components/organization/invitations/ReceivedInvitations.tsx index ff4bdcfc6..f14fef2f0 100644 --- a/src/components/organization/invitations/ReceivedInvitations.tsx +++ b/src/components/organization/invitations/ReceivedInvitations.tsx @@ -19,6 +19,7 @@ import { pathRoutes } from '../../../config/pathRoutes'; import { EmptyListMessage } from '../../EmptyListComponent'; import CustomSpinner from '../../CustomSpinner'; import CustomAvatar from '../../Avatar'; +import React from 'react'; const initialPageState = { pageNumber: 1, @@ -29,8 +30,8 @@ const initialPageState = { const ReceivedInvitations = () => { const [openModal, setOpenModal] = useState(false); const [loading, setLoading] = useState(false); - const [message, setMessage] = useState(null); - const [error, setError] = useState(null); + const [message, setMessage] = useState(''); + const [error, setError] = useState(''); const [currentPage, setCurrentPage] = useState(initialPageState); const timestamp = Date.now(); @@ -44,7 +45,7 @@ const ReceivedInvitations = () => { const [searchText, setSearchText] = useState(''); const [invitationsList, setInvitationsList] = - useState | null>(null); + useState([]); const props = { openModal, setOpenModal }; //Fetch the user organization list @@ -139,8 +140,8 @@ const ReceivedInvitations = () => { message={message ? message : error} type={message ? 'success' : 'failure'} onAlertClose={() => { - setMessage(null); - setError(null); + setMessage(''); + setError(''); }} /> diff --git a/src/components/organization/invitations/SendInvitationModal.tsx b/src/components/organization/invitations/SendInvitationModal.tsx index 7491fb91c..4004c0dc0 100644 --- a/src/components/organization/invitations/SendInvitationModal.tsx +++ b/src/components/organization/invitations/SendInvitationModal.tsx @@ -14,6 +14,7 @@ import { } from '../../../api/invitations'; import { getOrganizationRoles } from '../../../api/organization'; import { getFromLocalStorage } from '../../../api/Auth'; +import React from 'react'; interface Values { @@ -46,7 +47,7 @@ const SendInvitationModal = (props: { const [invitations, setInvitations] = useState([]); - const [memberRole, setMemberRole] = useState(null); + const [memberRole, setMemberRole] = useState(); const [initialData, setInitialData] = useState({ email: '', @@ -54,7 +55,7 @@ const SendInvitationModal = (props: { const [initialInvitationData, setInitialInvitationData] = useState({ email: '', }); - const [erroMsg, setErrMsg] = useState(null); + const [erroMsg, setErrMsg] = useState(''); const getRoles = async () => { const resRoles = await getOrganizationRoles(); @@ -150,7 +151,7 @@ const SendInvitationModal = (props: { message={erroMsg} type={'failure'} onAlertClose={() => { - setErrMsg(null); + setErrMsg(''); }} /> (false) - const [roles, setRoles] = useState(null) + const [roles, setRoles] = useState([]) - const [erroMsg, setErrMsg] = useState(null) + const [erroMsg, setErrMsg] = useState('') const getRoles = async () => { diff --git a/src/components/organization/users/Members.tsx b/src/components/organization/users/Members.tsx index 82e79edf2..220cf7042 100644 --- a/src/components/organization/users/Members.tsx +++ b/src/components/organization/users/Members.tsx @@ -14,6 +14,7 @@ import type { User } from '../interfaces/users'; import { getFromLocalStorage } from '../../../api/Auth'; import { getOrganizationUsers } from '../../../api/organization'; import { EmptyListMessage } from '../../EmptyListComponent'; +import React from 'react'; const initialPageState = { pageNumber: 1, @@ -24,8 +25,8 @@ const initialPageState = { const Members = () => { const [openModal, setOpenModal] = useState(false); const [loading, setLoading] = useState(true); - const [message, setMessage] = useState(null); - const [error, setError] = useState(null); + const [message, setMessage] = useState(''); + const [error, setError] = useState(''); const [userRoles, setUserRoles] = useState([]); const [currentPage, setCurrentPage] = useState(initialPageState); @@ -37,8 +38,8 @@ const Members = () => { }; const [searchText, setSearchText] = useState(''); - const [usersList, setUsersList] = useState | null>(null); - const [selectedUser, setSelectedUser] = useState(null); + const [usersList, setUsersList] = useState([]); + const [selectedUser, setSelectedUser] = useState(); const props = { openModal, setOpenModal }; const getAllUsers = async () => { @@ -122,8 +123,8 @@ const Members = () => { message={message ? message : error} type={message ? 'success' : 'failure'} onAlertClose={() => { - setMessage(null); - setError(null); + setMessage(''); + setError(''); }} /> {loading ? ( diff --git a/src/components/organization/walletCommonComponents/SetPrivateKeyValue.tsx b/src/components/organization/walletCommonComponents/SetPrivateKeyValue.tsx index 84dfa0b2e..92d2a2365 100644 --- a/src/components/organization/walletCommonComponents/SetPrivateKeyValue.tsx +++ b/src/components/organization/walletCommonComponents/SetPrivateKeyValue.tsx @@ -34,7 +34,7 @@ const SetPrivateKeyValueInput = ({ }: IProps) => { const [havePrivateKey, setHavePrivateKey] = useState(false); const [generatedKeys, setGeneratedKeys] = useState(null); - const [errorMessage, setErrorMessage] = useState(null); + const [errorMessage, setErrorMessage] = useState(''); const [loading, setLoading] = useState(false); const checkWalletBalance = async (privateKey: string, network: Network) => { @@ -57,7 +57,7 @@ const SetPrivateKeyValueInput = ({ if (parseFloat(etherBalance) < CommonConstants.BALANCELIMIT) { setErrorMessage('You have insufficient funds.'); } else { - setErrorMessage(null); + setErrorMessage(''); } return etherBalance; @@ -71,7 +71,7 @@ const SetPrivateKeyValueInput = ({ if (privateKeyValue && privateKeyValue.length === 64) { checkWalletBalance(privateKeyValue, Network.TESTNET); } else { - setErrorMessage(null); + setErrorMessage(''); } }, [privateKeyValue]); @@ -79,11 +79,11 @@ const SetPrivateKeyValueInput = ({ useEffect(() => { if (havePrivateKey) { setPrivateKeyValue(''); - setErrorMessage(null); + setErrorMessage(''); setGeneratedKeys(null); } else { setPrivateKeyValue(''); - setErrorMessage(null); + setErrorMessage(''); } }, [havePrivateKey]); diff --git a/src/components/organization/walletCommonComponents/WalletSpinup.tsx b/src/components/organization/walletCommonComponents/WalletSpinup.tsx index 344e61f12..7eb75b022 100644 --- a/src/components/organization/walletCommonComponents/WalletSpinup.tsx +++ b/src/components/organization/walletCommonComponents/WalletSpinup.tsx @@ -41,12 +41,12 @@ const WalletSpinup = (props: { const [agentType, setAgentType] = useState(AgentType.SHARED); const [loading, setLoading] = useState(false); const [walletSpinStep, setWalletSpinStep] = useState(0); - const [success, setSuccess] = useState(null); + const [success, setSuccess] = useState(''); const [agentSpinupCall, setAgentSpinupCall] = useState(false); - const [failure, setFailure] = useState(null); + const [failure, setFailure] = useState(''); const [seeds, setSeeds] = useState(''); const [maskedSeeds, setMaskedSeeds] = useState(''); - const [orgData, setOrgData] = useState(null); + const [orgData, setOrgData] = useState(); const [isShared, setIsShared] = useState(false); const [isConfiguredDedicated, setIsConfiguredDedicated] = useState(false); @@ -291,8 +291,8 @@ const submitDedicatedWallet = async ( message={success ?? failure} type={success ? 'success' : 'failure'} onAlertClose={() => { - setSuccess(null); - setFailure(null); + setSuccess(''); + setFailure(''); }} /> )} diff --git a/src/components/publicProfile/OrgWalletDetails.tsx b/src/components/publicProfile/OrgWalletDetails.tsx index 60d2c248b..3ef7b408b 100644 --- a/src/components/publicProfile/OrgWalletDetails.tsx +++ b/src/components/publicProfile/OrgWalletDetails.tsx @@ -8,7 +8,7 @@ import CopyDid from "../../commonComponents/CopyDid"; const OrgWalletDetails = ({ orgData }: IExploreOrg) => { - const [connectionInvitation, setConnectionInvitation] = useState(null); + const [connectionInvitation, setConnectionInvitation] = useState(''); useEffect(() => { if (orgData && orgData?.org_agents?.length > 0) { diff --git a/src/components/publicProfile/OrganisationPublicProfile.tsx b/src/components/publicProfile/OrganisationPublicProfile.tsx index 91342d8ec..90509d9cf 100644 --- a/src/components/publicProfile/OrganisationPublicProfile.tsx +++ b/src/components/publicProfile/OrganisationPublicProfile.tsx @@ -10,6 +10,7 @@ import CustomSpinner from '../CustomSpinner'; import CustomAvatar from '../Avatar'; import { EmptyListMessage } from '../EmptyListComponent'; import { AlertComponent } from '../AlertComponent'; +import React from 'react'; const OrganisationPublicProfile = () => { const initialPageState = { @@ -21,7 +22,7 @@ const OrganisationPublicProfile = () => { const [organizationList, setOrganizationList] = useState([]); const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); + const [error, setError] = useState(''); const [searchText, setSearchText] = useState(''); const [currentPage, setCurrentPage] = useState(initialPageState); const onPageChange = (page: number) => { @@ -93,7 +94,7 @@ const OrganisationPublicProfile = () => { message={error} type={'failure'} onAlertClose={() => { - setError(null); + setError(''); }} />