diff --git a/src/components/Authentication/SignUpUserName.tsx b/src/components/Authentication/SignUpUserName.tsx index c91195775..94f814727 100644 --- a/src/components/Authentication/SignUpUserName.tsx +++ b/src/components/Authentication/SignUpUserName.tsx @@ -1,7 +1,5 @@ import 'react-toastify/dist/ReactToastify.css'; - import * as yup from 'yup'; - import { Button, Label } from 'flowbite-react'; import { Field, @@ -9,12 +7,11 @@ import { Formik } from 'formik'; import { useState } from 'react'; - -import React from 'react'; import SignUpUserPasskey from './SignUpUserPasskey.js'; import SignUpUser from './SignUpUser.js'; import NavBar from './NavBar.js'; import FooterBar from './FooterBar.js'; +import React from 'react'; interface nameValues { firstName: string; @@ -126,13 +123,13 @@ const SignUpUserName = () => { .string() .required('First name is required') .min(2, 'First name must be at least 2 characters') - .max(50, 'First name must be at most 255 characters') + .max(50, 'First name must be at most 50 characters') .trim(), lastName: yup .string() .required('Last name is required') .min(2, 'Last name must be at least 2 characters') - .max(50, 'Last name must be at most 255 characters') + .max(50, 'Last name must be at most 50 characters') .trim() })} validateOnBlur @@ -151,72 +148,134 @@ const SignUpUserName = () => { lastName: formikHandlers.values.lastName }) return ( -
+
-
-
{ + const value = e.target.value; + formikHandlers.setFieldValue( + 'firstName', + value, + ); + formikHandlers.setFieldTouched( + 'firstName', + true, + ); + + if (value.length > 50) { + formikHandlers.setFieldError( + 'firstName', + 'First name must be at most 50 characters', + ); + } else { + formikHandlers.setFieldError( + 'firstName', + undefined, + ); + } + }} /> - { - (formikHandlers?.errors?.firstName && formikHandlers?.touched?.firstName) && - {formikHandlers?.errors?.firstName} - } + + {formikHandlers?.errors?.firstName && + formikHandlers?.touched?.firstName && ( + + {formikHandlers?.errors?.firstName} + + )}
-
-
{ + const value = e.target.value; + formikHandlers.setFieldValue('lastName', value); + formikHandlers.setFieldTouched( + 'lastName', + true, + ); + + if (value.length > 50) { + formikHandlers.setFieldError( + 'lastName', + 'Last name must be at most 50 characters', + ); + } else { + formikHandlers.setFieldError( + 'lastName', + undefined, + ); + } + }} /> - { - (formikHandlers?.errors?.lastName && formikHandlers?.touched?.lastName) && - {formikHandlers?.errors?.lastName} - } + {formikHandlers?.errors?.lastName && + formikHandlers?.touched?.lastName && ( + + {formikHandlers?.errors?.lastName} + + )}
- -
- Already have an account? -   {` Login here`}
-
- ) + ); }} diff --git a/src/components/CreateEcosystemOrgModal/index.tsx b/src/components/CreateEcosystemOrgModal/index.tsx index 264b49303..a7b1462e3 100644 --- a/src/components/CreateEcosystemOrgModal/index.tsx +++ b/src/components/CreateEcosystemOrgModal/index.tsx @@ -14,6 +14,7 @@ import { createOrganization } from "../../api/organization"; import { getFromLocalStorage } from "../../api/Auth"; import { createEcosystems } from "../../api/ecosystem"; import { getOrgDetails } from "../../config/ecosystem"; +import React from "react"; interface Values { name: string; @@ -340,7 +341,19 @@ const CreateEcosystemOrgModal = (props: IProps) => { name="name" value={formikHandlers.values.name} className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" - placeholder={`Enter ${popupName} Name`} /> + placeholder={`Enter ${popupName} Name`} + onChange={(e) => { + const value = e.target.value; + formikHandlers.setFieldValue('name', value); + formikHandlers.setFieldTouched('name', true); + + if (value.length > 50) { + formikHandlers.setFieldError('name', props.isorgModal ? 'Organization name must be at most 50 characters' : 'Ecosystem name must be at most 50 characters'); + } else { + formikHandlers.setFieldError('name', undefined); + } + }} + /> { (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && {formikHandlers?.errors?.name} @@ -365,7 +378,19 @@ const CreateEcosystemOrgModal = (props: IProps) => { value={formikHandlers.values.description} as='textarea' className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" - placeholder={`Enter ${popupName} Description`} /> + placeholder={`Enter ${popupName} Description`} + onChange={(e) => { + const value = e.target.value; + formikHandlers.setFieldValue('description', value); + formikHandlers.setFieldTouched('description', true); + + if (value.length > 50) { + formikHandlers.setFieldError('description', 'Description must be at most 255 characters'); + } else { + formikHandlers.setFieldError('description', undefined); + } + }} + /> { (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && {formikHandlers?.errors?.description} @@ -385,14 +410,11 @@ const CreateEcosystemOrgModal = (props: IProps) => { )} - - ) } - return ( <> {renderEcosystemModal()} diff --git a/src/components/EditEcosystemOrgModal/index.tsx b/src/components/EditEcosystemOrgModal/index.tsx index b2ec9e95c..986e5bba8 100644 --- a/src/components/EditEcosystemOrgModal/index.tsx +++ b/src/components/EditEcosystemOrgModal/index.tsx @@ -295,6 +295,18 @@ const EditPopupModal = (props: EditEntityModalProps) => { value={formikHandlers.values.name} className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" placeholder={`Enter ${props.isOrganization ? "Organization" : "Ecosystem"} Name`} + onChange={(e) => { + const value = e.target.value; + formikHandlers.setFieldValue('name', value); + formikHandlers.setFieldTouched('name', true); + + if (value.length > 50) { + formikHandlers.setFieldError('name', props.isOrganization ? 'Organization name must be at most 50 characters' : 'Ecosystem name must be at most 50 characters'); + } else { + formikHandlers.setFieldError('name', undefined); + } + }} + /> {formikHandlers?.errors?.name && formikHandlers?.touched?.name && ( {formikHandlers?.errors?.name} @@ -312,6 +324,18 @@ const EditPopupModal = (props: EditEntityModalProps) => { as='textarea' className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" placeholder={`Enter ${props.isOrganization ? "Organization" : "Ecosystem"} Description`} + onChange={(e) => { + const value = e.target.value; + formikHandlers.setFieldValue('description', value); + formikHandlers.setFieldTouched('description', true); + + if (value.length > 50) { + formikHandlers.setFieldError('description', 'Description must be at most 255 characters'); + } else { + formikHandlers.setFieldError('description', undefined); + } + }} + /> {formikHandlers?.errors?.description && formikHandlers?.touched?.description && ( {formikHandlers?.errors?.description} diff --git a/src/components/Issuance/IssuedCrdentials.tsx b/src/components/Issuance/IssuedCrdentials.tsx index 70c934289..4c8430b10 100644 --- a/src/components/Issuance/IssuedCrdentials.tsx +++ b/src/components/Issuance/IssuedCrdentials.tsx @@ -21,6 +21,7 @@ import { dateConversion } from '../../utils/DateConversion'; import { getIssuedCredentials } from '../../api/issuance'; import { pathRoutes } from '../../config/pathRoutes'; import { getFromLocalStorage } from '../../api/Auth'; +import { getOrgDetails } from '../../config/ecosystem' interface IssuedCredential { metadata: { [x: string]: { schemaId: string } }; @@ -34,11 +35,15 @@ const CredentialList = () => { const [error, setError] = useState(null); const [searchText, setSearchText] = useState(''); const [issuedCredList, setIssuedCredList] = useState([]); + const [walletCreated, setWalletCreated] = useState(false) const getIssuedCredDefs = async () => { setLoading(true) + const orgData = await getOrgDetails() + const isWalletCreated = Boolean(orgData.orgDid) + setWalletCreated(isWalletCreated) const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - if (orgId) { + if (orgId && isWalletCreated) { const response = await getIssuedCredentials(); const { data } = response as AxiosResponse; @@ -154,17 +159,20 @@ const CredentialList = () => { className="p-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- - - - - } - onClickEvent={schemeSelection} - /> + { + walletCreated && + + + + + } + onClickEvent={schemeSelection} + /> + }
{ setError(null) }} /> - {loading ? ( -
- -
- ) : issuedCredList && issuedCredList.length > 0 ? ( -
-
- {issuedCredList && issuedCredList.length > 0 && - + { + !walletCreated && !loading ? +
+ +
+ : +
+ { + loading ? ( +
+ +
+ ) : issuedCredList && issuedCredList.length > 0 ? ( +
+
+ {issuedCredList && issuedCredList.length > 0 && + + } +
+
+ ) : ( +
+ + There isn't any data available. + +
+ ) }
-
- ) : ( -
- - There isn't any data available. - -
- )} + }
diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx index 2c31e0660..de5b501bf 100644 --- a/src/components/Profile/EditUserProfile.tsx +++ b/src/components/Profile/EditUserProfile.tsx @@ -1,14 +1,13 @@ -import { useEffect, useRef, useState } from "react"; +import { useEffect, useRef, useState} from "react"; import type { UserProfile } from "./interfaces"; -import { setToLocalStorage, updateUserProfile } from "../../api/Auth"; -import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, imageSizeAccepted, storageKeys} from "../../config/CommonConstant"; +import { getFromLocalStorage, setToLocalStorage, updateUserProfile } from "../../api/Auth"; +import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, imageSizeAccepted, storageKeys } from "../../config/CommonConstant"; import type { AxiosResponse } from "axios"; import CustomAvatar from '../Avatar' import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; -import { Alert,Button} from "flowbite-react"; +import { Alert, Button } from "flowbite-react"; import { Form, Formik, FormikHelpers } from "formik"; import * as yup from "yup" -import React from "react"; interface Values { profileImg: string; @@ -28,7 +27,7 @@ interface EditUserProfileProps { updateProfile: (updatedProfile: UserProfile) => void; } -const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: EditUserProfileProps) => { +const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: EditUserProfileProps) => { const [loading, setLoading] = useState(false) const [isImageEmpty, setIsImageEmpty] = useState(true) @@ -54,7 +53,7 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E if (firstNameInputRef.current) { firstNameInputRef.current.focus(); } - }, []); + }, []); useEffect(() => { @@ -166,11 +165,19 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E } const resUpdateUserDetails = await updateUserProfile(userData) + const existingUser = await getFromLocalStorage(storageKeys.USER_PROFILE) + const { data } = resUpdateUserDetails as AxiosResponse - setToLocalStorage(storageKeys.USER_PROFILE, userData) + + const updatedUser = JSON.parse(existingUser) + + const updatedUserData = { + ...updatedUser, + ...userData + } updateProfile(userData); - await setToLocalStorage(storageKeys.USER_PROFILE, userData); + await setToLocalStorage(storageKeys.USER_PROFILE, updatedUserData); window.location.reload(); setLoading(false) } @@ -179,12 +186,12 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E firstName: yup.string() .required("First Name is required") .min(2, 'First name must be at least 2 characters') - .max(255, 'First name must be at most 255 characters'), - + .max(50, 'First name must be at most 50 characters'), + lastName: yup.string() .required("Last Name is required") .min(2, 'Last name must be at least 2 characters') - .max(255, 'Last name must be at most 255 characters') + .max(50, 'Last name must be at most 50 characters') }); @@ -219,7 +226,7 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E values: Values, { resetForm }: FormikHelpers ) => { - await updateUserDetails(values); + await updateUserDetails(values); toggleEditProfile(); }} @@ -253,7 +260,17 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E name="firstName" placeholder="Enter your first name" value={formikHandlers.values.firstName} - onChange={formikHandlers.handleChange} + onChange={(e) => { + const value = e.target.value; + formikHandlers.setFieldValue('firstName', value); + formikHandlers.setFieldTouched('firstName', true); + + if (value.length > 50) { + formikHandlers.setFieldError('firstName', 'First name must be at most 50 characters'); + } else { + formikHandlers.setFieldError('firstName', undefined); + } + }} onBlur={formikHandlers.handleBlur} ref={firstNameInputRef} className="bg-gray-50 py-3 px-4 font-medium text-gray-900 border border-gray-300 w-full rounded-md focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500 max-w-100/6rem" /> @@ -278,7 +295,17 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E name="lastName" placeholder="Enter your last name" value={formikHandlers.values.lastName} - onChange={formikHandlers.handleChange} + onChange={(e) => { + const value = e.target.value; + formikHandlers.setFieldValue('lastName', value); + formikHandlers.setFieldTouched('lastName', true); + + if (value.length > 50) { + formikHandlers.setFieldError('lastName', 'Last name must be at most 50 characters'); + } else { + formikHandlers.setFieldError('lastName', undefined); + } + }} onBlur={formikHandlers.handleBlur} className="bg-gray-50 py-3 px-4 font-medium text-gray-900 border border-gray-300 w-full rounded-md focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500 max-w-100/6rem" /> {(formikHandlers?.errors?.lastName && formikHandlers?.touched?.lastName) && ( @@ -321,28 +348,28 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E
-
- -
-
-
+
+ -
+ + Cancel + +
)} diff --git a/src/components/Profile/UserProfile.tsx b/src/components/Profile/UserProfile.tsx index d5c8e3cfc..cd6eaf840 100644 --- a/src/components/Profile/UserProfile.tsx +++ b/src/components/Profile/UserProfile.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; import type { AxiosResponse } from 'axios'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; -import { getFromLocalStorage, getUserProfile } from '../../api/Auth'; +import { getFromLocalStorage, getUserProfile, setToLocalStorage } from '../../api/Auth'; import BreadCrumbs from '../BreadCrumbs'; import type { UserProfile } from './interfaces'; import DisplayUserProfile from './DisplayUserProfile'; @@ -9,9 +9,16 @@ import React from 'react'; import AddPasskey from './AddPasskey'; import EditUserProfile from './EditUserProfile'; +interface IUserProfile { + firstName: string + lastName: string + email: string + profileImg: string +} + const UserProfile = () => { const [isEditProfileOpen, setIsEditProfileOpen] = useState(false); - const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(null); + const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(null); const fetchUserProfile = async () => { try { @@ -21,6 +28,8 @@ const UserProfile = () => { if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { setPrePopulatedUserProfile(data?.data); + await setToLocalStorage(storageKeys.USER_PROFILE, data?.data) + await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email) } } catch (error) { } @@ -37,7 +46,7 @@ const UserProfile = () => { }, []); - const updatePrePopulatedUserProfile = (updatedProfile: UserProfile) => { + const updatePrePopulatedUserProfile = (updatedProfile: IUserProfile) => { setPrePopulatedUserProfile(updatedProfile); }; @@ -107,7 +116,6 @@ const UserProfile = () => { - ); }; diff --git a/src/components/Verification/VerificationCredentialList.tsx b/src/components/Verification/VerificationCredentialList.tsx index ed011c083..87210b1cb 100644 --- a/src/components/Verification/VerificationCredentialList.tsx +++ b/src/components/Verification/VerificationCredentialList.tsx @@ -30,6 +30,7 @@ import type { TableData } from '../../commonComponents/datatable/interface'; import { dateConversion } from '../../utils/DateConversion'; import { pathRoutes } from '../../config/pathRoutes'; import { getFromLocalStorage, removeFromLocalStorage } from '../../api/Auth'; +import { getOrgDetails } from '../../config/ecosystem' const VerificationCredentialList = () => { const [loading, setLoading] = useState(true); @@ -42,6 +43,7 @@ const VerificationCredentialList = () => { const [verifyLoader, setVerifyloader] = useState(false); const [userData, setUserData] = useState(null); const [view, setView] = useState(false); + const [walletCreated, setWalletCreated] = useState(false) const getProofPresentationData = async (id: string) => { try { @@ -66,282 +68,306 @@ const VerificationCredentialList = () => { setLoading(true); try { + const orgData = await getOrgDetails() + const isWalletCreated = Boolean(orgData.orgDid) + setWalletCreated(isWalletCreated) const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - if (orgId) { - const response = await getVerificationList(); - const { data } = response as AxiosResponse; + if (orgId && isWalletCreated) { + const response = await getVerificationList(); + const { data } = response as AxiosResponse; - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const credentialList = data?.data?.map((requestProof: RequestProof) => { - return { - data: [ - { data: requestProof?.id ? requestProof?.id : 'Not available' }, - { - data: requestProof?.connectionId - ? requestProof?.connectionId - : 'Not available', - }, - { data: {dateConversion(requestProof.updatedAt)} }, - { - data: ( - - {requestProof?.state === ProofRequestState.requestSent - ? ProofRequestStateUserText.requestSent - : requestProof?.state === - ProofRequestState.presentationReceived - ? ProofRequestStateUserText.requestReceived - : requestProof?.state === ProofRequestState.done - ? ProofRequestStateUserText.done - : requestProof?.state === ProofRequestState.abandoned - ? ProofRequestStateUserText.abandoned - : ''} - - ), - }, - { - data: ( - - ), - }, - ], - }; - }); + + + + + Verify +

+ )} + + ), + }, + ], + }; + }); - setVerificationList(credentialList); - } else { - setErrMsg(response as string); + setVerificationList(credentialList); + } else { + setErrMsg(response as string); + } } + } catch (error) { + setErrMsg('An error occurred while fetching the proof request list'); } - } catch (error) { - setErrMsg('An error occurred while fetching the proof request list'); - } - setLoading(false); - }; + setLoading(false); + }; - const presentProofById = async (id: string) => { - try { - const response = await verifyPresentation(id); - const { data } = response as AxiosResponse; + const presentProofById = async (id: string) => { + try { + const response = await verifyPresentation(id); + const { data } = response as AxiosResponse; - if (data?.statusCode === apiStatusCodes?.API_STATUS_CREATED) { - setOpenModal(false) - setProofReqSuccess(data.message) - setVerifyloader(false) + if (data?.statusCode === apiStatusCodes?.API_STATUS_CREATED) { + setOpenModal(false) + setProofReqSuccess(data.message) + setVerifyloader(false) + setTimeout(() => { + getproofRequestList() + }, 2000) + } else { + setOpenModal(false) + setErrMsg(response as string); + setVerifyloader(false) + } setTimeout(() => { - getproofRequestList() - }, 2000) - } else { + setProofReqSuccess('') + setErrMsg('') + }, 4000) + } catch (error) { setOpenModal(false) - setErrMsg(response as string); setVerifyloader(false) + console.error("An error occurred:", error); + setErrMsg("An error occurred while processing the presentation."); } - setTimeout(() => { - setProofReqSuccess('') - setErrMsg('') - }, 4000) - } catch (error) { - setOpenModal(false) - setVerifyloader(false) - console.error("An error occurred:", error); - setErrMsg("An error occurred while processing the presentation."); - } - }; + }; - const openProofRequestModel = (flag: boolean, requestId: string, state: boolean) => { - setRequestId(requestId) - setOpenModal(flag) - setView(state === "done" ? true : false) + const openProofRequestModel = (flag: boolean, requestId: string, state: boolean) => { + setRequestId(requestId) + setOpenModal(flag) + setView(state === "done" ? true : false) - } + } - const requestProof = async (proofVericationId: string) => { - if (proofVericationId) { - setOpenModal(false) - presentProofById(proofVericationId) + const requestProof = async (proofVericationId: string) => { + if (proofVericationId) { + setOpenModal(false) + presentProofById(proofVericationId) + } } - } - useEffect(() => { - let getData: NodeJS.Timeout + useEffect(() => { + let getData: NodeJS.Timeout - if (searchText.length >= 1) { - getData = setTimeout(() => { }, 1000); - } else { - getproofRequestList() - } + if (searchText.length >= 1) { + getData = setTimeout(() => { }, 1000); + } else { + getproofRequestList() + } - return () => clearTimeout(getData) - }, [searchText]) + return () => clearTimeout(getData) + }, [searchText]) - const searchInputChange = (e: ChangeEvent) => { - setSearchText(e.target.value); - } + const searchInputChange = (e: ChangeEvent) => { + setSearchText(e.target.value); + } - const schemeSelection = () => { - window.location.href = pathRoutes.organizations.verification.schema - } + const schemeSelection = () => { + window.location.href = pathRoutes.organizations.verification.schema + } - const header = [ - { columnName: 'Request Id' }, - { columnName: 'Connection Id' }, - { columnName: 'Requested On' }, - { columnName: 'Status' }, - { columnName: 'Action' }, - ]; + const header = [ + { columnName: 'Request Id' }, + { columnName: 'Connection Id' }, + { columnName: 'Requested On' }, + { columnName: 'Status' }, + { columnName: 'Action' }, + ]; - return ( -
-
- -

- Verification List -

-
-
-
-
- - - + return ( +
+
+ +

+ Verification List +

+
+
+
+
+ { + walletCreated && + + + + } + onClickEvent={schemeSelection} + /> } - onClickEvent={schemeSelection} - /> -
- { - (proofReqSuccess || errMsg) && ( -
- setErrMsg(null)} - > - -

- {proofReqSuccess || errMsg} -

-
-
-
- )} - {loading ? ( -
-
- ) : verificationList && verificationList.length > 0 ? ( -
-
- {verificationList && verificationList.length > 0 && - - } -
-
- ) : ( -
- - There isn't any data available. - -
- )} + { + (proofReqSuccess || errMsg) && ( +
+ setErrMsg(null)} + > + +

+ {proofReqSuccess || errMsg} +

+
+
+
+ )} - + +
+ : +
+ { + + loading ? ( +
+ +
+ ) : verificationList && verificationList.length > 0 ? ( +
+
+ {verificationList && verificationList.length > 0 && + + } +
+
+ ) : ( +
+ + There isn't any data available. + +
+ ) + + } +
} - requestId={requestId} - userData={userData} - view={view} - /> + + +
-
- ) -} + ) + } -export default VerificationCredentialList; + export default VerificationCredentialList; diff --git a/src/components/organization/EditOrgdetailsModal.tsx b/src/components/organization/EditOrgdetailsModal.tsx index 997179817..3e055d5a6 100644 --- a/src/components/organization/EditOrgdetailsModal.tsx +++ b/src/components/organization/EditOrgdetailsModal.tsx @@ -2,7 +2,7 @@ import * as yup from "yup" import { Avatar, Button, Label, Modal } from 'flowbite-react'; import { Field, Form, Formik, FormikHelpers } from 'formik'; -import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted, storageKeys } from '../../config/CommonConstant' +import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted} from '../../config/CommonConstant' import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; import { useEffect, useState } from "react"; @@ -10,26 +10,24 @@ import { AlertComponent } from "../AlertComponent"; import type { AxiosResponse } from 'axios'; import { updateOrganization } from "../../api/organization"; import type { Organisation } from "./interfaces"; +import React from "react"; interface Values { website: any; name: string; description: string; } - interface ILogoImage { logoFile: string | File imagePreviewUrl: string | ArrayBuffer | null | File, fileName: string } - interface EditOrgdetailsModalProps { openModal: boolean; setMessage: (message: string) => void; setOpenModal: (flag: boolean) => void; onEditSucess?: () => void; orgData: Organisation | null; - } const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { @@ -55,7 +53,7 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { setOrgData({ name: props.orgData.name || '', description: props.orgData.description || '', - website: props?.orgData?.website || "", + website: props?.orgData?.website || "", }); setLogoImage({ @@ -76,7 +74,7 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { setOrgData({ name: '', description: '', - website:'' + website:'' }) setLogoImage({ @@ -282,7 +280,6 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { className="hidden" id="organizationlogo" title="" onChange={(event): void => handleImageChange(event)} /> - {/* {selectedImage || 'No File Chosen'} */} {imgError ?
{imgError}
: {logoImage.fileName || 'No File Chosen'}} @@ -308,7 +305,31 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { name="name" value={formikHandlers.values.name} className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" - placeholder="Your organization name" /> + placeholder="Your organization name" + onChange={(e) => { + const value = e.target.value; + formikHandlers.setFieldValue( + 'name', + value, + ); + formikHandlers.setFieldTouched( + 'name', + true, + ); + + if (value.length > 50) { + formikHandlers.setFieldError( + 'name', + 'Organization name must be at most 50 characters', + ); + } else { + formikHandlers.setFieldError( + 'name', + undefined, + ); + } + }} + /> { (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && {formikHandlers?.errors?.name} @@ -334,7 +355,31 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { value={formikHandlers.values.description} as='textarea' className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" - placeholder="Description of your organization" /> + placeholder="Description of your organization" + onChange={(e) => { + const value = e.target.value; + formikHandlers.setFieldValue( + 'description', + value, + ); + formikHandlers.setFieldTouched( + 'description', + true, + ); + + if (value.length > 50) { + formikHandlers.setFieldError( + 'description', + 'Description must be at most 50 characters', + ); + } else { + formikHandlers.setFieldError( + 'description', + undefined, + ); + } + }} + /> { (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && {formikHandlers?.errors?.description} diff --git a/src/components/organization/OrgDropDown.tsx b/src/components/organization/OrgDropDown.tsx index 52aa56710..09182d64b 100644 --- a/src/components/organization/OrgDropDown.tsx +++ b/src/components/organization/OrgDropDown.tsx @@ -29,6 +29,7 @@ const OrgDropDown = () => { const goToOrgDashboard = async (org: Organisation) => { await removeFromLocalStorage(storageKeys.ECOSYSTEM_ID) await removeFromLocalStorage(storageKeys.ECOSYSTEM_ROLE) + await removeFromLocalStorage(storageKeys.ORG_DETAILS) await setOrgRoleDetails(org) window.location.href = pathRoutes.organizations.dashboard; diff --git a/src/components/organization/WalletSpinup.tsx b/src/components/organization/WalletSpinup.tsx index c759ccb33..15baac481 100644 --- a/src/components/organization/WalletSpinup.tsx +++ b/src/components/organization/WalletSpinup.tsx @@ -28,7 +28,6 @@ interface Values { } interface ValuesShared { - seed: string; label: string; } @@ -37,36 +36,230 @@ enum AgentType { DEDICATED = 'dedicated', } +interface ISharedAgentForm { + seeds: string + isCopied: boolean + copyTextVal: (e: any) => void + orgName: string + loading: boolean + submitSharedWallet: (values: ValuesShared) => void +} + +interface IDedicatedAgentForm { + seeds: string + loading: boolean + submitDedicatedWallet: (values: Values) => void +} + +const SharedAgentForm = ({ orgName, seeds, isCopied, loading, copyTextVal, submitSharedWallet }: ISharedAgentForm) => ( +
+
+
+
+
+ {seeds} + + + +
+
+ !value || !value.includes(' ')) + .matches( + /^[A-Za-z0-9-][^ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]*$/, + 'Wallet label must be alphanumeric only', + ) + .min(2, 'Wallet label must be at least 2 characters') + .max(25, 'Wallet label must be at most 25 characters'), + })} + validateOnBlur + validateOnChange + enableReinitialize + onSubmit={(values: ValuesShared) => submitSharedWallet(values)} + > + {(formikHandlers): JSX.Element => ( +
+
+
+
+ + + {formikHandlers?.errors?.label && + formikHandlers?.touched?.label && ( + + {formikHandlers?.errors?.label} + + )} +
+ + +
+ )} +
+
+); + +const DedicatedAgentForm = ({ seeds, loading, submitDedicatedWallet }: IDedicatedAgentForm) => ( + ?@[\]^_`{|}~]*$/, + 'Wallet name must be alphanumeric only', + ) + .label('Wallet name'), + password: yup + .string() + .matches( + passwordRegex, + 'Password must contain one Capital, Special character', + ) + .required('Wallet password is required') + .label('Wallet password'), + })} + validateOnBlur + validateOnChange + enableReinitialize + onSubmit={(values: Values) => submitDedicatedWallet(values)} + > + {(formikHandlers): JSX.Element => ( +
+
+
+
+ + {formikHandlers?.errors?.seed && formikHandlers?.touched?.seed && ( + + {formikHandlers?.errors?.seed} + + )} +
+
+
+
+ + {formikHandlers?.errors?.name && formikHandlers?.touched?.name && ( + + {formikHandlers?.errors?.name} + + )} +
+
+
+
+ + {formikHandlers?.errors?.password && + formikHandlers?.touched?.password && ( + + {formikHandlers?.errors?.password} + + )} +
+ +
+ )} +
+); + const WalletSpinup = (props: { setWalletSpinupStatus: (flag: boolean) => void; orgName: string }) => { const [agentType, setAgentType] = useState(AgentType.SHARED); - const [loading, setLoading] = useState(false); - const [walletSpinStep, setWalletSpinStep] = useState(0); - const [success, setSuccess] = useState(null); - const [agentSpinupCall, setAgentSpinupCall] = useState(false); - const [failure, setFailure] = useState(null); - const [seeds, setSeeds] = useState(''); - const [isCopied, setIsCopied] = useState(false); + // const [organization, setOrganization] = useState(props.orgName) - - const generateWalletname = () => { - - } useEffect(() => { setSeeds(nanoid(32)); - generateWalletname() }, []); - function copyTextVal(event: React.MouseEvent) { + const copyTextVal = (event: React.MouseEvent) => { event.preventDefault() setIsCopied(true); @@ -183,202 +376,9 @@ const WalletSpinup = (props: { console.log(`error-in-wallet-creation-process`, JSON.stringify(data)); }); - const DedicatedAgentForm = () => ( - ?@[\]^_`{|}~]*$/, - 'Wallet name must be alphanumeric only', - ) - .label('Wallet name'), - password: yup - .string() - .matches( - passwordRegex, - 'Password must contain one Capital, Special character', - ) - .required('Wallet password is required') - .label('Wallet password'), - })} - validateOnBlur - validateOnChange - enableReinitialize - onSubmit={(values: Values) => submitDedicatedWallet(values)} - > - {(formikHandlers): JSX.Element => ( -
-
-
-
- - {formikHandlers?.errors?.seed && formikHandlers?.touched?.seed && ( - - {formikHandlers?.errors?.seed} - - )} -
-
-
-
- - - {formikHandlers?.errors?.name && formikHandlers?.touched?.name && ( - - {formikHandlers?.errors?.name} - - )} -
- -
-
-
- - - {formikHandlers?.errors?.password && - formikHandlers?.touched?.password && ( - - {formikHandlers?.errors?.password} - - )} -
- -
- )} -
- ); - const orgName = props?.orgName ? props?.orgName?.split(" ").reduce((s, c) => (s.charAt(0).toUpperCase() + s.slice(1)) + (c.charAt(0).toUpperCase() + c.slice(1)) ) : "" - const SharedAgentForm = () => ( - !value || !value.includes(' ')) - .matches( - /^[A-Za-z0-9-][^ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]*$/, - 'Wallet label must be alphanumeric only', - ) - .min(2, 'Wallet label must be at least 2 characters') - .max(25, 'Wallet label must be at most 25 characters'), - })} - validateOnBlur - validateOnChange - enableReinitialize - onSubmit={(values: ValuesShared) => submitSharedWallet(values)} - > - {(formikHandlers): JSX.Element => ( -
-
-
-
-
- {seeds} - - - -
- -
-
-
-
- - - {formikHandlers?.errors?.label && - formikHandlers?.touched?.label && ( - - {formikHandlers?.errors?.label} - - )} -
- - -
- )} -
- ); return (
@@ -444,9 +444,9 @@ const WalletSpinup = (props: { {!agentSpinupCall ? ( agentType === AgentType.SHARED ? ( - + ) : ( - + ) ) : (