From 10d7496b6439093e6ef09e0052cb3df34a429db5 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Tue, 12 Sep 2023 11:19:11 +0530 Subject: [PATCH 001/250] feat: display user profile Signed-off-by: bhavanakarwade --- src/components/Profile/AddPasskey.tsx | 432 ++++++++---------- src/components/Profile/DisplayUserProfile.tsx | 53 ++- src/components/Profile/UpdatePassword.tsx | 48 ++ src/components/organization/users/index.tsx | 1 + 4 files changed, 294 insertions(+), 240 deletions(-) create mode 100644 src/components/Profile/UpdatePassword.tsx diff --git a/src/components/Profile/AddPasskey.tsx b/src/components/Profile/AddPasskey.tsx index 3a606215d..34f9d9f46 100644 --- a/src/components/Profile/AddPasskey.tsx +++ b/src/components/Profile/AddPasskey.tsx @@ -1,277 +1,239 @@ - import { useEffect, useState } from 'react'; - import { startRegistration } from '@simplewebauthn/browser' - import type { AxiosError, AxiosResponse } from 'axios'; - import { addDeviceDetails, generateRegistrationOption, getUserDeviceDetails, verifyRegistration } from '../../api/Fido'; - import DeviceDetails from '../../commonComponents/DeviceDetailsCard'; - import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; - import { getFromLocalStorage, getUserProfile } from '../../api/Auth'; - import BreadCrumbs from '../BreadCrumbs'; - import { Alert } from 'flowbite-react'; - import type { IDeviceData, IdeviceBody, RegistrationOptionInterface, UserProfile, verifyRegistrationObjInterface } from './interfaces'; - import DisplayUserProfile from './DisplayUserProfile'; - import EditUserProfile from './EditUserProfile'; +import { useEffect, useState } from 'react'; +import { startRegistration } from '@simplewebauthn/browser' +import type { AxiosError, AxiosResponse } from 'axios'; +import { addDeviceDetails, generateRegistrationOption, getUserDeviceDetails, verifyRegistration } from '../../api/Fido'; +import DeviceDetails from '../../commonComponents/DeviceDetailsCard'; +import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; +import { getFromLocalStorage, getUserProfile } from '../../api/Auth'; +import BreadCrumbs from '../BreadCrumbs'; +import { Alert } from 'flowbite-react'; +import type { IDeviceData, IdeviceBody, RegistrationOptionInterface, UserProfile, verifyRegistrationObjInterface } from './interfaces'; +import DisplayUserProfile from './DisplayUserProfile'; +import UpdatePassword from './UpdatePassword'; +import EditUserProfile from './EditUserProfile'; import UpdateUserProfile from './EditUserProfile'; import CustomSpinner from '../CustomSpinner'; -import { dateConversion } from '../../utils/DateConversion'; - const AddPasskey = () => { - const [fidoError, setFidoError] = useState("") - const [fidoLoader, setFidoLoader] = useState(false) - const [OrgUserEmail, setOrgUserEmail] = useState('') - const [deviceList, setDeviceList] = useState([]) - const [addSuccess, setAddSuccess] = useState(null) - const [addfailure, setAddFailur] = useState(null) - const [isEditProfileOpen, setIsEditProfileOpen] = useState(false); - const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(null); - - - const fetchUserProfile = async () => { - try { - const token = await getFromLocalStorage(storageKeys.TOKEN); - const userDetailsResponse = await getUserProfile(token); - const { data } = userDetailsResponse as AxiosResponse; - - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - setPrePopulatedUserProfile(data?.data); - } - } catch (error) { +const AddPasskey = () => { + const [fidoError, setFidoError] = useState("") + const [fidoLoader, setFidoLoader] = useState(false) + const [OrgUserEmail, setOrgUserEmail] = useState('') + const [deviceList, setDeviceList] = useState([]) + const [addSuccess, setAddSuccess] = useState(null) + const [addfailure, setAddFailur] = useState(null) + const [isEditProfileOpen, setIsEditProfileOpen] = useState(false); + const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(null); + + + const fetchUserProfile = async () => { + try { + const token = await getFromLocalStorage(storageKeys.TOKEN); + const userDetailsResponse = await getUserProfile(token); + const { data } = userDetailsResponse as AxiosResponse; + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + setPrePopulatedUserProfile(data?.data); } + } catch (error) { + } }; - const toggleEditProfile = async () => { - await fetchUserProfile() - setIsEditProfileOpen(!isEditProfileOpen); - }; + const toggleEditProfile = async () => { + await fetchUserProfile() + setIsEditProfileOpen(!isEditProfileOpen); + }; - const showFidoError = (error: unknown): void => { - const err = error as AxiosError - if (err.message.includes("The operation either timed out or was not allowed")) { - const [errorMsg] = err.message.split('.') - setFidoError(errorMsg) - setTimeout(() => { - setFidoError("") - }, 5000) - } else { - setFidoError(err.message) - setTimeout(() => { - setFidoError("") - }, 5000) - } + const showFidoError = (error: unknown): void => { + const err = error as AxiosError + if (err.message.includes("The operation either timed out or was not allowed")) { + const [errorMsg] = err.message.split('.') + setFidoError(errorMsg) + setTimeout(() => { + setFidoError("") + }, 5000) + } else { + setFidoError(err.message) + setTimeout(() => { + setFidoError("") + }, 5000) } + } - const addDevice = async (): Promise => { - try { - registerWithPasskey(true) - } catch (error) { - setFidoLoader(false) - } + const addDevice = async (): Promise => { + try { + registerWithPasskey(true) + } catch (error) { + setFidoLoader(false) } + } - const setProfile = async () => { - const UserEmail = await getFromLocalStorage(storageKeys.USER_EMAIL) - setOrgUserEmail(UserEmail) - return UserEmail - } + const setProfile = async () => { + const UserEmail = await getFromLocalStorage(storageKeys.USER_EMAIL) + setOrgUserEmail(UserEmail) + return UserEmail + } - useEffect(() => { - fetchUserProfile(); + useEffect(() => { + fetchUserProfile(); }, []); - const registerWithPasskey = async (flag: boolean): Promise => { - try { - const RegistrationOption: RegistrationOptionInterface = { - userName: OrgUserEmail, - deviceFlag: flag - } - // Generate Registration Option - const generateRegistrationResponse = await generateRegistrationOption(RegistrationOption) - const { data } = generateRegistrationResponse as AxiosResponse - const opts = data?.data - const challangeId = data?.data?.challenge - if (opts) { - opts.authenticatorSelection = { - residentKey: "preferred", - requireResidentKey: false, - userVerification: "preferred" - } - } - const attResp = await startRegistration(opts) - - const verifyRegistrationObj = { - ...attResp, - challangeId + const registerWithPasskey = async (flag: boolean): Promise => { + try { + const RegistrationOption: RegistrationOptionInterface = { + userName: OrgUserEmail, + deviceFlag: flag + } + // Generate Registration Option + const generateRegistrationResponse = await generateRegistrationOption(RegistrationOption) + const { data } = generateRegistrationResponse as AxiosResponse + const opts = data?.data + const challangeId = data?.data?.challenge + if (opts) { + opts.authenticatorSelection = { + residentKey: "preferred", + requireResidentKey: false, + userVerification: "preferred" } + } + const attResp = await startRegistration(opts) - await verifyRegistrationMethod(verifyRegistrationObj, OrgUserEmail); - } catch (error) { - showFidoError(error) + const verifyRegistrationObj = { + ...attResp, + challangeId } + + await verifyRegistrationMethod(verifyRegistrationObj, OrgUserEmail); + } catch (error) { + showFidoError(error) } + } - const verifyRegistrationMethod = async (verifyRegistrationObj, OrgUserEmail: string) => { - try { - const verificationRegisterResp = await verifyRegistration(verifyRegistrationObj, OrgUserEmail) - const { data } = verificationRegisterResp as AxiosResponse - const credentialID = data?.data?.newDevice?.credentialID + const verifyRegistrationMethod = async (verifyRegistrationObj, OrgUserEmail: string) => { + try { + const verificationRegisterResp = await verifyRegistration(verifyRegistrationObj, OrgUserEmail) + const { data } = verificationRegisterResp as AxiosResponse + const credentialID = data?.data?.newDevice?.credentialID - if (data?.data?.verified) { - let platformDeviceName = '' + if (data?.data?.verified) { + let platformDeviceName = '' - if (verifyRegistrationObj?.authenticatorAttachment === "cross-platform") { - platformDeviceName = 'Passkey' - } else { - platformDeviceName = navigator.platform - } + if (verifyRegistrationObj?.authenticatorAttachment === "cross-platform") { + platformDeviceName = 'Passkey' + } else { + platformDeviceName = navigator.platform + } - const deviceBody: IdeviceBody = { - userName: OrgUserEmail, - credentialId: credentialID, - deviceFriendlyName: platformDeviceName - } - await addDeviceDetailsMethod(deviceBody) + const deviceBody: IdeviceBody = { + userName: OrgUserEmail, + credentialId: credentialID, + deviceFriendlyName: platformDeviceName } - } catch (error) { - showFidoError(error) + await addDeviceDetailsMethod(deviceBody) } + } catch (error) { + showFidoError(error) } - - const addDeviceDetailsMethod = async (deviceBody: IdeviceBody) => { - try { - const deviceDetailsResp = await addDeviceDetails(deviceBody) - const { data } = deviceDetailsResp as AxiosResponse - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - setAddSuccess("Device added successfully") - userDeviceDetails() - } else { - setAddFailur(deviceDetailsResp as string) - } - setTimeout(() => { - setAddSuccess('') - setAddFailur('') - }, 3000); - } catch (error) { - showFidoError(error) + } + + const addDeviceDetailsMethod = async (deviceBody: IdeviceBody) => { + try { + const deviceDetailsResp = await addDeviceDetails(deviceBody) + const { data } = deviceDetailsResp as AxiosResponse + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + setAddSuccess("Device added successfully") + userDeviceDetails() + } else { + setAddFailur(deviceDetailsResp as string) } + setTimeout(() => { + setAddSuccess('') + setAddFailur('') + }, 3000); + } catch (error) { + showFidoError(error) } - - //userDeviceDetails on page reload - const userDeviceDetails = async (): Promise => { - try { - const config = { headers: {} } - setFidoLoader(true) - - const userDeviceDetailsResp = await getUserDeviceDetails(OrgUserEmail) - setFidoLoader(false) - - if (userDeviceDetailsResp) { - const deviceDetails = Object.keys(userDeviceDetailsResp?.data?.data)?.length > 0 ? - userDeviceDetailsResp?.data?.data.map((data) => { - data.lastChangedDateTime = dateConversion(data.lastChangedDateTime) ? dateConversion(data.lastChangedDateTime) : "-" - return data - }) - : [] - setDeviceList(deviceDetails) - } - } catch (error) { - setFidoLoader(false) + } + + //userDeviceDetails on page reload + const userDeviceDetails = async (): Promise => { + try { + const config = { headers: {} } + setFidoLoader(true) + + const userDeviceDetailsResp = await getUserDeviceDetails(OrgUserEmail) + setFidoLoader(false) + + if (userDeviceDetailsResp) { + const deviceDetails = Object.keys(userDeviceDetailsResp?.data?.data)?.length > 0 ? + userDeviceDetailsResp?.data?.data.map((data) => { + data.lastChangedDateTime = data.lastChangedDateTime ? data.lastChangedDateTime : "-" + return data + }) + : [] + setDeviceList(deviceDetails) } + } catch (error) { + setFidoLoader(false) } + } - useEffect(() => { - if (OrgUserEmail) { - userDeviceDetails(); - } else { - setProfile(); - } - }, [OrgUserEmail]); + useEffect(() => { + if (OrgUserEmail) { + userDeviceDetails(); + } else { + setProfile(); + } + }, [OrgUserEmail]); - const updatePrePopulatedUserProfile = (updatedProfile: UserProfile) => { - setPrePopulatedUserProfile(updatedProfile); - }; - - return ( + const updatePrePopulatedUserProfile = (updatedProfile: UserProfile) => { + setPrePopulatedUserProfile(updatedProfile); + }; -
- -

- User's Profile -

+ return ( + +
+ + + {fidoLoader + ?
+ + +
+ : +
+
+
+
    +
  • + +
  • +
  • + +
  • + {/*
  • + +
  • */} + +
+
- {fidoLoader - ?
- -
- : - -
- - {/* first section */} -
- - {!isEditProfileOpen && prePopulatedUserProfile && ( +
+
- )} - - {isEditProfileOpen && prePopulatedUserProfile && ( - - )} - -
- - {/* second section */} -
-
- -
- {deviceList && deviceList.length > 0 && - deviceList.map((element, key) => ( - - ))} + />
- -
- - {/* */} - { - (addSuccess || addfailure || fidoError) && -
- setAddSuccess(null)} - > - -

- {addSuccess || addfailure || fidoError} -

-
-
-
- } +
+
-
-
+
+ } +
+ ); +}; -
- } -
- ); - }; - - export default AddPasskey; +export default AddPasskey; diff --git a/src/components/Profile/DisplayUserProfile.tsx b/src/components/Profile/DisplayUserProfile.tsx index cce777def..112959bb6 100644 --- a/src/components/Profile/DisplayUserProfile.tsx +++ b/src/components/Profile/DisplayUserProfile.tsx @@ -1,17 +1,18 @@ import type { UserProfile } from "./interfaces"; import CustomAvatar from '../Avatar' +import { Formik } from "formik"; interface DisplayUserProfileProps { toggleEditProfile: () => void; userProfileInfo: UserProfile | null; - } - - const DisplayUserProfile = ({ toggleEditProfile, userProfileInfo }: DisplayUserProfileProps) => { +} + +const DisplayUserProfile = ({ toggleEditProfile, userProfileInfo }: DisplayUserProfileProps) => { return ( -
+
-
+ {/*
  • @@ -77,7 +78,49 @@ interface DisplayUserProfileProps {
+
*/} + +
+
+
+
+
+
+
+
+

General

+

Basic info, like your first name, last name and profile image that will be displayed

+
+ +
+
First Name
+
+ +
+
+ +
+
Last Name
+
+ +
+
+ +
+
Profile Image
+
+ +
+
+ +
+
+
+
+
+
+
); }; diff --git a/src/components/Profile/UpdatePassword.tsx b/src/components/Profile/UpdatePassword.tsx new file mode 100644 index 000000000..6830a748b --- /dev/null +++ b/src/components/Profile/UpdatePassword.tsx @@ -0,0 +1,48 @@ +import React from 'react' + +const UpdatePassword = () => { + return ( +
+
+
+
+
+
+
+
+

Password

+

Enter your current & new password to reset your password

+
+ +
+
Current Password
+
+ +
+
+ +
+
New Password
+
+ +
+
+ +
+
Confirm Password
+
+ +
+
+ +
+
+
+
+
+
+
+) +} + +export default UpdatePassword \ No newline at end of file diff --git a/src/components/organization/users/index.tsx b/src/components/organization/users/index.tsx index 6f1d00c49..eec2e9e3e 100644 --- a/src/components/organization/users/index.tsx +++ b/src/components/organization/users/index.tsx @@ -7,6 +7,7 @@ import BreadCrumbs from '../../BreadCrumbs'; import Invitations from '../invitations/Invitations'; import { MdDashboard } from 'react-icons/md'; import Members from './Members'; +import React from 'react'; const initialPageState = { pageNumber: 1, From c94c979a56c6292cf484267bff9b5a943dc95c8e Mon Sep 17 00:00:00 2001 From: MoulikaKulkarni Date: Wed, 13 Sep 2023 17:08:59 +0530 Subject: [PATCH 002/250] fix: date-tooltip Signed-off-by: MoulikaKulkarni --- src/components/Tooltip/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Tooltip/index.tsx b/src/components/Tooltip/index.tsx index ecb244868..28092d8ef 100644 --- a/src/components/Tooltip/index.tsx +++ b/src/components/Tooltip/index.tsx @@ -2,16 +2,20 @@ import { Tooltip } from 'flowbite-react'; import moment from 'moment'; import { dateConversion } from '../../utils/DateConversion'; import type { ChildrenType } from 'react-tooltip'; +import { useEffect } from 'react'; interface DateProps { - date?: Date + date: string id?: string children?: any } const DateTooltip = ({date, children}: DateProps) => { - const formattedDate = date ? moment(date).format("MMM DD, YYYY, h:mm A z") : ''; + + const updatedDate = new Date(date); + const formattedDate = date ? moment(updatedDate).format("MMM DD, YYYY, h:mm A z") : ''; + return ( Date: Wed, 13 Sep 2023 17:17:49 +0530 Subject: [PATCH 003/250] fix: date-tooltip Signed-off-by: MoulikaKulkarni --- src/components/Tooltip/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Tooltip/index.tsx b/src/components/Tooltip/index.tsx index 28092d8ef..912a20ba3 100644 --- a/src/components/Tooltip/index.tsx +++ b/src/components/Tooltip/index.tsx @@ -2,7 +2,6 @@ import { Tooltip } from 'flowbite-react'; import moment from 'moment'; import { dateConversion } from '../../utils/DateConversion'; import type { ChildrenType } from 'react-tooltip'; -import { useEffect } from 'react'; interface DateProps { date: string From 01ffe2cf326533c77780a4cec05b70be83a27800 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Wed, 13 Sep 2023 17:23:43 +0530 Subject: [PATCH 004/250] feat: standardized api Signed-off-by: bhavanakarwade --- src/api/Agent.ts | 2 +- src/api/Auth.ts | 21 +++++++------------ src/api/invitations.ts | 7 +++---- src/api/organization.ts | 18 ++++++++-------- .../Authentication/ResetPassword.tsx | 1 + .../Authentication/SignInUserPassword.tsx | 10 ++++----- src/components/Authentication/SignUpUser.tsx | 2 +- .../Authentication/SignUpUserPasskey.tsx | 6 ++++-- .../Authentication/SignUpUserPassword.tsx | 13 +++++++++--- .../organization/CreateOrgFormModal.tsx | 4 ++-- src/components/organization/Dashboard.tsx | 2 +- .../organization/DedicatedIllustrate.tsx | 1 + .../organization/EditOrgdetailsModal.tsx | 13 ++++++------ src/components/organization/WalletSpinup.tsx | 11 +++++----- .../organization/invitations/Invitations.tsx | 1 + .../invitations/ReceivedInvitations.tsx | 3 +-- 16 files changed, 59 insertions(+), 56 deletions(-) diff --git a/src/api/Agent.ts b/src/api/Agent.ts index 6e49da913..3e23c0d98 100644 --- a/src/api/Agent.ts +++ b/src/api/Agent.ts @@ -6,7 +6,7 @@ import { storageKeys } from "../config/CommonConstant"; export const getAgentHealth = async (orgId:number) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: `${apiRoutes.Agent.checkAgentHealth}?orgId=${orgId}`, + url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Agent.checkAgentHealth}`, config: { headers: { 'Content-type': 'application/json', diff --git a/src/api/Auth.ts b/src/api/Auth.ts index f60eadb10..fe4cee9e2 100644 --- a/src/api/Auth.ts +++ b/src/api/Auth.ts @@ -11,6 +11,7 @@ export interface UserSignUpData { email: string, } export interface AddPasswordDetails { + email:string password:string isPasskey:boolean firstName: string|null @@ -60,7 +61,7 @@ export const loginUser = async(payload: UserSignInData) => { export const getUserProfile = async(accessToken: string) => { const details = { - url: apiRoutes.auth.userProfile, + url: apiRoutes.users.userProfile, config : { headers: { Authorization: `Bearer ${accessToken}` } } } try{ @@ -112,14 +113,12 @@ export const verifyUserMail = async(payload: EmailVerifyData ) => { catch(error){ const err = error as Error return err?.message - } - - + } } export const checkUserExist = async(payload: string) => { const details ={ - url:`${apiRoutes.auth.checkUser}${payload}`, + url:`${apiRoutes.users.checkUser}${payload}`, config: { headers: { "Content-type": "application/json" } } } try{ @@ -129,14 +128,12 @@ export const checkUserExist = async(payload: string) => { catch(error){ const err = error as Error return err?.message - } - - + } } -export const addPasswordDetails = async(payload: AddPasswordDetails, email:string) => { +export const addPasswordDetails = async(payload: AddPasswordDetails) => { const details ={ - url: `${apiRoutes.auth.addDetails}${email}`, + url: `${apiRoutes.auth.addDetails}`, payload, config: { headers: { "Content-type": "application/json" } } } @@ -147,9 +144,7 @@ export const addPasswordDetails = async(payload: AddPasswordDetails, email:strin catch(error){ const err = error as Error return err?.message - } - - + } } export const passwordEncryption = (password: string): string => { diff --git a/src/api/invitations.ts b/src/api/invitations.ts index 396ae62ba..1d6f43a08 100644 --- a/src/api/invitations.ts +++ b/src/api/invitations.ts @@ -8,7 +8,7 @@ export const getOrganizationInvitations = async (pageNumber: number, pageSize: n const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - const url = `${apiRoutes.organizations.invitations}/${orgId}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.organizations.invitations}?&pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` const token = await getFromLocalStorage(storageKeys.TOKEN) @@ -36,7 +36,7 @@ export const createInvitations = async (invitationList: Array) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - const url = apiRoutes.organizations.invitations + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.organizations.invitations}` const payload = { invitations: invitationList, orgId: Number(orgId) @@ -94,10 +94,9 @@ export const getUserInvitations = async (pageNumber: number, pageSize: number, s // Accept/ Reject Invitations export const acceptRejectInvitations = async (invitationId: number,orgId: number, status: string) => { - const url = apiRoutes.users.invitations + const url = `${apiRoutes.users.invitations}/${invitationId}` const payload = { - invitationId, orgId: Number(orgId), status } diff --git a/src/api/organization.ts b/src/api/organization.ts index e53dba9d1..d41784384 100644 --- a/src/api/organization.ts +++ b/src/api/organization.ts @@ -32,9 +32,9 @@ export const createOrganization = async (data: object) => { } } -export const updateOrganization = async (data: object) => { +export const updateOrganization = async (data: object, orgId:string) => { - const url = apiRoutes.organizations.update + const url = `${apiRoutes.organizations.update}/${orgId}` const payload = data const token = await getFromLocalStorage(storageKeys.TOKEN) @@ -114,7 +114,7 @@ export const getOrganizationById = async (orgId: string) => { export const getOrgDashboard = async (orgId: string) => { - const url = `${apiRoutes.organizations.getOrgDashboard}?orgId=${Number(orgId)}` + const url = `${apiRoutes.organizations.getOrgDashboard}/${orgId}` const token = await getFromLocalStorage(storageKeys.TOKEN) @@ -138,9 +138,9 @@ export const getOrgDashboard = async (orgId: string) => { } } -export const spinupDedicatedAgent = async (data: object) => { +export const spinupDedicatedAgent = async (data: object, orgId:number) => { - const url = apiRoutes.organizations.agentDedicatedSpinup + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Agent.agentDedicatedSpinup}` const payload = data const token = await getFromLocalStorage(storageKeys.TOKEN) @@ -166,9 +166,9 @@ export const spinupDedicatedAgent = async (data: object) => { } } -export const spinupSharedAgent = async (data: object) => { +export const spinupSharedAgent = async (data: object, orgId:number) => { - const url = apiRoutes.organizations.agentSharedSpinup + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Agent.agentSharedSpinup}` const payload = data const token = await getFromLocalStorage(storageKeys.TOKEN) @@ -227,7 +227,7 @@ export const getOrganizationUsers = async (pageNumber: number, pageSize: number, const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - const url = `${apiRoutes.users.fetchUsers}?orgId=${orgId}&pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.users.fetchUsers}?&pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` const axiosPayload = { url, @@ -248,7 +248,7 @@ export const editOrganizationUserRole = async (userId: number, roles: number[]) const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - const url = apiRoutes.organizations.editUserROle + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.organizations.editUserROle}/${userId}` const payload = { orgId, userId, diff --git a/src/components/Authentication/ResetPassword.tsx b/src/components/Authentication/ResetPassword.tsx index fb56ef23d..e5e2e4a77 100644 --- a/src/components/Authentication/ResetPassword.tsx +++ b/src/components/Authentication/ResetPassword.tsx @@ -13,6 +13,7 @@ import PasswordSuggestionBox from './PasswordSuggestionBox.js'; import FooterBar from './FooterBar.js'; import NavBar from './NavBar.js'; import { PassInvisible, PassVisible, SignUpArrow } from './Svg.js'; +import React from 'react'; interface passwordValues { password: string; diff --git a/src/components/Authentication/SignInUserPassword.tsx b/src/components/Authentication/SignInUserPassword.tsx index 8ad30e955..08aa86854 100644 --- a/src/components/Authentication/SignInUserPassword.tsx +++ b/src/components/Authentication/SignInUserPassword.tsx @@ -9,7 +9,7 @@ import { Formik, } from 'formik'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; -import { getUserProfile, loginUser, passwordEncryption, setToLocalStorage } from '../../api/Auth'; +import { getFromLocalStorage, getUserProfile, loginUser, passwordEncryption, setToLocalStorage } from '../../api/Auth'; import { Alert } from 'flowbite-react'; import type { AxiosResponse } from 'axios'; @@ -47,23 +47,24 @@ const SignInUserPassword = (signInUserProps: SignInUser3Props) => { const getUserDetails = async (access_token: string) => { + const userDetails = await getUserProfile(access_token); const { data } = userDetails as AxiosResponse if (data?.data?.userOrgRoles?.length > 0) { + const permissionArray: number | string[] = [] data?.data?.userOrgRoles?.forEach((element: { orgRole: { name: string } }) => permissionArray.push(element?.orgRole?.name)); await setToLocalStorage(storageKeys.PERMISSIONS, permissionArray) await setToLocalStorage(storageKeys.USER_PROFILE, data?.data) await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email) - window.location.href = '/dashboard' } else { setFailure(userDetails as string) } + setLoading(false) } - const signInUser = async (values: passwordValue) => { const payload: SignInUser3Props = { email: email, @@ -73,10 +74,8 @@ const SignInUserPassword = (signInUserProps: SignInUser3Props) => { setLoading(true) const loginRsp = await loginUser(payload) const { data } = loginRsp as AxiosResponse - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { await setToLocalStorage(storageKeys.TOKEN, data?.data?.access_token) - const response = await fetch('/api/auth/signin', { method: "POST", headers: { @@ -88,7 +87,6 @@ const SignInUserPassword = (signInUserProps: SignInUser3Props) => { if (response.redirected) { getUserDetails(data?.data?.access_token) } - } else { setLoading(false) setFailure(loginRsp as string) diff --git a/src/components/Authentication/SignUpUser.tsx b/src/components/Authentication/SignUpUser.tsx index 8a4949a75..cac0bf13c 100644 --- a/src/components/Authentication/SignUpUser.tsx +++ b/src/components/Authentication/SignUpUser.tsx @@ -48,7 +48,7 @@ const SignUpUser = () => { setVerifyLoader(true) const userRsp = await sendVerificationMail(payload); const { data } = userRsp as AxiosResponse; - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { setVerificationSuccess(data?.message) setVerifyLoader(false) diff --git a/src/components/Authentication/SignUpUserPasskey.tsx b/src/components/Authentication/SignUpUserPasskey.tsx index 167c75a05..3159d4cac 100644 --- a/src/components/Authentication/SignUpUserPasskey.tsx +++ b/src/components/Authentication/SignUpUserPasskey.tsx @@ -21,7 +21,7 @@ interface passwordValues { confirmPassword: string } -const SignUpUserPasskey = ({ firstName, lastName }: { firstName: string; lastName: string }) => { +const SignUpUserPasskey = ({ email,firstName, lastName }: { email:string,firstName: string; lastName: string }) => { const [loading, setLoading] = useState(false) const [erroMsg, setErrMsg] = useState(null) @@ -61,6 +61,7 @@ const SignUpUserPasskey = ({ firstName, lastName }: { firstName: string; lastNam const submit = async (passwordDetails: passwordValues, fidoFlag: boolean) => { const userEmail = await getFromLocalStorage(storageKeys.USER_EMAIL) const payload = { + email: userEmail, password: passwordEncryption(passwordDetails?.password), isPasskey: false, firstName: firstName, @@ -68,7 +69,7 @@ const SignUpUserPasskey = ({ firstName, lastName }: { firstName: string; lastNam } setLoading(true) - const userRsp = await addPasswordDetails(payload, userEmail) + const userRsp = await addPasswordDetails(payload) const { data } = userRsp as AxiosResponse setLoading(false) if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { @@ -325,6 +326,7 @@ const SignUpUserPasskey = ({ firstName, lastName }: { firstName: string; lastNam { currentComponent === 'password' && ( diff --git a/src/components/Authentication/SignUpUserPassword.tsx b/src/components/Authentication/SignUpUserPassword.tsx index 08d129bf5..6fefe3f8f 100644 --- a/src/components/Authentication/SignUpUserPassword.tsx +++ b/src/components/Authentication/SignUpUserPassword.tsx @@ -22,16 +22,20 @@ import NavBar from './NavBar.js'; import FooterBar from './FooterBar.js'; import PasswordSuggestionBox from './PasswordSuggestionBox.js'; import { PassInvisible, PassVisible, SignUpArrow } from './Svg.js'; +import React from 'react'; interface passwordValues { + email: string; password: string; confirmPassword: string; } const SignUpUserPassword = ({ + email, firstName, lastName, }: { + email: string, firstName: string; lastName: string; }) => { @@ -44,16 +48,18 @@ const SignUpUserPassword = ({ const [showSuggestion, setShowSuggestion] = useState(false); const submit = async (passwordDetails: passwordValues, fidoFlag: boolean) => { + const userEmail = await getFromLocalStorage(storageKeys.USER_EMAIL); const payload = { + email: userEmail, password: passwordEncryption(passwordDetails?.password), isPasskey: false, firstName, lastName, }; + setLoading(true); - const userEmail = await getFromLocalStorage(storageKeys.USER_EMAIL); - const userRsp = await addPasswordDetails(payload, userEmail); + const userRsp = await addPasswordDetails(payload); const { data } = userRsp as AxiosResponse; setLoading(false); if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { @@ -69,6 +75,7 @@ const SignUpUserPassword = ({ }; const initialValues = { + email: email, firstName: '', lastName: '', password: '', @@ -89,7 +96,7 @@ const SignUpUserPassword = ({ return (
{showSignUpUser ? ( - + ) : (
diff --git a/src/components/organization/CreateOrgFormModal.tsx b/src/components/organization/CreateOrgFormModal.tsx index 5883ef79a..2d57380b9 100644 --- a/src/components/organization/CreateOrgFormModal.tsx +++ b/src/components/organization/CreateOrgFormModal.tsx @@ -185,8 +185,8 @@ const CreateOrgFormModal = (props: { openModal: boolean; setMessage: (message: s .trim(), description: yup .string() - .min(2, 'Organization name must be at least 2 characters') - .max(255, 'Organization name must be at most 255 characters') + .min(2, 'Description must be at least 2 characters') + .max(255, 'Description must be at most 255 characters') .required('Description is required') })} validateOnBlur diff --git a/src/components/organization/Dashboard.tsx b/src/components/organization/Dashboard.tsx index d9a3d554c..0ae39b063 100644 --- a/src/components/organization/Dashboard.tsx +++ b/src/components/organization/Dashboard.tsx @@ -10,13 +10,13 @@ import Credential_Card from '../../assets/Credential_Card.svg'; import CustomAvatar from '../Avatar'; import CustomSpinner from '../CustomSpinner'; import EditOrgdetailsModal from './EditOrgdetailsModal'; -import Invitation_Card from '../../assets/Invitation_Card.svg'; import OrganizationDetails from './OrganizationDetails'; import Schema_Card from '../../assets/Schema_Card.svg'; import User_Card from '../../assets/User_Card.svg'; import WalletSpinup from './WalletSpinup'; import { getFromLocalStorage } from '../../api/Auth'; import { pathRoutes } from '../../config/pathRoutes'; +import React from 'react'; const Dashboard = () => { const [orgData, setOrgData] = useState(null); diff --git a/src/components/organization/DedicatedIllustrate.tsx b/src/components/organization/DedicatedIllustrate.tsx index 3686b3e4d..6b4c9ba53 100644 --- a/src/components/organization/DedicatedIllustrate.tsx +++ b/src/components/organization/DedicatedIllustrate.tsx @@ -1,3 +1,4 @@ +import React from 'react'; import DedicatedIcon from '../../assets/dedicated.svg'; const DedicatedIllustrate = () => { diff --git a/src/components/organization/EditOrgdetailsModal.tsx b/src/components/organization/EditOrgdetailsModal.tsx index 57d742a48..50534a264 100644 --- a/src/components/organization/EditOrgdetailsModal.tsx +++ b/src/components/organization/EditOrgdetailsModal.tsx @@ -2,14 +2,15 @@ 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 } from '../../config/CommonConstant' +import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted, storageKeys } from '../../config/CommonConstant' import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; import { useEffect, useState } from "react"; import { AlertComponent } from "../AlertComponent"; import type { AxiosResponse } from 'axios'; -// import { asset } from '../../lib/data.js'; import { updateOrganization } from "../../api/organization"; import type { Organisation } from "./interfaces"; +import React from "react"; +import { getFromLocalStorage } from "../../api/Auth"; interface Values { name: string; @@ -159,14 +160,14 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps)=> { setLoading(true) const orgData = { - orgId: props?.orgData?.id, name: values.name, description: values.description, logo: logoImage?.imagePreviewUrl as string || props?.orgData?.logoUrl, website: "" } + const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - const resUpdateOrg = await updateOrganization(orgData) + const resUpdateOrg = await updateOrganization(orgData, orgId as string) const { data } = resUpdateOrg as AxiosResponse setLoading(false) @@ -219,8 +220,8 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps)=> { .trim(), description: yup .string() - .min(2, 'Organization name must be at least 2 characters') - .max(255, 'Organization name must be at most 255 characters') + .min(2, 'Description must be at least 2 characters') + .max(255, 'Description must be at most 255 characters') .required('Description is required') })} validateOnBlur diff --git a/src/components/organization/WalletSpinup.tsx b/src/components/organization/WalletSpinup.tsx index 4f356ae04..fd5cf3391 100644 --- a/src/components/organization/WalletSpinup.tsx +++ b/src/components/organization/WalletSpinup.tsx @@ -20,6 +20,7 @@ import InputCopy from '../InputCopy'; import SOCKET from '../../config/SocketConfig'; import SharedIllustrate from './SharedIllustrate'; import { nanoid } from 'nanoid'; +import React from 'react'; interface Values { seed: string; @@ -86,17 +87,16 @@ const WalletSpinup = (props: { }; const submitDedicatedWallet = async (values: Values) => { - const orgId = await getFromLocalStorage(storageKeys.ORG_ID); const payload = { walletName: values.name, seed: seeds, - orgId: Number(orgId), walletPassword: passwordEncryption(values.password), clientSocketId: SOCKET.id, }; setLoading(true); - const spinupRes = await spinupDedicatedAgent(payload); + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); + const spinupRes = await spinupDedicatedAgent(payload, parseInt(orgId)); const { data } = spinupRes as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { @@ -113,16 +113,15 @@ const WalletSpinup = (props: { const submitSharedWallet = async (values: ValuesShared) => { setLoading(true); - const orgId = await getFromLocalStorage(storageKeys.ORG_ID); const payload = { label: values.label, seed: seeds, - orgId: Number(orgId), clientSocketId: SOCKET.id, }; + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - const spinupRes = await spinupSharedAgent(payload); + const spinupRes = await spinupSharedAgent(payload, parseInt(orgId)); const { data } = spinupRes as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { diff --git a/src/components/organization/invitations/Invitations.tsx b/src/components/organization/invitations/Invitations.tsx index 4e3fceac6..2fdfe1876 100644 --- a/src/components/organization/invitations/Invitations.tsx +++ b/src/components/organization/invitations/Invitations.tsx @@ -17,6 +17,7 @@ import { getOrganizations } from '../../../api/organization'; import CustomSpinner from '../../CustomSpinner'; import { dateConversion } from '../../../utils/DateConversion'; import DateTooltip from '../../Tooltip'; +import React from 'react'; const initialPageState = { pageNumber: 1, diff --git a/src/components/organization/invitations/ReceivedInvitations.tsx b/src/components/organization/invitations/ReceivedInvitations.tsx index 916d0b62c..8cb2984dc 100644 --- a/src/components/organization/invitations/ReceivedInvitations.tsx +++ b/src/components/organization/invitations/ReceivedInvitations.tsx @@ -94,8 +94,7 @@ const ReceivedInvitations = () => { setLoading(true) const response = await acceptRejectInvitations(invite.id, invite.orgId, status); const { data } = response as AxiosResponse - - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { setMessage(data?.message) setLoading(false) window.location.href = pathRoutes.organizations.root From 1fb80cee4ae7e7833a6ff41a2a3debff19f95638 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Wed, 13 Sep 2023 17:25:10 +0530 Subject: [PATCH 005/250] feat: standardized api Signed-off-by: bhavanakarwade --- .../invitations/SendInvitationModal.tsx | 1 + .../organization/users/EditUserRolesModal.tsx | 1 + src/components/organization/users/index.tsx | 1 + src/config/apiRoutes.ts | 39 ++++++++++--------- src/config/pathRoutes.ts | 2 +- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/components/organization/invitations/SendInvitationModal.tsx b/src/components/organization/invitations/SendInvitationModal.tsx index a66b17410..4dc29add9 100644 --- a/src/components/organization/invitations/SendInvitationModal.tsx +++ b/src/components/organization/invitations/SendInvitationModal.tsx @@ -9,6 +9,7 @@ import type { AxiosResponse } from 'axios'; import { apiStatusCodes } from "../../../config/CommonConstant"; import { createInvitations } from "../../../api/invitations"; import { getOrganizationRoles } from "../../../api/organization"; +import React from "react"; interface Values { email: string; diff --git a/src/components/organization/users/EditUserRolesModal.tsx b/src/components/organization/users/EditUserRolesModal.tsx index e4be018ac..8717cf7f0 100644 --- a/src/components/organization/users/EditUserRolesModal.tsx +++ b/src/components/organization/users/EditUserRolesModal.tsx @@ -6,6 +6,7 @@ import type { AxiosResponse } from 'axios'; import { TextTittlecase } from '../../../utils/TextTransform'; import type { User } from "../interfaces/users"; import { apiStatusCodes } from "../../../config/CommonConstant"; +import React from 'react'; interface RoleI { id: number diff --git a/src/components/organization/users/index.tsx b/src/components/organization/users/index.tsx index 6f1d00c49..eec2e9e3e 100644 --- a/src/components/organization/users/index.tsx +++ b/src/components/organization/users/index.tsx @@ -7,6 +7,7 @@ import BreadCrumbs from '../../BreadCrumbs'; import Invitations from '../invitations/Invitations'; import { MdDashboard } from 'react-icons/md'; import Members from './Members'; +import React from 'react'; const initialPageState = { pageNumber: 1, diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index da347f155..8fc3925da 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -2,30 +2,29 @@ import { verifyPresentation } from "../api/verification"; export const apiRoutes = { auth:{ - sendMail: '/users/send-mail', - sinIn: '/users/login', - verifyEmail:'/users/verify', - userProfile: 'users/profile', - checkUser:'/users/check-user/', - addDetails:'/users/add/' + sendMail:'/auth/verification-mail', + sinIn: '/auth/signin', + verifyEmail:'/auth/verify', + addDetails:'/auth/signup' }, users:{ - invitations: '/users/invitations', + userProfile: '/users/profile', + checkUser:'/users/', + invitations: '/users/org-invitations', fetchUsers: '/users', update: '/users', recentActivity: '/users/activity', }, organizations: { - create: '/organization', - update: '/organization', - getAll: '/organization', - getById: '/organization', - getOrgDashboard: '/organization/dashboard', - agentDedicatedSpinup: '/agent-service/spinup', - agentSharedSpinup: '/agent-service/tenant', - invitations: '/organization/invitations', - orgRoles: '/organization/roles', - editUserROle: '/organization/user-roles' + root: '/orgs', + create: '/orgs', + update: '/orgs', + getAll: '/orgs', + getById: '/orgs', + getOrgDashboard: '/orgs/dashboard', + invitations: '/invitations', + orgRoles: '/orgs/roles', + editUserROle: '/user-roles' }, connection: { create: '/connections', @@ -59,10 +58,12 @@ export const apiRoutes = { getAllRequestList: '/proofs', verifyCredential:'/proofs/request-proof', presentationVerification:'/proofs/verify-presentation', - proofRequestAttributesVerification:'/proofs/form-data' + proofRequestAttributesVerification:'/proofs/form-data' }, Agent:{ - checkAgentHealth: '/agent-service/health', + checkAgentHealth: '/agents/health', + agentDedicatedSpinup: '/agents/spinup', + agentSharedSpinup: '/agents/wallet' } } diff --git a/src/config/pathRoutes.ts b/src/config/pathRoutes.ts index b6a0dca75..a36ca1ca9 100644 --- a/src/config/pathRoutes.ts +++ b/src/config/pathRoutes.ts @@ -2,7 +2,7 @@ export const pathRoutes = { auth: { signUp: '/authentication/sign-up', sinIn: '/authentication/sign-in', - verifyEmail: '/users/verify', + verifyEmail: '/auth/verify', }, users: { dashboard: '/dashboard', From 1e8f7dfdd30dc8522da942d44735bfe7ba5667ce Mon Sep 17 00:00:00 2001 From: MoulikaKulkarni Date: Wed, 13 Sep 2023 17:42:18 +0530 Subject: [PATCH 006/250] fix: date-tooltip Signed-off-by: MoulikaKulkarni --- package-lock.json | 180 --------------------- src/commonComponents/DeviceDetailsCard.tsx | 4 +- 2 files changed, 1 insertion(+), 183 deletions(-) diff --git a/package-lock.json b/package-lock.json index 61136c553..56b58d11b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1353,15 +1353,6 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, - "node_modules/@types/jsonwebtoken": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", - "integrity": "sha512-drE6uz7QBKq1fYqqoFKTDRdFCPHd5TCub75BM+D+cMx7NU9hUz7SESLfC2fSCXVFMO5Yj8sOWHuGqPgjc+fz0Q==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/mdast": { "version": "3.0.12", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.12.tgz", @@ -2384,11 +2375,6 @@ "ieee754": "^1.2.1" } }, - "node_modules/buffer-equal-constant-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", - "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" - }, "node_modules/bufferutil": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", @@ -3105,14 +3091,6 @@ "resolved": "https://registry.npmjs.org/easy-bem/-/easy-bem-1.1.1.tgz", "integrity": "sha512-GJRqdiy2h+EXy6a8E6R+ubmqUM08BK0FWNq41k24fup6045biQ8NXxoXimiwegMQvFFV3t1emADdGNL1TlS61A==" }, - "node_modules/ecdsa-sig-formatter": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", - "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, "node_modules/electron-to-chromium": { "version": "1.4.484", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.484.tgz", @@ -5427,46 +5405,6 @@ "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.3.1.tgz", "integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==" }, - "node_modules/jsonwebtoken": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", - "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", - "dependencies": { - "jws": "^3.2.2", - "lodash.includes": "^4.3.0", - "lodash.isboolean": "^3.0.3", - "lodash.isinteger": "^4.0.4", - "lodash.isnumber": "^3.0.3", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.once": "^4.0.0", - "ms": "^2.1.1", - "semver": "^7.5.4" - }, - "engines": { - "node": ">=12", - "npm": ">=6" - } - }, - "node_modules/jwa": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", - "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", - "dependencies": { - "buffer-equal-constant-time": "1.0.1", - "ecdsa-sig-formatter": "1.0.11", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/jws": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", - "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", - "dependencies": { - "jwa": "^1.4.1", - "safe-buffer": "^5.0.1" - } - }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -5580,46 +5518,16 @@ "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz", "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==" }, - "node_modules/lodash.includes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" - }, - "node_modules/lodash.isboolean": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", - "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" - }, - "node_modules/lodash.isinteger": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", - "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" - }, - "node_modules/lodash.isnumber": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", - "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" - }, "node_modules/lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" }, - "node_modules/lodash.isstring": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" - }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, - "node_modules/lodash.once": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" - }, "node_modules/log-symbols": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-5.1.0.tgz", @@ -13383,15 +13291,6 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, - "@types/jsonwebtoken": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", - "integrity": "sha512-drE6uz7QBKq1fYqqoFKTDRdFCPHd5TCub75BM+D+cMx7NU9hUz7SESLfC2fSCXVFMO5Yj8sOWHuGqPgjc+fz0Q==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/mdast": { "version": "3.0.12", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.12.tgz", @@ -14120,11 +14019,6 @@ "ieee754": "^1.2.1" } }, - "buffer-equal-constant-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", - "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" - }, "bufferutil": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", @@ -14597,14 +14491,6 @@ "resolved": "https://registry.npmjs.org/easy-bem/-/easy-bem-1.1.1.tgz", "integrity": "sha512-GJRqdiy2h+EXy6a8E6R+ubmqUM08BK0FWNq41k24fup6045biQ8NXxoXimiwegMQvFFV3t1emADdGNL1TlS61A==" }, - "ecdsa-sig-formatter": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", - "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", - "requires": { - "safe-buffer": "^5.0.1" - } - }, "electron-to-chromium": { "version": "1.4.484", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.484.tgz", @@ -16250,42 +16136,6 @@ "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.3.1.tgz", "integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==" }, - "jsonwebtoken": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", - "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", - "requires": { - "jws": "^3.2.2", - "lodash.includes": "^4.3.0", - "lodash.isboolean": "^3.0.3", - "lodash.isinteger": "^4.0.4", - "lodash.isnumber": "^3.0.3", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.once": "^4.0.0", - "ms": "^2.1.1", - "semver": "^7.5.4" - } - }, - "jwa": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", - "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", - "requires": { - "buffer-equal-constant-time": "1.0.1", - "ecdsa-sig-formatter": "1.0.11", - "safe-buffer": "^5.0.1" - } - }, - "jws": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", - "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", - "requires": { - "jwa": "^1.4.1", - "safe-buffer": "^5.0.1" - } - }, "kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -16374,46 +16224,16 @@ "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz", "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==" }, - "lodash.includes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" - }, - "lodash.isboolean": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", - "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" - }, - "lodash.isinteger": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", - "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" - }, - "lodash.isnumber": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", - "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" - }, "lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" }, - "lodash.isstring": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" - }, "lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, - "lodash.once": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" - }, "log-symbols": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-5.1.0.tgz", diff --git a/src/commonComponents/DeviceDetailsCard.tsx b/src/commonComponents/DeviceDetailsCard.tsx index afe84ccde..738cff853 100644 --- a/src/commonComponents/DeviceDetailsCard.tsx +++ b/src/commonComponents/DeviceDetailsCard.tsx @@ -98,9 +98,7 @@ const DeviceDetails = (props: { deviceFriendlyName: string, createDateTime: stri

- - {dateConversion(new Date(props.createDateTime).toLocaleDateString('en-GB'))} -

+ {dateConversion(props?.createDateTime)}

{props.credentialID}

From 2da65f128ebb1cbf79ad72a441c0a7d78a5f5e36 Mon Sep 17 00:00:00 2001 From: MoulikaKulkarni Date: Wed, 13 Sep 2023 17:51:30 +0530 Subject: [PATCH 007/250] fix: date-tooltip Signed-off-by: MoulikaKulkarni --- src/commonComponents/DeviceDetailsCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonComponents/DeviceDetailsCard.tsx b/src/commonComponents/DeviceDetailsCard.tsx index 738cff853..7999bd8ed 100644 --- a/src/commonComponents/DeviceDetailsCard.tsx +++ b/src/commonComponents/DeviceDetailsCard.tsx @@ -58,7 +58,7 @@ const DeviceDetails = (props: { deviceFriendlyName: string, createDateTime: stri } setTimeout(() => { props.refreshList() - }, 4000); + }, 6000); } From 4b8bad6ecc969186d917182209a615e3e61904ac Mon Sep 17 00:00:00 2001 From: Nishad Shirsat <103021375+nishad-ayanworks@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:55:31 +0530 Subject: [PATCH 008/250] refactor: user role management for schema, cred-def, issuence and verification feature (#255) * worked on the user role management for schema and cred-def feature Signed-off-by: @nishad.shirsat * removed unnecessary code from files Signed-off-by: @nishad.shirsat * Worked on the user role manage for issuance Signed-off-by: @nishad.shirsat * Worked on the user role manage for verification Signed-off-by: @nishad.shirsat * Modified if condition in role view button Signed-off-by: @nishad.shirsat --------- Signed-off-by: @nishad.shirsat --- .../CredentialDefinitionCard.tsx | 28 ++++++++-- src/components/Issuance/IssuedCrdentials.tsx | 51 ++++++++----------- .../Resources/Schema/SchemasList.tsx | 50 +++++++++--------- .../Resources/Schema/ViewSchema.tsx | 47 +++++++++++++---- src/components/RoleViewButton/index.tsx | 18 ++++++- .../VerificationCredentialList.tsx | 48 ++++++++--------- src/utils/enums/features.ts | 5 +- 7 files changed, 152 insertions(+), 95 deletions(-) diff --git a/src/commonComponents/CredentialDefinitionCard.tsx b/src/commonComponents/CredentialDefinitionCard.tsx index d99d9f22a..e4514c174 100644 --- a/src/commonComponents/CredentialDefinitionCard.tsx +++ b/src/commonComponents/CredentialDefinitionCard.tsx @@ -1,17 +1,33 @@ import { Button, Card } from 'flowbite-react'; -const CredDeffCard = (props: { credDeffName: string, credentialDefinitionId: string, schemaId: string, revocable: boolean, onClickCallback: (schemaId: string, credentialDefinitionId: string) => void; }) => { - return ( - { +import { Roles } from '../utils/enums/roles'; + +const CredDeffCard = (props: { credDeffName: string, userRoles?:string[], credentialDefinitionId: string, schemaId: string, revocable: boolean, onClickCallback: (schemaId: string, credentialDefinitionId: string) => void; }) => { + + const redirectToIssuance = () => { + if (props?.userRoles?.includes(Roles.OWNER) + || props?.userRoles?.includes(Roles.ADMIN) + || props?.userRoles?.includes(Roles.ISSUER)) { props.onClickCallback(props.schemaId, props.credentialDefinitionId) - }} className=' cursor-pointer overflow-hidden overflow-ellipsis' style={{ maxHeight: '100%', maxWidth: '100%', overflow: 'auto' }}> + + } + } + + return ( +
{/* This will take up 2/3 of the available width on larger screens */}
{props.credDeffName}
-
+ { + props.userRoles + && (props.userRoles.includes(Roles.OWNER) + || props.userRoles.includes(Roles.ADMIN) + || props.userRoles.includes(Roles.ISSUER) + ) + &&
+ } +

diff --git a/src/components/Issuance/IssuedCrdentials.tsx b/src/components/Issuance/IssuedCrdentials.tsx index 4c63f633c..b6676bb03 100644 --- a/src/components/Issuance/IssuedCrdentials.tsx +++ b/src/components/Issuance/IssuedCrdentials.tsx @@ -1,7 +1,7 @@ 'use client'; import { ChangeEvent, useEffect, useState } from 'react'; -import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; +import { IssueCredential, IssueCredentialUserText } from '../../common/enums'; import { AlertComponent } from '../AlertComponent'; import type { AxiosResponse } from 'axios'; @@ -9,15 +9,17 @@ import BreadCrumbs from '../BreadCrumbs'; import { Button } from 'flowbite-react'; import CustomSpinner from '../CustomSpinner'; import DataTable from '../../commonComponents/datatable'; +import DateTooltip from '../Tooltip'; import { EmptyListMessage } from '../EmptyListComponent'; -import { IssueCredential, IssueCredentialUserText } from '../../common/enums'; +import { Features } from '../../utils/enums/features'; import React from 'react'; +import RoleViewButton from '../RoleViewButton'; import SearchInput from '../SearchInput'; import type { TableData } from '../../commonComponents/datatable/interface'; +import { apiStatusCodes } from '../../config/CommonConstant'; import { dateConversion } from '../../utils/DateConversion'; import { getIssuedCredentials } from '../../api/issuance'; import { pathRoutes } from '../../config/pathRoutes'; -import DateTooltip from '../Tooltip'; interface IssuedCredential { metadata: { [x: string]: { schemaId: string } }; @@ -147,32 +149,23 @@ const CredentialList = () => {

-
-
- -
+
+
+ + + + + + } + onClickEvent={schemeSelection} + /> + +
void; }) => { const [schemaList, setSchemaList] = useState([]) @@ -136,8 +139,8 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD - {options.map((opt) => (
-
- + />
@@ -182,8 +186,8 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD } {loading ? (
- - + +
) : schemaList && schemaList.length > 0 ? ( @@ -199,7 +203,7 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD
- {schemaList.length> 0 &&( 0 && ( { setSchemaListAPIParameter(prevState => ({ @@ -213,8 +217,8 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD
) : ( + buttonContent={'Create'} + svgComponent={ } onClick={() => { diff --git a/src/components/Resources/Schema/ViewSchema.tsx b/src/components/Resources/Schema/ViewSchema.tsx index 3f6851d21..495fd22ad 100644 --- a/src/components/Resources/Schema/ViewSchema.tsx +++ b/src/components/Resources/Schema/ViewSchema.tsx @@ -1,20 +1,23 @@ +import * as yup from 'yup'; import { Alert, Button, Card, Label, Pagination } from 'flowbite-react'; import { Field, Form, Formik } from 'formik'; -import { useEffect, useState } from 'react'; -import BreadCrumbs from '../../BreadCrumbs'; -import * as yup from 'yup'; import { apiStatusCodes, storageKeys } from '../../../config/CommonConstant'; -import CredDeffCard from '../../../commonComponents/CredentialDefinitionCard'; import { createCredentialDefinition, getCredDeffById, getSchemaById } from '../../../api/Schema'; +import { getFromLocalStorage, setToLocalStorage } from '../../../api/Auth'; +import { useEffect, useState } from 'react'; + import type { AxiosResponse } from 'axios'; +import BreadCrumbs from '../../BreadCrumbs'; +import CredDeffCard from '../../../commonComponents/CredentialDefinitionCard'; import type { CredDeffFieldNameType } from './interfaces'; -import { getFromLocalStorage, setToLocalStorage } from '../../../api/Auth'; +import CustomSpinner from '../../CustomSpinner'; import { EmptyListMessage } from '../../EmptyListComponent'; +import React from 'react'; +import { Roles } from '../../../utils/enums/roles'; +import SchemaCard from '../../../commonComponents/SchemaCard'; import { nanoid } from 'nanoid'; import { pathRoutes } from '../../../config/pathRoutes'; -import CustomSpinner from '../../CustomSpinner'; -import React from 'react'; interface Values { tagName: string; @@ -51,6 +54,9 @@ const ViewSchemas = () => { const [orgId, setOrgId] = useState(0) const [credDefAuto, setCredDefAuto] = useState('') + const [userRoles, setUserRoles] = useState([]) + + const getSchemaDetails = async (id: string, organizationId: number) => { try { setLoading(true); @@ -109,6 +115,16 @@ const ViewSchemas = () => { fetchData(); }, []); + const getUserRoles = async () => { + const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) + const roles = orgRoles.split(',') + setUserRoles(roles) + } + + useEffect(() => { + getUserRoles() + },[]) + const submit = async (values: Values) => { setCreateLoader(true) @@ -241,7 +257,11 @@ const ViewSchemas = () => {
)} - + { + (userRoles.includes(Roles.OWNER) + || userRoles.includes(Roles.ADMIN)) + + &&
Create Credential Definition @@ -364,6 +384,8 @@ const ViewSchemas = () => {
+ + } <> @@ -392,7 +414,14 @@ const ViewSchemas = () => { {credDeffList && credDeffList.length > 0 && credDeffList.map((element, key) => (
- +
)) } diff --git a/src/components/RoleViewButton/index.tsx b/src/components/RoleViewButton/index.tsx index 4ed94b180..1c2f0616b 100644 --- a/src/components/RoleViewButton/index.tsx +++ b/src/components/RoleViewButton/index.tsx @@ -32,7 +32,23 @@ const RoleViewButton = ({ buttonTitle, svgComponent, onClickEvent, feature }: Ro if(feature === Features.CRETAE_ORG){ return true - } else if (userRoles.includes(Roles.OWNER) || userRoles.includes(Roles.ADMIN)) { + } else if (feature === Features.ISSUENCE) { + if (userRoles.includes(Roles.OWNER) + || userRoles.includes(Roles.ADMIN) + || userRoles.includes(Roles.ISSUER) + ) { + return true + } + return false + }else if (feature === Features.VERIFICATION) { + if (userRoles.includes(Roles.OWNER) + || userRoles.includes(Roles.ADMIN) + || userRoles.includes(Roles.VERIFIER) + ) { + return true + } + return false + }else if (userRoles.includes(Roles.OWNER) || userRoles.includes(Roles.ADMIN)) { return true } else { return false diff --git a/src/components/Verification/VerificationCredentialList.tsx b/src/components/Verification/VerificationCredentialList.tsx index 26dcf9d66..7be364f3a 100644 --- a/src/components/Verification/VerificationCredentialList.tsx +++ b/src/components/Verification/VerificationCredentialList.tsx @@ -1,7 +1,11 @@ 'use client'; -import { Alert, Button, Pagination } from 'flowbite-react'; +import { Alert, Button } from 'flowbite-react'; import { ChangeEvent, useEffect, useState } from 'react'; +import { + ProofRequestState, + ProofRequestStateUserText, +} from '../../common/enums'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; import { getProofAttributes, @@ -12,22 +16,20 @@ import { import { AlertComponent } from '../AlertComponent'; import type { AxiosResponse } from 'axios'; import BreadCrumbs from '../BreadCrumbs'; +import CustomSpinner from '../CustomSpinner'; import DataTable from '../../commonComponents/datatable'; +import DateTooltip from '../Tooltip'; import { EmptyListMessage } from '../EmptyListComponent'; +import { Features } from '../../utils/enums/features'; import ProofRequest from './ProofRequestPopup'; -import { - ProofRequestState, - ProofRequestStateUserText, -} from '../../common/enums'; import React from 'react'; import type { RequestProof } from './interface'; +import RoleViewButton from '../RoleViewButton'; import SearchInput from '../SearchInput'; import type { TableData } from '../../commonComponents/datatable/interface'; import { dateConversion } from '../../utils/DateConversion'; import { pathRoutes } from '../../config/pathRoutes'; import { removeFromLocalStorage } from '../../api/Auth'; -import CustomSpinner from '../CustomSpinner'; -import DateTooltip from '../Tooltip'; const VerificationCredentialList = () => { const [loading, setLoading] = useState(true); @@ -273,27 +275,19 @@ const VerificationCredentialList = () => {
-
-
- + } + onClickEvent={schemeSelection} + />
{ (proofReqSuccess || errMsg) && ( diff --git a/src/utils/enums/features.ts b/src/utils/enums/features.ts index bd1fe8aee..cc574a15e 100644 --- a/src/utils/enums/features.ts +++ b/src/utils/enums/features.ts @@ -2,5 +2,8 @@ export enum Features { SEND_INVITATION = 'send_invitations', - CRETAE_ORG = 'create_org' + CRETAE_ORG = 'create_org', + CRETAE_SCHEMA = 'create_schema', + ISSUENCE = 'issuence', + VERIFICATION = 'verification' } \ No newline at end of file From a5eea25dad756c21ad7713af3a44bad75a7e3da3 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 14 Sep 2023 12:04:22 +0530 Subject: [PATCH 009/250] feat: refactor API's Signed-off-by: bhavanakarwade --- src/api/Auth.ts | 2 +- src/api/Fido.ts | 2 +- src/components/Authentication/ResetPassword.tsx | 1 - src/components/Authentication/SignUpUserPasskey.tsx | 1 + src/components/Profile/AddPasskey.tsx | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/Auth.ts b/src/api/Auth.ts index fd1c838f3..7f57a2085 100644 --- a/src/api/Auth.ts +++ b/src/api/Auth.ts @@ -12,7 +12,7 @@ export interface UserSignUpData { email: string, } export interface AddPasswordDetails { - // email:string + email:string password:string | undefined isPasskey:boolean firstName: string|null diff --git a/src/api/Fido.ts b/src/api/Fido.ts index a1fa56e87..7016a906c 100644 --- a/src/api/Fido.ts +++ b/src/api/Fido.ts @@ -27,7 +27,7 @@ export const generateRegistrationOption = async (payload: RegistrationOptionInte } } -export const verifyRegistration = async (payload, userEmail:string) => { +export const verifyRegistration = async (payload:any, userEmail:string) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { url: `${apiRoutes.fido.verifyRegistration}${userEmail}`, diff --git a/src/components/Authentication/ResetPassword.tsx b/src/components/Authentication/ResetPassword.tsx index ff6fcb2c8..602eeba43 100644 --- a/src/components/Authentication/ResetPassword.tsx +++ b/src/components/Authentication/ResetPassword.tsx @@ -13,7 +13,6 @@ import FooterBar from './FooterBar.js'; import NavBar from './NavBar.js'; import { addPasskeyUserDetails, passwordEncryption, setToLocalStorage } from '../../api/Auth.js'; import type { AxiosResponse } from 'axios'; -import React from 'react'; import { PassInvisible, PassVisible, SignUpArrow } from './Svg.js'; import React from 'react'; diff --git a/src/components/Authentication/SignUpUserPasskey.tsx b/src/components/Authentication/SignUpUserPasskey.tsx index fb33d57dd..112199503 100644 --- a/src/components/Authentication/SignUpUserPasskey.tsx +++ b/src/components/Authentication/SignUpUserPasskey.tsx @@ -63,6 +63,7 @@ const SignUpUserPasskey = ({ email,firstName, lastName }: { email:string,firstNa const userEmail = await getFromLocalStorage(storageKeys.USER_EMAIL) const password: string = uuidv4(); let payload: AddPasswordDetails = { + email: userEmail, isPasskey: fidoFlag, firstName: firstName, lastName: lastName, diff --git a/src/components/Profile/AddPasskey.tsx b/src/components/Profile/AddPasskey.tsx index 25a7ed872..b2d64006c 100644 --- a/src/components/Profile/AddPasskey.tsx +++ b/src/components/Profile/AddPasskey.tsx @@ -107,7 +107,7 @@ const AddPasskey = () => { } } - const verifyRegistrationMethod = async (verifyRegistrationObj, OrgUserEmail: string) => { + const verifyRegistrationMethod = async (verifyRegistrationObj:any, OrgUserEmail: string) => { try { const verificationRegisterResp = await verifyRegistration(verifyRegistrationObj, OrgUserEmail) const { data } = verificationRegisterResp as AxiosResponse From 03483bd805e2b15916f7ccb8e4e9f30ad30334af Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 14 Sep 2023 13:10:41 +0530 Subject: [PATCH 010/250] resolved sonar cloud checks Signed-off-by: bhavanakarwade --- .../Authentication/SignInUserPassword.tsx | 42 ++++++++++--------- .../Authentication/SignUpUserPassword.tsx | 1 - src/components/Profile/AddPasskey.tsx | 3 +- src/components/organization/Dashboard.tsx | 1 - .../organization/EditOrgdetailsModal.tsx | 1 - src/components/organization/WalletSpinup.tsx | 1 - .../invitations/SendInvitationModal.tsx | 1 - .../organization/users/EditUserRolesModal.tsx | 1 - src/components/organization/users/index.tsx | 1 - 9 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/components/Authentication/SignInUserPassword.tsx b/src/components/Authentication/SignInUserPassword.tsx index 08aa86854..2d35ce986 100644 --- a/src/components/Authentication/SignInUserPassword.tsx +++ b/src/components/Authentication/SignInUserPassword.tsx @@ -9,7 +9,7 @@ import { Formik, } from 'formik'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; -import { getFromLocalStorage, getUserProfile, loginUser, passwordEncryption, setToLocalStorage } from '../../api/Auth'; +import { getUserProfile, loginUser, passwordEncryption, setToLocalStorage } from '../../api/Auth'; import { Alert } from 'flowbite-react'; import type { AxiosResponse } from 'axios'; @@ -34,6 +34,28 @@ interface SignInUser3Props { password?: string } +const getUserDetails = async (access_token: string) => { + const [failure, setFailure] = useState(null) + const [loading, setLoading] = useState(false) + + const userDetails = await getUserProfile(access_token); + const { data } = userDetails as AxiosResponse + if (data?.data?.userOrgRoles?.length > 0) { + + const permissionArray: number | string[] = [] + data?.data?.userOrgRoles?.forEach((element: { orgRole: { name: string } }) => permissionArray.push(element?.orgRole?.name)); + await setToLocalStorage(storageKeys.PERMISSIONS, permissionArray) + await setToLocalStorage(storageKeys.USER_PROFILE, data?.data) + await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email) + window.location.href = '/dashboard' + } else { + setFailure(userDetails as string) + } + + setLoading(false) +} + + const SignInUserPassword = (signInUserProps: SignInUser3Props) => { const [email, setEmail] = useState(signInUserProps?.email) const [fidoUserError, setFidoUserError] = useState("") @@ -46,24 +68,6 @@ const SignInUserPassword = (signInUserProps: SignInUser3Props) => { const [passwordVisible, setPasswordVisible] = useState(false); - const getUserDetails = async (access_token: string) => { - - const userDetails = await getUserProfile(access_token); - const { data } = userDetails as AxiosResponse - if (data?.data?.userOrgRoles?.length > 0) { - - const permissionArray: number | string[] = [] - data?.data?.userOrgRoles?.forEach((element: { orgRole: { name: string } }) => permissionArray.push(element?.orgRole?.name)); - await setToLocalStorage(storageKeys.PERMISSIONS, permissionArray) - await setToLocalStorage(storageKeys.USER_PROFILE, data?.data) - await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email) - window.location.href = '/dashboard' - } else { - setFailure(userDetails as string) - } - - setLoading(false) - } const signInUser = async (values: passwordValue) => { const payload: SignInUser3Props = { diff --git a/src/components/Authentication/SignUpUserPassword.tsx b/src/components/Authentication/SignUpUserPassword.tsx index 6fefe3f8f..d8d5a07d8 100644 --- a/src/components/Authentication/SignUpUserPassword.tsx +++ b/src/components/Authentication/SignUpUserPassword.tsx @@ -22,7 +22,6 @@ import NavBar from './NavBar.js'; import FooterBar from './FooterBar.js'; import PasswordSuggestionBox from './PasswordSuggestionBox.js'; import { PassInvisible, PassVisible, SignUpArrow } from './Svg.js'; -import React from 'react'; interface passwordValues { email: string; diff --git a/src/components/Profile/AddPasskey.tsx b/src/components/Profile/AddPasskey.tsx index b2d64006c..2ff8de60f 100644 --- a/src/components/Profile/AddPasskey.tsx +++ b/src/components/Profile/AddPasskey.tsx @@ -100,14 +100,13 @@ const AddPasskey = () => { ...attResp, challangeId } - console.log("verifyRegistrationObj::::", verifyRegistrationObj) await verifyRegistrationMethod(verifyRegistrationObj, OrgUserEmail); } catch (error) { showFidoError(error) } } - const verifyRegistrationMethod = async (verifyRegistrationObj:any, OrgUserEmail: string) => { + const verifyRegistrationMethod = async (verifyRegistrationObj, OrgUserEmail: string) => { try { const verificationRegisterResp = await verifyRegistration(verifyRegistrationObj, OrgUserEmail) const { data } = verificationRegisterResp as AxiosResponse diff --git a/src/components/organization/Dashboard.tsx b/src/components/organization/Dashboard.tsx index 025860894..1b1c635a0 100644 --- a/src/components/organization/Dashboard.tsx +++ b/src/components/organization/Dashboard.tsx @@ -17,7 +17,6 @@ import User_Card from '../../assets/User_Card.svg'; import WalletSpinup from './WalletSpinup'; import { getFromLocalStorage } from '../../api/Auth'; import { pathRoutes } from '../../config/pathRoutes'; -import React from 'react'; const Dashboard = () => { const [orgData, setOrgData] = useState(null); diff --git a/src/components/organization/EditOrgdetailsModal.tsx b/src/components/organization/EditOrgdetailsModal.tsx index 50534a264..e82a71903 100644 --- a/src/components/organization/EditOrgdetailsModal.tsx +++ b/src/components/organization/EditOrgdetailsModal.tsx @@ -9,7 +9,6 @@ import { AlertComponent } from "../AlertComponent"; import type { AxiosResponse } from 'axios'; import { updateOrganization } from "../../api/organization"; import type { Organisation } from "./interfaces"; -import React from "react"; import { getFromLocalStorage } from "../../api/Auth"; interface Values { diff --git a/src/components/organization/WalletSpinup.tsx b/src/components/organization/WalletSpinup.tsx index fd5cf3391..101180289 100644 --- a/src/components/organization/WalletSpinup.tsx +++ b/src/components/organization/WalletSpinup.tsx @@ -20,7 +20,6 @@ import InputCopy from '../InputCopy'; import SOCKET from '../../config/SocketConfig'; import SharedIllustrate from './SharedIllustrate'; import { nanoid } from 'nanoid'; -import React from 'react'; interface Values { seed: string; diff --git a/src/components/organization/invitations/SendInvitationModal.tsx b/src/components/organization/invitations/SendInvitationModal.tsx index 4dc29add9..a66b17410 100644 --- a/src/components/organization/invitations/SendInvitationModal.tsx +++ b/src/components/organization/invitations/SendInvitationModal.tsx @@ -9,7 +9,6 @@ import type { AxiosResponse } from 'axios'; import { apiStatusCodes } from "../../../config/CommonConstant"; import { createInvitations } from "../../../api/invitations"; import { getOrganizationRoles } from "../../../api/organization"; -import React from "react"; interface Values { email: string; diff --git a/src/components/organization/users/EditUserRolesModal.tsx b/src/components/organization/users/EditUserRolesModal.tsx index 8717cf7f0..e4be018ac 100644 --- a/src/components/organization/users/EditUserRolesModal.tsx +++ b/src/components/organization/users/EditUserRolesModal.tsx @@ -6,7 +6,6 @@ import type { AxiosResponse } from 'axios'; import { TextTittlecase } from '../../../utils/TextTransform'; import type { User } from "../interfaces/users"; import { apiStatusCodes } from "../../../config/CommonConstant"; -import React from 'react'; interface RoleI { id: number diff --git a/src/components/organization/users/index.tsx b/src/components/organization/users/index.tsx index eec2e9e3e..6f1d00c49 100644 --- a/src/components/organization/users/index.tsx +++ b/src/components/organization/users/index.tsx @@ -7,7 +7,6 @@ import BreadCrumbs from '../../BreadCrumbs'; import Invitations from '../invitations/Invitations'; import { MdDashboard } from 'react-icons/md'; import Members from './Members'; -import React from 'react'; const initialPageState = { pageNumber: 1, From ddd129ba4ec7e64b9fb598d1c47c39a8f1643536 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 14 Sep 2023 13:19:02 +0530 Subject: [PATCH 011/250] resolved sonar cloud checks Signed-off-by: bhavanakarwade --- .../Authentication/SignInUserPassword.tsx | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/components/Authentication/SignInUserPassword.tsx b/src/components/Authentication/SignInUserPassword.tsx index 2d35ce986..a51e466ac 100644 --- a/src/components/Authentication/SignInUserPassword.tsx +++ b/src/components/Authentication/SignInUserPassword.tsx @@ -34,28 +34,6 @@ interface SignInUser3Props { password?: string } -const getUserDetails = async (access_token: string) => { - const [failure, setFailure] = useState(null) - const [loading, setLoading] = useState(false) - - const userDetails = await getUserProfile(access_token); - const { data } = userDetails as AxiosResponse - if (data?.data?.userOrgRoles?.length > 0) { - - const permissionArray: number | string[] = [] - data?.data?.userOrgRoles?.forEach((element: { orgRole: { name: string } }) => permissionArray.push(element?.orgRole?.name)); - await setToLocalStorage(storageKeys.PERMISSIONS, permissionArray) - await setToLocalStorage(storageKeys.USER_PROFILE, data?.data) - await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email) - window.location.href = '/dashboard' - } else { - setFailure(userDetails as string) - } - - setLoading(false) -} - - const SignInUserPassword = (signInUserProps: SignInUser3Props) => { const [email, setEmail] = useState(signInUserProps?.email) const [fidoUserError, setFidoUserError] = useState("") @@ -68,7 +46,24 @@ const SignInUserPassword = (signInUserProps: SignInUser3Props) => { const [passwordVisible, setPasswordVisible] = useState(false); - + const getUserDetails = async (access_token: string) => { + + const userDetails = await getUserProfile(access_token); + const { data } = userDetails as AxiosResponse + if (data?.data?.userOrgRoles?.length > 0) { + + const permissionArray: number | string[] = [] + data?.data?.userOrgRoles?.forEach((element: { orgRole: { name: string } }) => permissionArray.push(element?.orgRole?.name)); + await setToLocalStorage(storageKeys.PERMISSIONS, permissionArray) + await setToLocalStorage(storageKeys.USER_PROFILE, data?.data) + await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email) + window.location.href = '/dashboard' + } else { + setFailure(userDetails as string) + } + + setLoading(false) + } const signInUser = async (values: passwordValue) => { const payload: SignInUser3Props = { email: email, From 5a390d849fc3eb4b08a03728370b5edaa9207ecf Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 14 Sep 2023 14:02:30 +0530 Subject: [PATCH 012/250] resolved sonar lint checks Signed-off-by: bhavanakarwade --- package-lock.json | 426 ++++++++++-------- package.json | 4 +- .../Authentication/SignInUserPassword.tsx | 1 - 3 files changed, 235 insertions(+), 196 deletions(-) diff --git a/package-lock.json b/package-lock.json index 98810efde..a8497674c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,6 +49,7 @@ "socket.io-client": "^4.6.2", "tailwind-scrollbar": "^3.0.4", "tailwindcss": "^3.3.3", + "uuid": "^9.0.1", "yup": "^1.2.0" }, "devDependencies": { @@ -58,6 +59,7 @@ "@types/downloadjs": "^1.4.3", "@types/eslint": "^8.21.1", "@types/secure-random-password": "^0.2.1", + "@types/uuid": "^9.0.3", "@typescript-eslint/eslint-plugin": "^5.54.1", "@typescript-eslint/parser": "^5.54.1", "astro-eslint-parser": "^0.11.0", @@ -221,22 +223,6 @@ "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.5.0.tgz", "integrity": "sha512-wIh+gKBI9Nshz2o46B0B3f5k/W+WI9ZAv6y5Dn5WJ5SK1t0TnDimB4WE5rmTD05ZAIn8HALCZVmCsvj0w0v0lw==" }, - "node_modules/@astrojs/markdown-remark/node_modules/jsonc-parser": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", - "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" - }, - "node_modules/@astrojs/markdown-remark/node_modules/shiki": { - "version": "0.14.3", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.3.tgz", - "integrity": "sha512-U3S/a+b0KS+UkTyMjoNojvTgrBHjgp7L6ovhFVZsXmBGnVdQ4K4U9oK0z63w538S91ATngv1vXigHCSWOwnr+g==", - "dependencies": { - "ansi-sequence-parser": "^1.1.0", - "jsonc-parser": "^3.2.0", - "vscode-oniguruma": "^1.7.0", - "vscode-textmate": "^8.0.0" - } - }, "node_modules/@astrojs/prism": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-2.1.2.tgz", @@ -1411,16 +1397,6 @@ "@types/react": "*" } }, - "node_modules/@types/react-dom/node_modules/@types/react": { - "version": "18.2.14", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.14.tgz", - "integrity": "sha512-A0zjq+QN/O0Kpe30hA1GidzyFjatVvrpIvWLxD+xv67Vt91TWWgco9IvrJBkeyHm1trGaFS/FSGqPlhyeZRm0g==", - "dependencies": { - "@types/prop-types": "*", - "@types/scheduler": "*", - "csstype": "^3.0.2" - } - }, "node_modules/@types/resolve": { "version": "1.20.2", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", @@ -1456,6 +1432,12 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.7.tgz", "integrity": "sha512-cputDpIbFgLUaGQn6Vqg3/YsJwxUwHLO13v3i5ouxT4lat0khip9AEWxtERujXV9wxIB1EyF97BSJFt6vpdI8g==" }, + "node_modules/@types/uuid": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.3.tgz", + "integrity": "sha512-taHQQH/3ZyI3zP8M/puluDEIEvtQHVYcC6y3N8ijFtAd28+Ey/G4sg1u2gB01S8MwybLOKAp9/yCMu/uR5l3Ug==", + "dev": true + }, "node_modules/@types/websocket": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/websocket/-/websocket-1.0.5.tgz", @@ -2009,22 +1991,6 @@ "url": "https://github.com/sponsors/ota-meshi" } }, - "node_modules/astro/node_modules/jsonc-parser": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", - "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" - }, - "node_modules/astro/node_modules/shiki": { - "version": "0.14.3", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.3.tgz", - "integrity": "sha512-U3S/a+b0KS+UkTyMjoNojvTgrBHjgp7L6ovhFVZsXmBGnVdQ4K4U9oK0z63w538S91ATngv1vXigHCSWOwnr+g==", - "dependencies": { - "ansi-sequence-parser": "^1.1.0", - "jsonc-parser": "^3.2.0", - "vscode-oniguruma": "^1.7.0", - "vscode-textmate": "^8.0.0" - } - }, "node_modules/astrojs-compiler-sync": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/astrojs-compiler-sync/-/astrojs-compiler-sync-0.3.3.tgz", @@ -4234,23 +4200,6 @@ "tailwindcss": "^3" } }, - "node_modules/flowbite-react/node_modules/flowbite": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/flowbite/-/flowbite-1.7.0.tgz", - "integrity": "sha512-OTTmnhRgv85Rs+mcMaVU7zB6EvRQs7BaQziyMUsZLRjW9aUpeQyqKjLmxsVMMCdr8isYPCLd6UL7X1IaSVI0WQ==", - "dependencies": { - "@popperjs/core": "^2.9.3", - "mini-svg-data-uri": "^1.4.3" - } - }, - "node_modules/flowbite-react/node_modules/react-icons": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.10.1.tgz", - "integrity": "sha512-/ngzDP/77tlCfqthiiGNZeYFACw85fUjZtLbedmJ5DTlNDIwETxhwBzdOJ21zj4iJdvc0J3y7yOsX3PpxAJzrw==", - "peerDependencies": { - "react": "*" - } - }, "node_modules/flowbite-typography": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/flowbite-typography/-/flowbite-typography-1.0.3.tgz", @@ -6802,6 +6751,44 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "inBundle": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "inBundle": true, + "license": "MIT" + }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/strip-ansi": { "version": "7.1.0", "inBundle": true, @@ -6816,6 +6803,80 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "inBundle": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "inBundle": true, + "license": "MIT" + }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "inBundle": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/npm/node_modules/@isaacs/string-locale-compare": { "version": "1.1.0", "inBundle": true, @@ -9137,20 +9198,8 @@ }, "node_modules/npm/node_modules/string-width": { "version": "4.2.3", - "inBundle": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/npm/node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "inBundle": true, "license": "MIT", "dependencies": { @@ -9164,18 +9213,8 @@ }, "node_modules/npm/node_modules/strip-ansi": { "version": "6.0.1", - "inBundle": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/npm/node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "inBundle": true, "license": "MIT", "dependencies": { @@ -9348,24 +9387,9 @@ } }, "node_modules/npm/node_modules/wrap-ansi": { - "version": "8.1.0", - "inBundle": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/npm/node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "inBundle": true, "license": "MIT", "dependencies": { @@ -11806,6 +11830,18 @@ "base64-arraybuffer": "^1.0.2" } }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/uvu": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/uvu/-/uvu-0.5.6.tgz", @@ -12396,22 +12432,6 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.5.0.tgz", "integrity": "sha512-wIh+gKBI9Nshz2o46B0B3f5k/W+WI9ZAv6y5Dn5WJ5SK1t0TnDimB4WE5rmTD05ZAIn8HALCZVmCsvj0w0v0lw==" - }, - "jsonc-parser": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", - "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" - }, - "shiki": { - "version": "0.14.3", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.3.tgz", - "integrity": "sha512-U3S/a+b0KS+UkTyMjoNojvTgrBHjgp7L6ovhFVZsXmBGnVdQ4K4U9oK0z63w538S91ATngv1vXigHCSWOwnr+g==", - "requires": { - "ansi-sequence-parser": "^1.1.0", - "jsonc-parser": "^3.2.0", - "vscode-oniguruma": "^1.7.0", - "vscode-textmate": "^8.0.0" - } } } }, @@ -13325,18 +13345,6 @@ "integrity": "sha512-2et4PDvg6PVCyS7fuTc4gPoksV58bW0RwSxWKcPRcHZf0PRUGq03TKcD/rUHe3azfV6/5/biUBJw+HhCQjaP0A==", "requires": { "@types/react": "*" - }, - "dependencies": { - "@types/react": { - "version": "18.2.14", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.14.tgz", - "integrity": "sha512-A0zjq+QN/O0Kpe30hA1GidzyFjatVvrpIvWLxD+xv67Vt91TWWgco9IvrJBkeyHm1trGaFS/FSGqPlhyeZRm0g==", - "requires": { - "@types/prop-types": "*", - "@types/scheduler": "*", - "csstype": "^3.0.2" - } - } } }, "@types/resolve": { @@ -13374,6 +13382,12 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.7.tgz", "integrity": "sha512-cputDpIbFgLUaGQn6Vqg3/YsJwxUwHLO13v3i5ouxT4lat0khip9AEWxtERujXV9wxIB1EyF97BSJFt6vpdI8g==" }, + "@types/uuid": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.3.tgz", + "integrity": "sha512-taHQQH/3ZyI3zP8M/puluDEIEvtQHVYcC6y3N8ijFtAd28+Ey/G4sg1u2gB01S8MwybLOKAp9/yCMu/uR5l3Ug==", + "dev": true + }, "@types/websocket": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/websocket/-/websocket-1.0.5.tgz", @@ -13746,24 +13760,6 @@ "which-pm": "^2.0.0", "yargs-parser": "^21.1.1", "zod": "^3.20.6" - }, - "dependencies": { - "jsonc-parser": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", - "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" - }, - "shiki": { - "version": "0.14.3", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.3.tgz", - "integrity": "sha512-U3S/a+b0KS+UkTyMjoNojvTgrBHjgp7L6ovhFVZsXmBGnVdQ4K4U9oK0z63w538S91ATngv1vXigHCSWOwnr+g==", - "requires": { - "ansi-sequence-parser": "^1.1.0", - "jsonc-parser": "^3.2.0", - "vscode-oniguruma": "^1.7.0", - "vscode-textmate": "^8.0.0" - } - } } }, "astro-eslint-parser": { @@ -15323,23 +15319,6 @@ "react-icons": "^4.10.1", "react-indiana-drag-scroll": "^2.2.0", "tailwind-merge": "^1.13.2" - }, - "dependencies": { - "flowbite": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/flowbite/-/flowbite-1.7.0.tgz", - "integrity": "sha512-OTTmnhRgv85Rs+mcMaVU7zB6EvRQs7BaQziyMUsZLRjW9aUpeQyqKjLmxsVMMCdr8isYPCLd6UL7X1IaSVI0WQ==", - "requires": { - "@popperjs/core": "^2.9.3", - "mini-svg-data-uri": "^1.4.3" - } - }, - "react-icons": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.10.1.tgz", - "integrity": "sha512-/ngzDP/77tlCfqthiiGNZeYFACw85fUjZtLbedmJ5DTlNDIwETxhwBzdOJ21zj4iJdvc0J3y7yOsX3PpxAJzrw==", - "requires": {} - } } }, "flowbite-typography": { @@ -16985,12 +16964,86 @@ "strip-ansi": "^7.0.1" } }, + "string-width-cjs": { + "version": "npm:string-width@4.2.3", + "bundled": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "bundled": true + }, + "emoji-regex": { + "version": "8.0.0", + "bundled": true + }, + "strip-ansi": { + "version": "6.0.1", + "bundled": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, "strip-ansi": { "version": "7.1.0", "bundled": true, "requires": { "ansi-regex": "^6.0.1" } + }, + "strip-ansi-cjs": { + "version": "npm:strip-ansi@6.0.1", + "bundled": true, + "requires": { + "ansi-regex": "^5.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "bundled": true + } + } + }, + "wrap-ansi-cjs": { + "version": "npm:wrap-ansi@7.0.0", + "bundled": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "bundled": true + }, + "emoji-regex": { + "version": "8.0.0", + "bundled": true + }, + "string-width": { + "version": "4.2.3", + "bundled": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "bundled": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } } } }, @@ -18493,15 +18546,8 @@ }, "string-width": { "version": "4.2.3", - "bundled": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "string-width-cjs": { - "version": "npm:string-width@4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "bundled": true, "requires": { "emoji-regex": "^8.0.0", @@ -18511,13 +18557,8 @@ }, "strip-ansi": { "version": "6.0.1", - "bundled": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "strip-ansi-cjs": { - "version": "npm:strip-ansi@6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "bundled": true, "requires": { "ansi-regex": "^5.0.1" @@ -18637,12 +18678,13 @@ } }, "wrap-ansi": { - "version": "8.1.0", + "version": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "bundled": true, "requires": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" }, "dependencies": { "ansi-regex": { @@ -18675,15 +18717,6 @@ } } }, - "wrap-ansi-cjs": { - "version": "npm:wrap-ansi@7.0.0", - "bundled": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, "wrappy": { "version": "1.0.2", "bundled": true @@ -20345,6 +20378,11 @@ "base64-arraybuffer": "^1.0.2" } }, + "uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" + }, "uvu": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/uvu/-/uvu-0.5.6.tgz", diff --git a/package.json b/package.json index e4af0800f..5f9723ea7 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "socket.io-client": "^4.6.2", "tailwind-scrollbar": "^3.0.4", "tailwindcss": "^3.3.3", + "uuid": "^9.0.1", "yup": "^1.2.0" }, "devDependencies": { @@ -74,6 +75,7 @@ "@types/downloadjs": "^1.4.3", "@types/eslint": "^8.21.1", "@types/secure-random-password": "^0.2.1", + "@types/uuid": "^9.0.3", "@typescript-eslint/eslint-plugin": "^5.54.1", "@typescript-eslint/parser": "^5.54.1", "astro-eslint-parser": "^0.11.0", @@ -90,4 +92,4 @@ "eslint-plugin-tsdoc": "^0.2.17", "postcss": "^8.4.25" } -} \ No newline at end of file +} diff --git a/src/components/Authentication/SignInUserPassword.tsx b/src/components/Authentication/SignInUserPassword.tsx index a51e466ac..983ea8a10 100644 --- a/src/components/Authentication/SignInUserPassword.tsx +++ b/src/components/Authentication/SignInUserPassword.tsx @@ -54,7 +54,6 @@ const SignInUserPassword = (signInUserProps: SignInUser3Props) => { const permissionArray: number | string[] = [] data?.data?.userOrgRoles?.forEach((element: { orgRole: { name: string } }) => permissionArray.push(element?.orgRole?.name)); - await setToLocalStorage(storageKeys.PERMISSIONS, permissionArray) await setToLocalStorage(storageKeys.USER_PROFILE, data?.data) await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email) window.location.href = '/dashboard' From d773d63f4d7c7c14192f4242a4d5eac22f9727bb Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 14 Sep 2023 15:34:13 +0530 Subject: [PATCH 013/250] feat: standardized api for schema module Signed-off-by: bhavanakarwade --- src/api/Schema.ts | 6 +++--- src/components/Issuance/CredDefSelection.tsx | 1 - src/components/Issuance/Issuance.tsx | 2 +- src/components/Resources/Schema/ViewSchema.tsx | 4 ++-- src/config/apiRoutes.ts | 3 ++- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api/Schema.ts b/src/api/Schema.ts index df8595d23..f0e142355 100644 --- a/src/api/Schema.ts +++ b/src/api/Schema.ts @@ -30,7 +30,7 @@ export const getAllSchemas = async ({itemPerPage, page, allSearch }: GetAllSchem export const getAllSchemasByOrgId = async ({ search, itemPerPage, page }: GetAllSchemaListParameter, orgId: string) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: `${apiRoutes.schema.getAll}?orgId=${orgId}&pageNumber=${page}&pageSize=${itemPerPage}&searchByText=${search}`, + url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getAll}&pageNumber=${page}&pageSize=${itemPerPage}&searchByText=${search}`, config: { headers: { 'Content-type': 'application/json', @@ -72,10 +72,10 @@ export const addSchema = async (payload: createSchema) => { } } -export const getSchemaById = async (id: string, orgId: number) => { +export const getSchemaById = async (schemaId: string, orgId: number) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: `${apiRoutes.schema.getSchemaById}?schemaId=${id}&orgId=${orgId}`, + url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getSchemaById}/${schemaId}`, config: { headers: { 'Content-type': 'application/json', diff --git a/src/components/Issuance/CredDefSelection.tsx b/src/components/Issuance/CredDefSelection.tsx index 4e49ca23f..fe59801ba 100644 --- a/src/components/Issuance/CredDefSelection.tsx +++ b/src/components/Issuance/CredDefSelection.tsx @@ -15,7 +15,6 @@ import SchemaCard from "../../commonComponents/SchemaCard"; import type { TableData } from "../../commonComponents/datatable/interface"; import { dateConversion } from "../../utils/DateConversion"; import { getCredentialDefinitions } from "../../api/issuance"; -import { getSchemaById } from "../../api/Schema"; import { pathRoutes } from "../../config/pathRoutes"; import DateTooltip from "../Tooltip"; diff --git a/src/components/Issuance/Issuance.tsx b/src/components/Issuance/Issuance.tsx index fe8565a4b..47fc2faee 100644 --- a/src/components/Issuance/Issuance.tsx +++ b/src/components/Issuance/Issuance.tsx @@ -5,7 +5,7 @@ import * as Yup from 'yup'; import { Alert, Button, Card } from 'flowbite-react'; import { ErrorMessage, Field, Form, Formik } from 'formik'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; -import { getCredDeffById, getSchemaById } from '../../api/Schema'; +// import { getCredDeffById, getSchemaById } from '../../api/Schema'; import { getFromLocalStorage, removeFromLocalStorage } from '../../api/Auth'; import { useEffect, useState } from 'react'; diff --git a/src/components/Resources/Schema/ViewSchema.tsx b/src/components/Resources/Schema/ViewSchema.tsx index 495fd22ad..1caf14685 100644 --- a/src/components/Resources/Schema/ViewSchema.tsx +++ b/src/components/Resources/Schema/ViewSchema.tsx @@ -57,10 +57,10 @@ const ViewSchemas = () => { const [userRoles, setUserRoles] = useState([]) - const getSchemaDetails = async (id: string, organizationId: number) => { + const getSchemaDetails = async (SchemaId: string, organizationId: number) => { try { setLoading(true); - const SchemaDetails = await getSchemaById(id, organizationId); + const SchemaDetails = await getSchemaById(SchemaId, organizationId); const { data } = SchemaDetails as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index b34fe5dd2..ad813933d 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -18,6 +18,7 @@ export const apiRoutes = { recentActivity: '/users/activity', }, organizations: { + root: '/orgs', create: '/organization', update: '/organization', getAll: '/organization', @@ -35,7 +36,7 @@ export const apiRoutes = { schema: { create: '/schemas', getAll: '/schemas', - getSchemaById:'/schemas/id', + getSchemaById:'/schemas', createCredentialDefinition: '/credential-definitions', getCredDeffBySchemaId: '/schemas/credential-definitions', getAllSchemaFromPlatform: `/schemas/platform` From 51c63217b9174c3e8a58401dda3c2df997abfa27 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 14 Sep 2023 15:48:05 +0530 Subject: [PATCH 014/250] worked on feedback provided in pr comments Signed-off-by: bhavanakarwade --- src/api/Auth.ts | 6 +----- src/api/Fido.ts | 2 +- src/components/Profile/EditUserProfile.tsx | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/api/Auth.ts b/src/api/Auth.ts index 7f57a2085..a4d57b30d 100644 --- a/src/api/Auth.ts +++ b/src/api/Auth.ts @@ -1,7 +1,4 @@ import {axiosGet, axiosPost, axiosPut} from '../services/apiRequests' -import { number, string } from 'yup' - -import type { AxiosError } from 'axios' import CryptoJS from "crypto-js" import { apiRoutes } from '../config/apiRoutes' import { envConfig } from '../config/envConfig' @@ -13,7 +10,7 @@ export interface UserSignUpData { } export interface AddPasswordDetails { email:string - password:string | undefined + password:string isPasskey:boolean firstName: string|null lastName: string|null @@ -99,7 +96,6 @@ export const updateUserProfile = async(data: object ) => { const err = error as Error return err?.message } - } export const verifyUserMail = async(payload: EmailVerifyData ) => { diff --git a/src/api/Fido.ts b/src/api/Fido.ts index 7016a906c..2c21c6dde 100644 --- a/src/api/Fido.ts +++ b/src/api/Fido.ts @@ -27,7 +27,7 @@ export const generateRegistrationOption = async (payload: RegistrationOptionInte } } -export const verifyRegistration = async (payload:any, userEmail:string) => { +export const verifyRegistration = async (payload:verifyRegistrationObjInterface, userEmail:string) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { url: `${apiRoutes.fido.verifyRegistration}${userEmail}`, diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx index 05ccb3a6b..216e829bc 100644 --- a/src/components/Profile/EditUserProfile.tsx +++ b/src/components/Profile/EditUserProfile.tsx @@ -152,7 +152,6 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } setLoading(true) const userData = { - // id: userProfileInfo?.id, firstName: values.firstName, lastName: values.lastName, email: values.email, From a9c141fa6696c8c30de1c08155aa9799c13d5058 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 14 Sep 2023 18:14:27 +0530 Subject: [PATCH 015/250] feat: refactor api for schema module Signed-off-by: bhavanakarwade --- src/api/Schema.ts | 18 ++++++++++-------- src/api/issuance.ts | 4 +++- src/api/verification.ts | 2 +- .../Authentication/SignInUserPasskey.tsx | 2 ++ src/components/Resources/Schema/Create.tsx | 9 +++++---- src/components/Resources/Schema/ViewSchema.tsx | 2 +- src/config/apiRoutes.ts | 16 +++++++++------- 7 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/api/Schema.ts b/src/api/Schema.ts index f0e142355..7fa91c63b 100644 --- a/src/api/Schema.ts +++ b/src/api/Schema.ts @@ -8,7 +8,7 @@ import { storageKeys } from "../config/CommonConstant"; export const getAllSchemas = async ({itemPerPage, page, allSearch }: GetAllSchemaListParameter) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: `${apiRoutes.schema.getAllSchemaFromPlatform}?pageSize=${itemPerPage}&searchByText=${allSearch}&pageNumber=${page}`, + url: `${apiRoutes.Platform.getAllSchemaFromPlatform}?pageSize=${itemPerPage}&searchByText=${allSearch}&pageNumber=${page}`, config: { headers: { 'Content-type': 'application/json', @@ -49,10 +49,11 @@ export const getAllSchemasByOrgId = async ({ search, itemPerPage, page }: GetAll } } -export const addSchema = async (payload: createSchema) => { +export const addSchema = async (payload: createSchema, orgId: number) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: apiRoutes.schema.create, + // url: apiRoutes.schema.create, + url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.create}`, payload, config: { headers: { @@ -94,10 +95,10 @@ export const getSchemaById = async (schemaId: string, orgId: number) => { } } -export const createCredentialDefinition = async (payload: createCredDeffFieldName) => { +export const createCredentialDefinition = async (payload: createCredDeffFieldName, orgId:number) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: apiRoutes.schema.createCredentialDefinition, + url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.createCredentialDefinition}`, payload, config: { headers: { @@ -118,10 +119,10 @@ export const createCredentialDefinition = async (payload: createCredDeffFieldNam } } -export const getCredDeffById = async (id: string, orgId: number) => { +export const getCredDeffById = async (schemaId: string, orgId: number) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: `${apiRoutes.schema.getCredDeffBySchemaId}?schemaId=${id}&orgId=${orgId}`, + url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getCredDefBySchemaId}/${schemaId}/cred-defs`, config: { headers: { 'Content-type': 'application/json', @@ -138,4 +139,5 @@ export const getCredDeffById = async (id: string, orgId: number) => { const err = error as Error return err?.message } -} \ No newline at end of file +} + diff --git a/src/api/issuance.ts b/src/api/issuance.ts index 0706f5b5d..3c7d0be50 100644 --- a/src/api/issuance.ts +++ b/src/api/issuance.ts @@ -24,7 +24,9 @@ export const getIssuedCredentials = async (state: IssueCredential) => { export const getCredentialDefinitions = async (schemaId: string) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - const url = `${apiRoutes.Issuance.getCredDefBySchemaId}?schemaId=${schemaId}&orgId=${orgId}`; + // const url = `${apiRoutes.Issuance.getCredDefBySchemaId}?schemaId=${schemaId}&orgId=${orgId}`; + const url= `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getCredDefBySchemaId}/${schemaId}/cred-defs`; + const axiosPayload = { url, config: await getHeaderConfigs(), diff --git a/src/api/verification.ts b/src/api/verification.ts index 75aef3370..8d530e448 100644 --- a/src/api/verification.ts +++ b/src/api/verification.ts @@ -91,7 +91,7 @@ export const getProofAttributes=async (id:string)=>{ } export const getCredentialDefinitionsForVerification = async (schemaId: string) => { - const url = `${apiRoutes.Issuance.getCredDefBySchemaId}?schemaId=${schemaId}`; + const url = `${apiRoutes.schema.getCredDefBySchemaId}?schemaId=${schemaId}`; const axiosPayload = { url, config: await getHeaderConfigs(), diff --git a/src/components/Authentication/SignInUserPasskey.tsx b/src/components/Authentication/SignInUserPasskey.tsx index 94e1921fb..206f5c0c6 100644 --- a/src/components/Authentication/SignInUserPasskey.tsx +++ b/src/components/Authentication/SignInUserPasskey.tsx @@ -95,6 +95,8 @@ const SignInUserPasskey = (signInUserProps: signInUserProps) => { ...attResp, challangeId }; + setFidoLoader(false) + const verificationResp = await verifyAuthenticationMethod(verifyAuthenticationObj, { userName: email }); const { data } = verificationResp as AxiosResponse if (data?.data.verified) { diff --git a/src/components/Resources/Schema/Create.tsx b/src/components/Resources/Schema/Create.tsx index 9283b109d..0519eb781 100644 --- a/src/components/Resources/Schema/Create.tsx +++ b/src/components/Resources/Schema/Create.tsx @@ -18,6 +18,7 @@ import SchemaCard from '../../../commonComponents/SchemaCard'; import { addSchema } from '../../../api/Schema'; import { getFromLocalStorage } from '../../../api/Auth'; import { pathRoutes } from '../../../config/pathRoutes'; +import React from 'react'; const options = [ { value: 'string', label: 'String' }, @@ -49,7 +50,7 @@ const CreateSchema = () => { orgId: orgId, }; - const createSchema = await addSchema(schemaFieldName); + const createSchema = await addSchema(schemaFieldName, orgId); const { data } = createSchema as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { if (data?.data) { @@ -492,9 +493,9 @@ const CreateSchema = () => { - -
  • - -
  • - {/*
  • - -
  • */} +
  • + +
  • +
  • + +
  • -
    -
    - -
    -
    - -
    -
    +
    +
    + +
    +
    + +
    +
    + } ); diff --git a/src/components/Profile/DisplayUserProfile.tsx b/src/components/Profile/DisplayUserProfile.tsx index 112959bb6..6f6c60ace 100644 --- a/src/components/Profile/DisplayUserProfile.tsx +++ b/src/components/Profile/DisplayUserProfile.tsx @@ -1,13 +1,16 @@ import type { UserProfile } from "./interfaces"; import CustomAvatar from '../Avatar' import { Formik } from "formik"; +import React from "react"; +import { Button } from "flowbite-react"; interface DisplayUserProfileProps { toggleEditProfile: () => void; userProfileInfo: UserProfile | null; } -const DisplayUserProfile = ({ toggleEditProfile, userProfileInfo }: DisplayUserProfileProps) => { +// const DisplayUserProfile = ({ toggleEditProfile, userProfileInfo }: DisplayUserProfileProps) => { + const DisplayUserProfile = () => { return (
    @@ -82,41 +85,88 @@ const DisplayUserProfile = ({ toggleEditProfile, userProfileInfo }: DisplayUserP
    -
    -
    +
    + {/*
    */}
    -

    General

    +

    General

    Basic info, like your first name, last name and profile image that will be displayed

    -
    First Name
    +
    First Name
    - +
    -
    Last Name
    +
    Last Name
    - +
    -
    -
    Profile Image
    +
    +
    Profile Image
    - + {/* */} +
    + +
    + +
    +
    + + No File Chosen +
    +
    +
    + +
    +
    + +
    + + +
    -
    + {/*
    */}
    From 588491bb92e95934e918ff85b22a4159ed55dad7 Mon Sep 17 00:00:00 2001 From: tipusinghaw Date: Mon, 18 Sep 2023 12:34:39 +0530 Subject: [PATCH 022/250] fix: passkey add device loader issue Signed-off-by: tipusinghaw --- src/components/Authentication/SignInUserPasskey.tsx | 1 + src/components/Profile/AddPasskey.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/Authentication/SignInUserPasskey.tsx b/src/components/Authentication/SignInUserPasskey.tsx index 94e1921fb..37286be51 100644 --- a/src/components/Authentication/SignInUserPasskey.tsx +++ b/src/components/Authentication/SignInUserPasskey.tsx @@ -95,6 +95,7 @@ const SignInUserPasskey = (signInUserProps: signInUserProps) => { ...attResp, challangeId }; + setFidoLoader(false) const verificationResp = await verifyAuthenticationMethod(verifyAuthenticationObj, { userName: email }); const { data } = verificationResp as AxiosResponse if (data?.data.verified) { diff --git a/src/components/Profile/AddPasskey.tsx b/src/components/Profile/AddPasskey.tsx index 25a7ed872..5087abb3c 100644 --- a/src/components/Profile/AddPasskey.tsx +++ b/src/components/Profile/AddPasskey.tsx @@ -140,8 +140,10 @@ const AddPasskey = () => { const { data } = deviceDetailsResp as AxiosResponse if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { setAddSuccess("Device added successfully") - userDeviceDetails() - window.location.href = `${apiRoutes.auth.profile}` + setTimeout(() => { + userDeviceDetails() + window.location.href = `${apiRoutes.auth.profile}` + }, 4000) } else { setAddFailur(deviceDetailsResp as string) } From 3e3805632974eb4ba4800ef032eb8cab51968461 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Mon, 18 Sep 2023 14:09:25 +0530 Subject: [PATCH 023/250] proper message displayed when no organization is created Signed-off-by: bhavanakarwade --- src/api/invitations.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/invitations.ts b/src/api/invitations.ts index 1d6f43a08..ee2af5f76 100644 --- a/src/api/invitations.ts +++ b/src/api/invitations.ts @@ -8,6 +8,10 @@ export const getOrganizationInvitations = async (pageNumber: number, pageSize: n const orgId = await getFromLocalStorage(storageKeys.ORG_ID) + if (!orgId) { + return "Organization is required"; + } + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.organizations.invitations}?&pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` const token = await getFromLocalStorage(storageKeys.TOKEN) From 68d9b6602c25764472f1e9c4f546688b21ff085e Mon Sep 17 00:00:00 2001 From: tipusinghaw Date: Mon, 18 Sep 2023 14:58:24 +0530 Subject: [PATCH 024/250] fix: add device alert message issue Signed-off-by: tipusinghaw --- src/components/Profile/AddPasskey.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Profile/AddPasskey.tsx b/src/components/Profile/AddPasskey.tsx index 5087abb3c..ffa9c9de8 100644 --- a/src/components/Profile/AddPasskey.tsx +++ b/src/components/Profile/AddPasskey.tsx @@ -141,7 +141,8 @@ const AddPasskey = () => { if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { setAddSuccess("Device added successfully") setTimeout(() => { - userDeviceDetails() + // userDeviceDetails() // required + setAddSuccess('') window.location.href = `${apiRoutes.auth.profile}` }, 4000) } else { From 44cf801cdf5334850d06769ea74f0c4fc19604dd Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Mon, 18 Sep 2023 15:03:34 +0530 Subject: [PATCH 025/250] worked on update password page Signed-off-by: bhavanakarwade --- src/components/Profile/AddPasskey.tsx | 6 +++--- src/components/Profile/DisplayUserProfile.tsx | 2 -- src/components/Profile/UpdatePassword.tsx | 8 +++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/Profile/AddPasskey.tsx b/src/components/Profile/AddPasskey.tsx index 351edd2d6..d9efa965b 100644 --- a/src/components/Profile/AddPasskey.tsx +++ b/src/components/Profile/AddPasskey.tsx @@ -198,12 +198,12 @@ const AddPasskey = () => {
    - {fidoLoader + {/* {fidoLoader ?
    - : + : */}
    @@ -233,7 +233,7 @@ const AddPasskey = () => {
    - } + {/* } */}
    ); }; diff --git a/src/components/Profile/DisplayUserProfile.tsx b/src/components/Profile/DisplayUserProfile.tsx index 6f6c60ace..23e3004ac 100644 --- a/src/components/Profile/DisplayUserProfile.tsx +++ b/src/components/Profile/DisplayUserProfile.tsx @@ -86,7 +86,6 @@ interface DisplayUserProfileProps {
    - {/*
    */}
    @@ -166,7 +165,6 @@ interface DisplayUserProfileProps {
    - {/*
    */}
    diff --git a/src/components/Profile/UpdatePassword.tsx b/src/components/Profile/UpdatePassword.tsx index 6830a748b..25ea16ee2 100644 --- a/src/components/Profile/UpdatePassword.tsx +++ b/src/components/Profile/UpdatePassword.tsx @@ -5,13 +5,12 @@ const UpdatePassword = () => {
    -
    -

    Password

    -

    Enter your current & new password to reset your password

    +

    Password

    +

    Enter your current & new password to reset your password

    @@ -28,7 +27,7 @@ const UpdatePassword = () => {
    -
    +
    Confirm Password
    @@ -38,7 +37,6 @@ const UpdatePassword = () => {
    -
    From 67c4009b7355d9c42478bfd75273d9c4f630c0d4 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Mon, 18 Sep 2023 15:40:39 +0530 Subject: [PATCH 026/250] feat: worked on update password page Signed-off-by: bhavanakarwade --- src/components/Profile/DisplayUserProfile.tsx | 90 +++++++++---------- src/components/Profile/UpdatePassword.tsx | 32 ++++++- 2 files changed, 74 insertions(+), 48 deletions(-) diff --git a/src/components/Profile/DisplayUserProfile.tsx b/src/components/Profile/DisplayUserProfile.tsx index 23e3004ac..e74c2aef2 100644 --- a/src/components/Profile/DisplayUserProfile.tsx +++ b/src/components/Profile/DisplayUserProfile.tsx @@ -10,7 +10,7 @@ interface DisplayUserProfileProps { } // const DisplayUserProfile = ({ toggleEditProfile, userProfileInfo }: DisplayUserProfileProps) => { - const DisplayUserProfile = () => { +const DisplayUserProfile = () => { return (
    @@ -86,50 +86,50 @@ interface DisplayUserProfileProps {
    -
    -
    -
    -
    -

    General

    -

    Basic info, like your first name, last name and profile image that will be displayed

    -
    +
    + +
    +
    +

    General

    +

    Basic info, like your first name, last name and profile image that will be displayed

    +
    -
    -
    First Name
    -
    - -
    +
    +
    First Name
    +
    +
    +
    -
    -
    Last Name
    -
    - -
    +
    +
    Last Name
    +
    +
    +
    -
    -
    Profile Image
    -
    - {/* */} -
    - -
    - -
    -
    - - No File Chosen +
    +
    Profile Image
    +
    + {/* */} +
    + +
    + +
    +
    + + No File Chosen
    -
    -
    +
    +
    @@ -150,21 +150,17 @@ interface DisplayUserProfileProps { style={{ height: '2.5rem', width: '7rem', minWidth: '4rem' }} > - - + + Reset
    - - - - -
    - -
    +
    + +
    diff --git a/src/components/Profile/UpdatePassword.tsx b/src/components/Profile/UpdatePassword.tsx index 25ea16ee2..7d0199a41 100644 --- a/src/components/Profile/UpdatePassword.tsx +++ b/src/components/Profile/UpdatePassword.tsx @@ -1,10 +1,11 @@ +import { Button } from 'flowbite-react' import React from 'react' const UpdatePassword = () => { return (
    -
    +
    @@ -33,6 +34,35 @@ const UpdatePassword = () => {
    +
    + +
    +
    + +
    From d34205b4c6cbf96ebfbaaf99343342f12b4c6325 Mon Sep 17 00:00:00 2001 From: Nishad Shirsat <103021375+nishad-ayanworks@users.noreply.github.com> Date: Mon, 18 Sep 2023 16:38:52 +0530 Subject: [PATCH 027/250] refactor: edit organization for private/public option (#277) * feat:public profile features Signed-off-by: pranalidhanavade * feat:changes in edit organization details model Signed-off-by: pranalidhanavade --------- Signed-off-by: pranalidhanavade Signed-off-by: @nishad.shirsat Co-authored-by: pranalidhanavade --- .../Authentication/SignInUserPassword.tsx | 6 +- src/components/Profile/EditUserProfile.tsx | 135 +++++++---- src/components/Profile/interfaces/index.ts | 1 + .../organization/EditOrgdetailsModal.tsx | 228 ++++++++++++------ 4 files changed, 244 insertions(+), 126 deletions(-) diff --git a/src/components/Authentication/SignInUserPassword.tsx b/src/components/Authentication/SignInUserPassword.tsx index 8ad30e955..df06a4ab4 100644 --- a/src/components/Authentication/SignInUserPassword.tsx +++ b/src/components/Authentication/SignInUserPassword.tsx @@ -8,17 +8,17 @@ import { Form, Formik, } from 'formik'; +import React, { useState } from 'react'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; import { getUserProfile, loginUser, passwordEncryption, setToLocalStorage } from '../../api/Auth'; import { Alert } from 'flowbite-react'; import type { AxiosResponse } from 'axios'; import CustomSpinner from '../CustomSpinner'; +import FooterBar from './FooterBar'; +import NavBar from './NavBar'; import SignInUserPasskey from './SignInUserPasskey'; import { getSupabaseClient } from '../../supabase'; -import NavBar from './NavBar'; -import FooterBar from './FooterBar'; -import React, { useState } from 'react'; interface emailValue { email: string; diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx index 29969e217..578de1d89 100644 --- a/src/components/Profile/EditUserProfile.tsx +++ b/src/components/Profile/EditUserProfile.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { SetStateAction, useEffect, useState } from "react"; import type { UserProfile } from "./interfaces"; import { getFromLocalStorage, getUserProfile, updateUserProfile } from "../../api/Auth"; import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted, storageKeys } from "../../config/CommonConstant"; @@ -14,7 +14,8 @@ interface Values { profileImg: string; firstName: string; lastName: string; - email:string; + email: string; + radio1: string | boolean; } interface ILogoImage { @@ -37,13 +38,16 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } firstName: userProfileInfo?.firstName || "", lastName: userProfileInfo?.lastName || "", email: userProfileInfo?.email || "", - + radio1: userProfileInfo?.publicProfile?.toString() + }) const [logoImage, setLogoImage] = useState({ logoFile: '', imagePreviewUrl: userProfileInfo?.profileImg || "", fileName: '' }) + + useEffect(() => { @@ -52,8 +56,8 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } profileImg: userProfileInfo?.profileImg || "", firstName: userProfileInfo.firstName || '', lastName: userProfileInfo.lastName || '', - email: userProfileInfo?.email, - + email: userProfileInfo?.email, + radio1: userProfileInfo?.publicProfile.toString() }); setLogoImage({ @@ -121,7 +125,7 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } ...logoImage, imagePreviewUrl: '', }); - + const reader = new FileReader() const file = event?.target?.files @@ -146,9 +150,6 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } const updateUserDetails = async (values: Values) => { - console.log(`Image::`, logoImage?.imagePreviewUrl); - - setLoading(true) const userData = { @@ -156,8 +157,8 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } firstName: values.firstName, lastName: values.lastName, email: values.email, - profileImg: logoImage?.imagePreviewUrl as string || values?.profileImg - + profileImg: logoImage?.imagePreviewUrl as string || values?.profileImg, + publicProfile:values?.radio1 } const resUpdateUserDetails = await updateUserProfile(userData) @@ -172,14 +173,14 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } const validationSchema = yup.object().shape({ 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'), + .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'), 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') + .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') }); @@ -192,17 +193,19 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } - ) => { + ) => { if (!values.firstName || !values.lastName) { return; } - + values['radio1'] = values?.radio1 === 'true' ? true : false updateUserDetails(values); toggleEditProfile(); + }} - + validationSchema={validationSchema}> {(formikHandlers): JSX.Element => (
    ) : ( - )} + )}

    @@ -251,25 +254,25 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }

    + type="button" + className="absolute top-0 right-0 w-6 h-6 m-2 " + onClick={toggleEditProfile} + > + + + + + + + +
    @@ -317,6 +320,48 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } }
    +
    +
    +
    +
    + + Private + Only the connected organization can see you organization details + +
    +
    +
    +
    + + Public + Your profile and organization details can be seen by everyone +
    +
    +
    diff --git a/src/components/Profile/interfaces/index.ts b/src/components/Profile/interfaces/index.ts index 799a152b5..0fae36cb1 100644 --- a/src/components/Profile/interfaces/index.ts +++ b/src/components/Profile/interfaces/index.ts @@ -55,4 +55,5 @@ export interface UserProfile { lastName: string isEmailVerified: boolean keycloakUserId: string + publicProfile:boolean } \ No newline at end of file diff --git a/src/components/organization/EditOrgdetailsModal.tsx b/src/components/organization/EditOrgdetailsModal.tsx index e7312d0cc..68689b54d 100644 --- a/src/components/organization/EditOrgdetailsModal.tsx +++ b/src/components/organization/EditOrgdetailsModal.tsx @@ -5,15 +5,18 @@ import { Field, Form, Formik, FormikHelpers } from 'formik'; import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted } from '../../config/CommonConstant' import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; import { useEffect, useState } from "react"; + import { AlertComponent } from "../AlertComponent"; import type { AxiosResponse } from 'axios'; +import type { Organisation } from "./interfaces"; +import React from "react"; // import { asset } from '../../lib/data.js'; import { updateOrganization } from "../../api/organization"; -import type { Organisation } from "./interfaces"; interface Values { name: string; description: string; + radio1: string | boolean; } interface ILogoImage { @@ -26,58 +29,67 @@ interface EditOrgdetailsModalProps { openModal: boolean; setMessage: (message: string) => void; setOpenModal: (flag: boolean) => void; - onEditSucess?:() =>void; - orgData: Organisation | null; - } + onEditSucess?: () => void; + orgData: Organisation | null; -const EditOrgdetailsModal = (props: EditOrgdetailsModalProps)=> { +} + +const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { const [logoImage, setLogoImage] = useState({ logoFile: "", imagePreviewUrl: props?.orgData?.logoUrl || "", - fileName: '' + fileName: '', + }) const [loading, setLoading] = useState(false) const [isImageEmpty, setIsImageEmpty] = useState(true) + const [isPublic, setIsPublic] = useState(true) const [initialOrgData, setOrgData] = useState({ name: props?.orgData?.name || "", description: props?.orgData?.description || "", + radio1: props?.orgData?.publicProfile?.toString() || "" }) useEffect(() => { - + if (props.orgData) { - setOrgData({ - name: props.orgData.name || '', - description: props.orgData.description || '', - }); - - setLogoImage({ - logoFile: "", - imagePreviewUrl: props.orgData.logoUrl || "", - fileName: '' - }); + setOrgData({ + name: props.orgData.name || '', + description: props.orgData.description || '', + radio1: props?.orgData?.publicProfile.toString() + }); + + setLogoImage({ + logoFile: "", + imagePreviewUrl: props.orgData.logoUrl || "", + fileName: '' + }); } - }, [props.orgData]); - + }, [props]); + const [erroMsg, setErrMsg] = useState(null) const [imgError, setImgError] = useState('') useEffect(() => { - setOrgData({ - name: '', - description: '', - }) - setLogoImage({ - ...logoImage, - logoFile: "", - imagePreviewUrl: "" - }) + if (props.openModal === false) { + setOrgData({ + name: '', + description: '', + radio1: '' + }) + + setLogoImage({ + ...logoImage, + logoFile: "", + imagePreviewUrl: "" + }) + } }, [props.openModal]) @@ -155,33 +167,34 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps)=> { } } - const submitUpdateOrganization = async (values: Values) => { - setLoading(true) + const submitUpdateOrganization = async (values: Values) => { - const orgData = { - orgId: props?.orgData?.id, - name: values.name, - description: values.description, - logo: logoImage?.imagePreviewUrl as string || props?.orgData?.logoUrl, - website: "" - } + setLoading(true) - const resUpdateOrg = await updateOrganization(orgData) + const orgData = { + orgId: props?.orgData?.id, + name: values.name, + description: values.description, + logo: logoImage?.imagePreviewUrl as string || props?.orgData?.logoUrl, + website: "", + isPublic: isPublic + } - const { data } = resUpdateOrg as AxiosResponse - setLoading(false) + const resUpdateOrg = await updateOrganization(orgData) - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - if(props?.onEditSucess){ - props?.onEditSucess() - } - props.setOpenModal(false) - window.location.reload(); - } else { - setErrMsg(resUpdateOrg as string) + const { data } = resUpdateOrg as AxiosResponse + setLoading(false) + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + if (props?.onEditSucess) { + props?.onEditSucess() } + props.setOpenModal(false) + } else { + setErrMsg(resUpdateOrg as string) } - + } + return ( { setLogoImage({ @@ -195,19 +208,16 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps)=> { }> Edit Organization - { + onAlertClose={() => { setErrMsg(null) }} - /> + /> { description: yup .string() .min(2, 'Organization name must be at least 2 characters') - .max(255, 'Organization name must be at most 255 characters') + .max(600, 'Organization name must be at most 255 characters') .required('Description is required') })} validateOnBlur @@ -232,7 +242,6 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps)=> { ) => { submitUpdateOrganization(values) - }} > {(formikHandlers): JSX.Element => ( @@ -249,21 +258,21 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps)=> { { - (typeof (logoImage.logoFile) === "string" && props?.orgData?.logoUrl) ? - Jese picture - : typeof (logoImage.logoFile) === "string" ? - : + (typeof (logoImage.logoFile) === "string" && props?.orgData?.logoUrl) ? Jese picture + : typeof (logoImage.logoFile) === "string" ? + : + Jese picture } @@ -278,7 +287,7 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps)=> {
    + +
    { {formikHandlers?.errors?.description} }
    +
    +
    +
    + + +
    +
    + +
    +
    +
    + setIsPublic(false)} + id="private" + name="private" + /> + Private + Only the connected organization can see you organization details + +
    +
    +
    +
    + setIsPublic(true)} + checked={isPublic === true} + id="public" + name="public" + /> + + Public + Your profile and organization details can be seen by everyone +
    +
    )} From 9446b835e04605dccd5596da6d330d6b9c885fb8 Mon Sep 17 00:00:00 2001 From: Nishad Shirsat <103021375+nishad-ayanworks@users.noreply.github.com> Date: Mon, 18 Sep 2023 17:14:15 +0530 Subject: [PATCH 028/250] refactor: changes in edit user for public/ private profile (#278) * feat:public profile features Signed-off-by: pranalidhanavade * feat:changes in edit organization details model Signed-off-by: pranalidhanavade * implemented public private selection in edit profile functionality Signed-off-by: @nishad.shirsat --------- Signed-off-by: pranalidhanavade Signed-off-by: @nishad.shirsat Co-authored-by: pranalidhanavade --- src/components/Profile/DisplayUserProfile.tsx | 16 +++++- src/components/Profile/EditUserProfile.tsx | 54 ++++++++++--------- src/components/Profile/interfaces/index.ts | 11 ++-- .../organization/EditOrgdetailsModal.tsx | 5 +- 4 files changed, 51 insertions(+), 35 deletions(-) diff --git a/src/components/Profile/DisplayUserProfile.tsx b/src/components/Profile/DisplayUserProfile.tsx index cce777def..e40640073 100644 --- a/src/components/Profile/DisplayUserProfile.tsx +++ b/src/components/Profile/DisplayUserProfile.tsx @@ -1,5 +1,5 @@ -import type { UserProfile } from "./interfaces"; import CustomAvatar from '../Avatar' +import type { UserProfile } from "./interfaces"; interface DisplayUserProfileProps { toggleEditProfile: () => void; @@ -76,6 +76,20 @@ interface DisplayUserProfileProps {
    +
  • +
    + +
    +

    + Public view +

    +

    + + {userProfileInfo?.publicProfile ? " Public" : "Private"} +

    +
    +
    +
  • diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx index 578de1d89..bc90a1db7 100644 --- a/src/components/Profile/EditUserProfile.tsx +++ b/src/components/Profile/EditUserProfile.tsx @@ -1,21 +1,22 @@ +import * as yup from "yup" + +import { Avatar, Button, Label } from "flowbite-react"; +import { Field, Form, Formik, FormikHelpers } from "formik"; +import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted, storageKeys } from "../../config/CommonConstant"; import { SetStateAction, useEffect, useState } from "react"; -import type { UserProfile } from "./interfaces"; +import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; import { getFromLocalStorage, getUserProfile, updateUserProfile } from "../../api/Auth"; -import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted, storageKeys } from "../../config/CommonConstant"; + import type { AxiosResponse } from "axios"; import CustomAvatar from '../Avatar' -import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; -import { Avatar, Button, Label } from "flowbite-react"; -import { Field, Form, Formik, FormikHelpers } from "formik"; +import type { UserProfile } from "./interfaces"; import { asset } from "../../lib/data"; -import * as yup from "yup" interface Values { profileImg: string; firstName: string; lastName: string; email: string; - radio1: string | boolean; } interface ILogoImage { @@ -33,13 +34,14 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } const [loading, setLoading] = useState(false) const [isImageEmpty, setIsImageEmpty] = useState(true) + + const [isPublic, setIsPublic] = useState(true) + const [initialProfileData, setInitialProfileData] = useState({ profileImg: userProfileInfo?.profileImg || "", firstName: userProfileInfo?.firstName || "", lastName: userProfileInfo?.lastName || "", - email: userProfileInfo?.email || "", - radio1: userProfileInfo?.publicProfile?.toString() - + email: userProfileInfo?.email || "" }) const [logoImage, setLogoImage] = useState({ logoFile: '', @@ -56,8 +58,7 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } profileImg: userProfileInfo?.profileImg || "", firstName: userProfileInfo.firstName || '', lastName: userProfileInfo.lastName || '', - email: userProfileInfo?.email, - radio1: userProfileInfo?.publicProfile.toString() + email: userProfileInfo?.email }); setLogoImage({ @@ -153,22 +154,22 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } setLoading(true) const userData = { - id: userProfileInfo?.id, + id: userProfileInfo?.id as number, firstName: values.firstName, lastName: values.lastName, email: values.email, profileImg: logoImage?.imagePreviewUrl as string || values?.profileImg, - publicProfile:values?.radio1 + isPublic } const resUpdateUserDetails = await updateUserProfile(userData) + setLoading(false) const { data } = resUpdateUserDetails as AxiosResponse - updateProfile(userData); - - setLoading(false) - + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + updateProfile(userData); + } } const validationSchema = yup.object().shape({ @@ -200,7 +201,6 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } if (!values.firstName || !values.lastName) { return; } - values['radio1'] = values?.radio1 === 'true' ? true : false updateUserDetails(values); toggleEditProfile(); @@ -330,13 +330,14 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } value="Profile View" />
    - setIsPublic(false)} id="private" - name="radio1" - value="true" - /> + name="private" + /> Private Only the connected organization can see you organization details @@ -350,12 +351,13 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } value="" />
    - setIsPublic(true)} + checked={isPublic === true} id="public" - name="radio1" - value="false" + name="public" /> Public Your profile and organization details can be seen by everyone diff --git a/src/components/Profile/interfaces/index.ts b/src/components/Profile/interfaces/index.ts index 0fae36cb1..f9b37eb6d 100644 --- a/src/components/Profile/interfaces/index.ts +++ b/src/components/Profile/interfaces/index.ts @@ -48,12 +48,13 @@ export interface UserEmail { export interface UserProfile { id: number - profileImg: string - username: string + profileImg?: string + username?: string email: string firstName: string lastName: string - isEmailVerified: boolean - keycloakUserId: string - publicProfile:boolean + isEmailVerified?: boolean + keycloakUserId?: string + publicProfile?: boolean + isPublic?:boolean } \ No newline at end of file diff --git a/src/components/organization/EditOrgdetailsModal.tsx b/src/components/organization/EditOrgdetailsModal.tsx index 68689b54d..3ee77c6cc 100644 --- a/src/components/organization/EditOrgdetailsModal.tsx +++ b/src/components/organization/EditOrgdetailsModal.tsx @@ -229,8 +229,8 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { .trim(), description: yup .string() - .min(2, 'Organization name must be at least 2 characters') - .max(600, 'Organization name must be at most 255 characters') + .min(2, 'Organization description must be at least 2 characters') + .max(600, 'Organization description must be at most 255 characters') .required('Description is required') })} validateOnBlur @@ -240,7 +240,6 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { values: Values, { resetForm }: FormikHelpers ) => { - submitUpdateOrganization(values) }} > From d2d8b3aaec5ca0b616230dba0229b49bdadf5a9e Mon Sep 17 00:00:00 2001 From: 16-karan <141734327+16-karan@users.noreply.github.com> Date: Mon, 18 Sep 2023 17:17:41 +0530 Subject: [PATCH 029/250] feat: public profiles for users and organisations (#276) * feat public profile for organisation and user Signed-off-by: karan * fix: reviewed changes Signed-off-by: karan * fix: changes required Signed-off-by: karan --------- Signed-off-by: karan --- src/api/organization.ts | 42 ++++- src/app/PublicProfileLayout.astro | 16 ++ .../publicProfile/OrgUserInfoLayout.astro | 83 +++++++++ .../OrganisationPublicProfile.tsx | 159 +++++++++++++++++ .../publicProfile/ProfileDesign.astro | 30 ++++ .../publicProfile/PublicProfiles.tsx | 68 ++++++++ .../publicProfile/PublicUserList.tsx | 160 ++++++++++++++++++ .../publicProfile/WalletDetailQRLayout.astro | 90 ++++++++++ src/config/apiRoutes.ts | 4 + src/pages/index.astro | 6 + src/pages/org/[org].astro | 54 ++++++ src/pages/publicOrg/[publicOrg].astro | 53 ++++++ src/pages/publicUser/[publicuser].astro | 141 +++++++++++++++ src/pages/search.astro | 11 ++ src/pages/user/[user].astro | 141 +++++++++++++++ src/services/apiRequests.ts | 24 +++ 16 files changed, 1081 insertions(+), 1 deletion(-) create mode 100644 src/app/PublicProfileLayout.astro create mode 100644 src/components/publicProfile/OrgUserInfoLayout.astro create mode 100644 src/components/publicProfile/OrganisationPublicProfile.tsx create mode 100644 src/components/publicProfile/ProfileDesign.astro create mode 100644 src/components/publicProfile/PublicProfiles.tsx create mode 100644 src/components/publicProfile/PublicUserList.tsx create mode 100644 src/components/publicProfile/WalletDetailQRLayout.astro create mode 100644 src/pages/org/[org].astro create mode 100644 src/pages/publicOrg/[publicOrg].astro create mode 100644 src/pages/publicUser/[publicuser].astro create mode 100644 src/pages/search.astro create mode 100644 src/pages/user/[user].astro diff --git a/src/api/organization.ts b/src/api/organization.ts index e53dba9d1..0b1098567 100644 --- a/src/api/organization.ts +++ b/src/api/organization.ts @@ -1,4 +1,4 @@ -import { axiosGet, axiosPost, axiosPut } from "../services/apiRequests" +import { axiosGet, axiosPost, axiosPublicUserGet, axiosPut } from "../services/apiRequests" import { apiRoutes } from "../config/apiRoutes"; import { getFromLocalStorage } from "./Auth"; @@ -302,4 +302,44 @@ export const createConnection = async (orgName: string) => { } } +// public profile +export const getPublicUsers = async (pageNumber: number, pageSize: number, search :string) => { + + const url = `${apiRoutes.public.users}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` + + const axiosPayload = { + url, + } + + try { + return await axiosPublicUserGet(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} + +export const getPublicOrganizations = async (pageNumber: number, pageSize: number, search :string) => { + + const url = `${apiRoutes.public.organizations}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` + + const config = { + headers: { + 'Content-Type': 'application/json', + } + } + const axiosPayload = { + url, + config + } + + try { + return await axiosGet(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} diff --git a/src/app/PublicProfileLayout.astro b/src/app/PublicProfileLayout.astro new file mode 100644 index 000000000..b76adf6a6 --- /dev/null +++ b/src/app/PublicProfileLayout.astro @@ -0,0 +1,16 @@ +--- +import NavBarSidebar from "./NavBarSidebar.astro"; + +--- + + +
    +
    + + +
    +
    diff --git a/src/components/publicProfile/OrgUserInfoLayout.astro b/src/components/publicProfile/OrgUserInfoLayout.astro new file mode 100644 index 000000000..4aafa1197 --- /dev/null +++ b/src/components/publicProfile/OrgUserInfoLayout.astro @@ -0,0 +1,83 @@ +--- +interface UserDetails { + lastName: string; + firstName: string; + email: string; + publicProfile: boolean; + id: number; + username: string; +} +const { orgUsersData } = Astro.props; +--- +{orgUsersData && +
    +
    + { + orgUsersData && + orgUsersData?.map((orgUser: UserDetails) => { + return ( + <> +
    + {orgUser.firstName && + + + + + + + + + + + + + + + +
    + {orgUser.firstName} {orgUser.lastName} +
    } +
    + +
    + {orgUser.email && + +

    {orgUser.email}

    + } +
    + + ); + }) + } +
    +
    } diff --git a/src/components/publicProfile/OrganisationPublicProfile.tsx b/src/components/publicProfile/OrganisationPublicProfile.tsx new file mode 100644 index 000000000..bb6d2953d --- /dev/null +++ b/src/components/publicProfile/OrganisationPublicProfile.tsx @@ -0,0 +1,159 @@ +'use client'; + +import { ChangeEvent, useEffect, useState } from 'react'; +import { getPublicOrganizations } from '../../api/organization'; +import type { AxiosResponse } from 'axios'; +import { apiStatusCodes } from '../../config/CommonConstant'; +import SearchInput from '../SearchInput'; +import { Button, Card, Pagination } from 'flowbite-react'; +import CustomSpinner from '../CustomSpinner'; +import CustomAvatar from '../Avatar'; +import { EmptyListMessage } from '../EmptyListComponent'; + +const OrganisationPublicProfile = () => { + const initialPageState = { + pageNumber: 1, + pageSize: 10, + total: 0, + }; + + const [organizationsList, setOrganizationList] = useState([]); + + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const [searchText, setSearchText] = useState(''); + const [currentPage, setCurrentPage] = useState(initialPageState); + const onPageChange = (page: number) => { + setCurrentPage({ + ...currentPage, + pageNumber: page, + }); + }; + + const getAllOrganizations = async () => { + setLoading(true); + const response = await getPublicOrganizations( + currentPage?.pageNumber, + currentPage?.pageSize, + searchText, + ); + + const { data } = response as AxiosResponse; + + if (data?.statusCode === apiStatusCodes?.API_STATUS_SUCCESS) { + const totalPages = data?.data?.totalPages; + + const orgList = data?.data?.organizations.map((userOrg: any) => { + return userOrg; + }); + + setOrganizationList(orgList); + setCurrentPage({ + ...currentPage, + total: totalPages, + }); + } else { + setError(response as string); + } + setLoading(false); + }; + + useEffect(() => { + let getData: NodeJS.Timeout; + + if (searchText?.length >= 1) { + getData = setTimeout(() => { + getAllOrganizations(); + }, 1000); + } else { + getAllOrganizations(); + } + + return () => clearTimeout(getData); + }, [searchText, currentPage.pageNumber]); + + const searchInputChange = (e: ChangeEvent) => { + setSearchText(e.target.value); + }; + + return ( +
    +
    + +
    + +
    + {loading ? ( +
    + +
    + ) : organizationsList && organizationsList?.length > 0 ? ( +
    + {organizationsList?.map( + (org: { + logoUrl: string; + name: string; + description: string; + id: number; + orgSlug: string; + }) => ( + { + window.location.href = `/org/${org?.orgSlug}`; + }} + className="transform transition duration-500 hover:scale-[1.02] hover:bg-gray-50 cursor-pointer" + > +
    + {org.logoUrl ? ( + + ) : ( + + )} + +
    +
    +

    {org?.name}

    +
    +
    +
      +
    • +
      +
      + {org?.description} +
      +
      +
    • +
    +
    +
    +
    +
    + ), + )} +
    + ) : ( + organizationsList && ( +
    + +
    + ) + )} + +
    + {organizationsList && organizationsList?.length > 0 && ( + + )} +
    +
    +
    + ); +}; + +export default OrganisationPublicProfile; diff --git a/src/components/publicProfile/ProfileDesign.astro b/src/components/publicProfile/ProfileDesign.astro new file mode 100644 index 000000000..a5dc5b966 --- /dev/null +++ b/src/components/publicProfile/ProfileDesign.astro @@ -0,0 +1,30 @@ +--- +const {orgData} = Astro.props +import CustomAvatar from "../../components/Avatar" +--- + + +
    +
    +
    + + {orgData?.logoUrl ? ( + + ) : ( + + )} + +

    {orgData?.name}

    +
    + {orgData?.website && + + {orgData?.website} + } +
    +

    {orgData?.description}

    +
    +
    +
    + diff --git a/src/components/publicProfile/PublicProfiles.tsx b/src/components/publicProfile/PublicProfiles.tsx new file mode 100644 index 000000000..f89513402 --- /dev/null +++ b/src/components/publicProfile/PublicProfiles.tsx @@ -0,0 +1,68 @@ +'use client'; + +import PublicUserList from './PublicUserList'; +import OrganisationPublicProfile from './OrganisationPublicProfile'; + +const PublicProfile = () => { + return ( +
    +
    +
    +
      +
    • + +
    • +
    • + +
    • +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + ); +}; + +export default PublicProfile; diff --git a/src/components/publicProfile/PublicUserList.tsx b/src/components/publicProfile/PublicUserList.tsx new file mode 100644 index 000000000..793a51432 --- /dev/null +++ b/src/components/publicProfile/PublicUserList.tsx @@ -0,0 +1,160 @@ +'use client'; + +import React, { ChangeEvent, useEffect, useState } from 'react'; +import type { AxiosResponse } from 'axios'; +import { apiStatusCodes } from '../../config/CommonConstant'; +import { getPublicUsers } from '../../api/organization'; +import SearchInput from '../SearchInput'; +import { Card, Pagination } from 'flowbite-react'; +import CustomAvatar from '../Avatar'; +import CustomSpinner from '../CustomSpinner'; +import { EmptyListMessage } from '../EmptyListComponent'; + +const PublicUserList = () => { + const initialPageState = { + pageNumber: 1, + pageSize: 10, + total: 0, + }; + const [usersData, setUsersData] = useState([]); + const [searchText, setSearchText] = useState(''); + + const [error, setError] = useState(null); + const [loading, setLoading] = useState(false); + const [currentPage, setCurrentPage] = useState(initialPageState); + const onPageChange = (page: number) => { + setCurrentPage({ + ...currentPage, + pageNumber: page, + }); + }; + const getAllPublicUsers = async () => { + setLoading(true); + const response = await getPublicUsers( + currentPage.pageNumber, + currentPage.pageSize, + searchText, + ); + + const { data } = response as AxiosResponse; + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + const totalPages = data?.data?.totalPages; + + const usersList = data?.data?.users.map((users: any) => { + return users; + }); + + setUsersData(usersList); + setCurrentPage({ + ...currentPage, + total: totalPages, + }); + } else { + setError(response as string); + } + setLoading(false); + }; + + useEffect(() => { + let getData: NodeJS.Timeout | undefined; + + if (searchText.length >= 1) { + getData = setTimeout(() => { + getAllPublicUsers(); + }, 1000); + } else { + getAllPublicUsers(); + } + + return () => clearTimeout(getData); + }, [searchText, currentPage.pageNumber]); + + const searchInputChange = (e: ChangeEvent) => { + setSearchText(e.target.value); + }; + + return ( + <> +
    + +
    + +
    + {loading ? ( + <> + + + ) : usersData && usersData?.length > 0 ? ( +
    + {usersData.map( + (user: { + logoUrl: string; + firstName: string; + email: string; + id: number; + username: string; + }) => ( + { + window.location.href = `/user/${user.username}`; + }} + className="transform transition duration-500 hover:scale-[1.02] hover:bg-gray-50 cursor-pointer" + > +
    + {user.logoUrl ? ( + + ) : ( + + )} + +
    +
    +

    {user.firstName}

    +
    +
    +
      +
    • +
      +
      + {user.email} +
      +
      +
    • +
    +
    +
    +
    +
    + ), + )} +
    + ) : ( + usersData && ( +
    + +
    + ) + )} + +
    + {usersData && usersData?.length > 0 && ( + + )} +
    +
    + + ); +}; + +export default PublicUserList; diff --git a/src/components/publicProfile/WalletDetailQRLayout.astro b/src/components/publicProfile/WalletDetailQRLayout.astro new file mode 100644 index 000000000..467cf4dc4 --- /dev/null +++ b/src/components/publicProfile/WalletDetailQRLayout.astro @@ -0,0 +1,90 @@ +--- +import CustomQRCode from "../../commonComponents/QRcode"; +const {orgData} = Astro.props +interface UserObject { + orgDid:string + ledgers:{ + name:string + networkType:string + } + networkType:string + walletName:string + createDateTime:string +} +--- + +
    +
    +

    Wallet Details

    + + { orgData?.org_agents.length > 0 ? +
    +
      + {orgData?.org_agents ? + orgData?.org_agents?.map((agentData:UserObject) => ( +
    • + DID + : + {agentData?.orgDid} + +
    • +
    • + Ledger + : + {agentData?.ledgers?.name} +
    • +
    • + Network + : + {agentData?.ledgers?.networkType} +
    • +
    • + WalletName + : + {agentData?.walletName} +
    • +
    • + CreationDate + : + {agentData?.createDateTime} +
    • + )) + : +
        + Wallet details are not avilable. Need to create wallet. +
      + + } +
    +
    : +

    + + Wallet details are not avilable. Need to create wallet. +

    + } +
    +{orgData?.org_agents.length > 0 && +
    +
    + { orgData?.org_agents && + +
    + +
    + } +
    +
    } +
    + + + diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index b34fe5dd2..1a8c6fb2e 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -65,6 +65,10 @@ export const apiRoutes = { }, Agent:{ checkAgentHealth: '/agent-service/health', + }, + public:{ + organizations: '/organization/public-profiles', + users:'/users/public-profiles', } } diff --git a/src/pages/index.astro b/src/pages/index.astro index 9c4eafae8..0e61f2c88 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -24,6 +24,12 @@ import { pathRoutes } from '../config/pathRoutes'; >
    + Explore + { + return users?.user; + }, +); +--- + +
    + + +
    +
    + +
    + +
    + +
    +

    Users

    + +
    +
    +
    +
    diff --git a/src/pages/publicOrg/[publicOrg].astro b/src/pages/publicOrg/[publicOrg].astro new file mode 100644 index 000000000..7026962d9 --- /dev/null +++ b/src/pages/publicOrg/[publicOrg].astro @@ -0,0 +1,53 @@ +--- +import { pathRoutes } from '../../config/pathRoutes'; +import ProfileDesign from '../../components/publicProfile/ProfileDesign.astro'; +import WalletDetailQRLayout from '../../components/publicProfile/WalletDetailQRLayout.astro'; +import OrgUserInfoLayout from '../../components/publicProfile/OrgUserInfoLayout.astro'; + +const { publicOrg } = Astro.params; +const baseUrl = process.env.PUBLIC_BASE_URL || import.meta.env.PUBLIC_BASE_URL +const response = await fetch( + `${baseUrl}/organization/public-profiles/${publicOrg}`, +); +const data = await response?.json(); +const orgData = data?.data; +const orgUsersData = orgData?.userOrgRoles?.map( + (users: { user: { firstName: string } }) => { + return users?.user; + }, +); +--- + +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +

    Users

    + +
    +
    +
    +
    diff --git a/src/pages/publicUser/[publicuser].astro b/src/pages/publicUser/[publicuser].astro new file mode 100644 index 000000000..8e5bcf285 --- /dev/null +++ b/src/pages/publicUser/[publicuser].astro @@ -0,0 +1,141 @@ +--- +import CustomAvatar from '../../components/Avatar'; +import { pathRoutes } from '../../config/pathRoutes'; + +const { publicuser } = Astro.params; +const baseUrl = process.env.PUBLIC_BASE_URL || import.meta.env.PUBLIC_BASE_URL +const response = await fetch(`${baseUrl}/users/public-profiles/${publicuser}`); +const data = await response.json(); +const userData = data?.data; +--- + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + { + userData?.logoUrl ? ( + + ) : ( + + ) + } +

    + {userData?.firstName}{' '}{userData?.lastName} +

    +
    + + {userData?.email} +
    +
    +
    +
    + + +
    + +
    + { + userData?.userOrgRoles?.map( + (userOrg: { + organisation: { + name: string; + description: string; + logoUrl: string; + id: number; + orgSlug:string + }; + name: string; + }) => { + return ( + userOrg?.organisation?.name && ( + +
    +
    +
    +
    + {userOrg?.name} +
    +

    + {userOrg?.organisation?.name && + userOrg?.organisation?.name } +

    +
    +
    +

    + {userOrg?.organisation?.description && + userOrg?.organisation?.description} +

    +
    + + {userData?.publicProfile && + View More.. + } +
    +
    + ) + ); + }, + ) + } +
    +
    +
    +
    +
    diff --git a/src/pages/search.astro b/src/pages/search.astro new file mode 100644 index 000000000..8edab03cc --- /dev/null +++ b/src/pages/search.astro @@ -0,0 +1,11 @@ +--- +import PublicProfile from "../components/publicProfile/PublicProfiles" +import PublicProfileLayout from "../app/PublicProfileLayout.astro" +import LayoutCommon from "../app/LayoutCommon.astro"; + +--- + + + + + diff --git a/src/pages/user/[user].astro b/src/pages/user/[user].astro new file mode 100644 index 000000000..89de7bad5 --- /dev/null +++ b/src/pages/user/[user].astro @@ -0,0 +1,141 @@ +--- +import CustomAvatar from '../../components/Avatar'; +import { pathRoutes } from '../../config/pathRoutes'; + +const { user } = Astro.params; +const baseUrl = process.env.PUBLIC_BASE_URL || import.meta.env.PUBLIC_BASE_URL +const response = await fetch(`${baseUrl}/users/public-profiles/${user}`); +const data = await response.json(); +const userData = data?.data; +--- + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + { + userData?.logoUrl ? ( + + ) : ( + + ) + } +

    + {userData?.firstName}{' '}{userData?.lastName} +

    +
    + + {userData?.email} +
    +
    +
    +
    + + +
    + +
    + { + userData?.userOrgRoles?.map( + (userOrg: { + organisation: { + name: string; + description: string; + logoUrl: string; + id: number; + orgSlug:string + }; + name: string; + }) => { + return ( + userOrg?.organisation?.name && ( + +
    +
    +
    +
    + {userOrg?.name} +
    +

    + {userOrg?.organisation?.name && + userOrg?.organisation?.name } +

    +
    +
    +

    + {userOrg?.organisation?.description && + userOrg?.organisation?.description} +

    +
    + + {userData?.publicProfile && + View More.. + } +
    +
    + ) + ); + }, + ) + } +
    +
    +
    +
    +
    diff --git a/src/services/apiRequests.ts b/src/services/apiRequests.ts index aaf5e4fcc..df89491d6 100644 --- a/src/services/apiRequests.ts +++ b/src/services/apiRequests.ts @@ -19,6 +19,30 @@ export const axiosGet = async ({ url, config }: APIParameters): Promise => { + try { + const response = await axiosUser.get(url); + + return response + } + catch (error) { + const err = error as AxiosError + return HandleResponse(err.response ? err.response : err) + } +} + +export const axiosPublicOrganisationGet = async ({ url }: APIParameters): Promise => { + try { + const response = await axiosUser.get(url); + + return response + } + catch (error) { + const err = error as AxiosError + return HandleResponse(err.response ? err.response : err) + } +} + export const axiosPost = async ({ url, payload, config }: APIParameters): Promise => { try { const response = await axiosUser.post(url, payload, config); From f34b05053cccb15eaeba5b73bdb6fa6193e677ec Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Mon, 18 Sep 2023 19:17:34 +0530 Subject: [PATCH 030/250] refactor api for schema module Signed-off-by: bhavanakarwade --- src/api/Schema.ts | 2 +- src/components/Resources/Schema/ViewSchema.tsx | 9 ++++++--- src/config/apiRoutes.ts | 1 - 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api/Schema.ts b/src/api/Schema.ts index 7fa91c63b..866523732 100644 --- a/src/api/Schema.ts +++ b/src/api/Schema.ts @@ -30,7 +30,7 @@ export const getAllSchemas = async ({itemPerPage, page, allSearch }: GetAllSchem export const getAllSchemasByOrgId = async ({ search, itemPerPage, page }: GetAllSchemaListParameter, orgId: string) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getAll}&pageNumber=${page}&pageSize=${itemPerPage}&searchByText=${search}`, + url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getAll}?pageNumber=${page}&pageSize=${itemPerPage}&searchByText=${search}`, config: { headers: { 'Content-type': 'application/json', diff --git a/src/components/Resources/Schema/ViewSchema.tsx b/src/components/Resources/Schema/ViewSchema.tsx index 27c5e260f..c17acb637 100644 --- a/src/components/Resources/Schema/ViewSchema.tsx +++ b/src/components/Resources/Schema/ViewSchema.tsx @@ -50,7 +50,7 @@ const ViewSchemas = () => { const [success, setSuccess] = useState(null) const [credDefListErr, setCredDefListErr] = useState(null) const [schemaDetailErr, setSchemaDetailErr] = useState(null) - const [failure, setFailur] = useState(null) + const [failure, setFailure] = useState(null) const [orgId, setOrgId] = useState(0) const [credDefAuto, setCredDefAuto] = useState('') @@ -143,7 +143,7 @@ const ViewSchemas = () => { setSuccess(data?.message) } else { - setFailur(createCredDeff as string) + setFailure(createCredDeff as string) setCreateLoader(false) } getCredentialDefinitionList(schemaDetails?.schemaId, orgId) @@ -334,7 +334,10 @@ const ViewSchemas = () => { (success || failure) && setSuccess(null)} + onDismiss={() => { + setSuccess(null) + setFailure(null) + }} >

    diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index 2cce24dae..f6ce41c2f 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -53,7 +53,6 @@ export const apiRoutes = { }, Issuance:{ getIssuedCredentials:'/issue-credentials', - // getCredDefBySchemaId :'/schemas/cred-defs', getAllConnections:'/connections', issueCredential:'/issue-credentials/create-offer' }, From 5c8163cdfa467bd0801b73839cc4debedf2aa22c Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Mon, 18 Sep 2023 19:39:27 +0530 Subject: [PATCH 031/250] feat: refactor api's for connection verification and issuance module Signed-off-by: bhavanakarwade --- src/api/connection.ts | 2 +- src/api/issuance.ts | 7 +++---- src/api/organization.ts | 4 +--- src/api/verification.ts | 17 +++++++---------- src/config/apiRoutes.ts | 24 ++++++++++++------------ 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/api/connection.ts b/src/api/connection.ts index 678cd3046..5b670771b 100644 --- a/src/api/connection.ts +++ b/src/api/connection.ts @@ -6,7 +6,7 @@ import { getFromLocalStorage } from './Auth'; export const getConnectionsByOrg = async () => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - const url = `${apiRoutes.Issuance.getAllConnections}?orgId=${orgId}`; + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.getAllConnections}`; const axiosPayload = { url, config: await getHeaderConfigs(), diff --git a/src/api/issuance.ts b/src/api/issuance.ts index 0706f5b5d..daa4514df 100644 --- a/src/api/issuance.ts +++ b/src/api/issuance.ts @@ -7,8 +7,7 @@ import { getFromLocalStorage } from './Auth'; export const getIssuedCredentials = async (state: IssueCredential) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - const url = `${apiRoutes.Issuance.getIssuedCredentials}?orgId=${orgId}`; - + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.getIssuedCredentials}`; const axiosPayload = { url, config: await getHeaderConfigs(), @@ -40,8 +39,8 @@ export const getCredentialDefinitions = async (schemaId: string) => { export const issueCredential = async (data: object) => { - const url = apiRoutes.Issuance.issueCredential; - const payload = data; + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.issueCredential}`; const payload = data; const axiosPayload = { url, payload, diff --git a/src/api/organization.ts b/src/api/organization.ts index 0b1098567..10423df99 100644 --- a/src/api/organization.ts +++ b/src/api/organization.ts @@ -274,10 +274,8 @@ export const editOrganizationUserRole = async (userId: number, roles: number[]) export const createConnection = async (orgName: string) => { - - const url = apiRoutes.connection.create - const orgId = await getFromLocalStorage(storageKeys.ORG_ID) + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.connection.create}` const data = { label: orgName, diff --git a/src/api/verification.ts b/src/api/verification.ts index 75aef3370..0c6475d8b 100644 --- a/src/api/verification.ts +++ b/src/api/verification.ts @@ -6,8 +6,8 @@ import { axiosGet, axiosPost } from '../services/apiRequests'; import { getFromLocalStorage } from './Auth'; export const verifyCredential = async (payload: any) => { - const url = apiRoutes.Verification.verifyCredential; - const axiosPayload = { + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.verifyCredential}`; const axiosPayload = { url, payload, config: await getHeaderConfigs(), @@ -40,8 +40,7 @@ export const getVerificationCredential = async (state: IssueCredential) => { export const getVerificationList = async () => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - const url = `${apiRoutes.Verification.getAllRequestList}?orgId=${orgId}`; - + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.getAllRequestList}` const axiosPayload = { url, config: await getHeaderConfigs(), @@ -55,10 +54,9 @@ export const getVerificationList = async () => { } }; -export const verifyPresentation = async (id:string) => { +export const verifyPresentation = async (proofId:string) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - const url = `${apiRoutes.Verification.presentationVerification}?orgId=${orgId}&id=${id}`; - + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.presentationVerification}/${proofId}/verify`; const axiosPayload = { url, config: await getHeaderConfigs(), @@ -73,10 +71,9 @@ export const verifyPresentation = async (id:string) => { }; -export const getProofAttributes=async (id:string)=>{ +export const getProofAttributes=async (proofId:string)=>{ const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - const url = `${apiRoutes.Verification.proofRequestAttributesVerification}?id=${id}&orgId=${orgId}`; - + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.proofRequestAttributesVerification}/${proofId}/form`; const axiosPayload = { url, config: await getHeaderConfigs(), diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index 1a8c6fb2e..c67150602 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -18,6 +18,7 @@ export const apiRoutes = { recentActivity: '/users/activity', }, organizations: { + root: '/orgs', create: '/organization', update: '/organization', getAll: '/organization', @@ -51,18 +52,17 @@ export const apiRoutes = { fidoVerifyAuthentication: 'Fido/verify-authentication/' }, - Issuance:{ - getIssuedCredentials:'/issue-credentials', - getCredDefBySchemaId :'/schemas/credential-definitions', - getAllConnections:'/connections', - issueCredential:'/issue-credentials/create-offer' - }, - Verification:{ - getAllRequestList: '/proofs', - verifyCredential:'/proofs/request-proof', - presentationVerification:'/proofs/verify-presentation', - proofRequestAttributesVerification:'/proofs/form-data' - }, + Issuance: { + getIssuedCredentials: '/credentials', + getAllConnections: '/connections', + issueCredential: '/credentials/offer', + }, + Verification: { + getAllRequestList: '/credentials/proofs', + verifyCredential: '/proofs', + presentationVerification: '/proofs', + proofRequestAttributesVerification: '/proofs' + }, Agent:{ checkAgentHealth: '/agent-service/health', }, From bbeb0edf811d35b13bb8749394ce9fdfbaee7327 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Mon, 18 Sep 2023 19:52:02 +0530 Subject: [PATCH 032/250] fix: refactor creddef by id api Signed-off-by: bhavanakarwade --- src/config/apiRoutes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index c67150602..681a6efc0 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -38,7 +38,7 @@ export const apiRoutes = { getAll: '/schemas', getSchemaById:'/schemas/id', createCredentialDefinition: '/credential-definitions', - getCredDeffBySchemaId: '/schemas/credential-definitions', + getCredDefBySchemaId: '/schemas', getAllSchemaFromPlatform: `/schemas/platform` }, fido: { From 07379fe32366e876eda8168035deb1f5cd7f446b Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Mon, 18 Sep 2023 19:54:44 +0530 Subject: [PATCH 033/250] removed unncecessary code Signed-off-by: bhavanakarwade --- src/config/apiRoutes.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index 919face45..21b707ac5 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -35,10 +35,8 @@ export const apiRoutes = { create: '/schemas', getAll: '/schemas', getSchemaById:'/schemas', - // createCredentialDefinition: '/credential-definitions', createCredentialDefinition: '/cred-defs', getCredDefBySchemaId: '/schemas', - // getAllSchemaFromPlatform: `/schemas/platform`, }, fido: { generateRegistration: 'fido/generate-registration-options', From 73770103d09002e7e296162d6d73ab5eb944a70c Mon Sep 17 00:00:00 2001 From: MoulikaKulkarni Date: Mon, 18 Sep 2023 19:56:26 +0530 Subject: [PATCH 034/250] fix: create schema responsiveness Signed-off-by: MoulikaKulkarni --- src/components/Resources/Schema/Create.tsx | 1006 +++++++++++--------- 1 file changed, 535 insertions(+), 471 deletions(-) diff --git a/src/components/Resources/Schema/Create.tsx b/src/components/Resources/Schema/Create.tsx index 5660dbc33..08b72bc01 100644 --- a/src/components/Resources/Schema/Create.tsx +++ b/src/components/Resources/Schema/Create.tsx @@ -4,13 +4,8 @@ import * as yup from 'yup'; import { Alert, Button, Card, Label, Table } from 'flowbite-react'; import { Field, FieldArray, Form, Formik } from 'formik'; -import { - apiStatusCodes, - schemaVersionRegex, - storageKeys, -} from '../../../config/CommonConstant'; +import {apiStatusCodes,schemaVersionRegex,storageKeys} from '../../../config/CommonConstant'; import { useEffect, useState } from 'react'; - import type { AxiosResponse } from 'axios'; import BreadCrumbs from '../../BreadCrumbs'; import type { FieldName, Values } from './interfaces'; @@ -19,477 +14,546 @@ import { addSchema } from '../../../api/Schema'; import { getFromLocalStorage } from '../../../api/Auth'; import { pathRoutes } from '../../../config/pathRoutes'; -const options = [ - { value: 'string', label: 'String' }, - { value: 'number', label: 'Number' }, - { value: 'date', label: 'Date' }, -]; - -const CreateSchema = () => { - const [failure, setFailure] = useState(null); - const [orgId, setOrgId] = useState(0); - const [orgDid, setOrgDid] = useState(''); - const [createloader, setCreateLoader] = useState(false); - - useEffect(() => { - const fetchData = async () => { - const organizationId = await getFromLocalStorage(storageKeys.ORG_ID); - setOrgId(Number(organizationId)); - }; - - fetchData(); - }, []); - - const submit = async (values: Values) => { - setCreateLoader(true); - const schemaFieldName: FieldName = { - schemaName: values.schemaName, - schemaVersion: values.schemaVersion, - attributes: values.attribute, - orgId: orgId, - }; - - const createSchema = await addSchema(schemaFieldName); - const { data } = createSchema as AxiosResponse; - if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { - if (data?.data) { - setCreateLoader(false); - window.location.href = pathRoutes.organizations.schemas; - } else { - setFailure(createSchema as string); - setCreateLoader(false); - } - } else { - setCreateLoader(false); - setFailure(createSchema as string); - setTimeout(() => { - setFailure(null); - }, 4000); - } - }; - - return ( -

    -
    - -

    - Create Schema -

    -
    -
    - -
    - => { - values.attribute.forEach((element: any) => { - if (!element.schemaDataType) { - element.schemaDataType = 'string'; - } - }); - const updatedAttribute: Array = []; - values.attribute.forEach((element) => { - updatedAttribute.push(Number(element)); - }); - submit(values); - }} - > - {(formikHandlers): JSX.Element => ( -
    -
    -
    -
    -
    -
    - {' '} - - {formikHandlers.errors && - formikHandlers.touched.schemaName && - formikHandlers.errors.schemaName ? ( - - ) : ( - - )} -
    -
    -
    -
    -
    -
    - {' '} - - {formikHandlers.errors && - formikHandlers.touched.schemaVersion && - formikHandlers.errors.schemaVersion ? ( - - ) : ( - - )} -
    -
    -
    -
    - - {(fieldArrayProps: any): JSX.Element => { - const { form, remove, push } = fieldArrayProps; - const { values } = form; - const { attribute } = values; - - const areFirstInputsSelected = - values.schemaName && values.schemaVersion; - - return ( - <> -
    - Attributes * -
    -
    - {attribute.map((element: any, index: number) => ( -
    - -
    -
    - - {formikHandlers.touched.attribute && - attribute[index] && - formikHandlers?.errors?.attribute && - formikHandlers?.errors?.attribute[ - index - ] && - formikHandlers?.touched?.attribute[index] - ?.attributeName && - formikHandlers?.errors?.attribute[index] - ?.attributeName ? ( - - ) : ( - - )} -
    - -
    - - {options.map((opt) => { - return ( - - ); - })} - - {formikHandlers?.touched?.attribute && - attribute[index] && - formikHandlers?.errors?.attribute && - formikHandlers?.errors?.attribute[ - index - ] && - formikHandlers?.touched?.attribute[index] - ?.schemaDataType && - formikHandlers?.errors?.attribute[index] - ?.schemaDataType ? ( - - ) : ( - - )} -
    -
    - - - {formikHandlers?.touched?.attribute && - attribute[index] && - formikHandlers?.errors?.attribute && - formikHandlers?.errors?.attribute[ - index - ] && - formikHandlers?.touched?.attribute[index] - ?.displayName && - formikHandlers?.errors?.attribute[index] - ?.displayName ? ( - - ) : ( - - )} -
    - {index === 0 && attribute.length === 1 ? ( - '' - ) : ( -
    + const options = [ + { value: 'string', label: 'String' }, + { value: 'number', label: 'Number' }, + { value: 'date', label: 'Date' }, + ]; + + + const CreateSchema = () => { + const [failure, setFailure] = useState(null); + const [orgId, setOrgId] = useState(0); + const [orgDid, setOrgDid] = useState(''); + const [createloader, setCreateLoader] = useState(false); + + useEffect(() => { + const fetchData = async () => { + const organizationId = await getFromLocalStorage( + storageKeys.ORG_ID); + setOrgId(Number(organizationId)); + }; + + fetchData(); + }, []); + + const submit = async (values: Values) => { + setCreateLoader(true); + const schemaFieldName: FieldName = { + schemaName: values.schemaName, + schemaVersion: values.schemaVersion, + attributes: values.attribute, + orgId: orgId, + }; + + const createSchema = await addSchema(schemaFieldName); + const { data } = createSchema as AxiosResponse; + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + + if (data?.data) { + setCreateLoader(false); + window.location.href = pathRoutes.organizations.schemas; + + } else { + setFailure(createSchema as string); + setCreateLoader(false); + } + } else { + setCreateLoader(false); + setFailure(createSchema as string); + setTimeout(() => { + setFailure(null); + }, 4000); + } + }; + + return ( +
    +
    + +

    + Create Schema +

    +
    +
    + +
    + => { + values.attribute.forEach((element: any) => { + + if (!element.schemaDataType) { + element.schemaDataType = 'string'; + } + }); + const updatedAttribute: Array = []; + values.attribute.forEach((element) => { + updatedAttribute.push(Number(element)); + + }); + submit(values); + }} + > + {(formikHandlers): JSX.Element => ( + + +
    +
    +
    +
    +
    + {' '} + + {formikHandlers.errors && + formikHandlers.touched.schemaName && + formikHandlers.errors.schemaName ? ( + + + ) : ( + + )} +
    +
    +
    +
    +
    +
    + {' '} + + {formikHandlers.errors && + formikHandlers.touched.schemaVersion && + formikHandlers.errors.schemaVersion ? ( + + + ) : ( + + )} +
    +
    +
    +
    + + {(fieldArrayProps: any): JSX.Element => { + const { form, remove, push } = fieldArrayProps; + const { values } = form; + const { attribute } = values; + + const areFirstInputsSelected = + values.schemaName && values.schemaVersion; + + return ( + <> +
    + Attributes * + +
    +
    + {attribute.map((element: any, index: number, schemaDataType:string) => ( + +
    + + +
    +
    + + {formikHandlers.touched.attribute && + attribute[index] && + formikHandlers?.errors?.attribute && + formikHandlers?.errors?.attribute[ + index + ] && + formikHandlers?.touched?.attribute[index] + ?.attributeName && + formikHandlers?.errors?.attribute[index] + + ?.attributeName ? ( + + ) : ( + + )} +
    + +
    + + {options.map((opt) => { + return ( + + ); + })} + + {formikHandlers?.touched?.attribute && + attribute[index] && + formikHandlers?.errors?.attribute && + formikHandlers?.errors?.attribute[ + index + ] && + formikHandlers?.touched?.attribute[index] + ?.schemaDataType && + formikHandlers?.errors?.attribute[index] + + ?.schemaDataType ? ( + + ) : ( + + )} +
    +
    + + + {formikHandlers?.touched?.attribute && + attribute[index] && + formikHandlers?.errors?.attribute && + formikHandlers?.errors?.attribute[ + index + ] && + formikHandlers?.touched?.attribute[index] + ?.displayName && + formikHandlers?.errors?.attribute[index] + + ?.displayName ? ( + + ) : ( + + )} +
    + + + +
    + {index === 0 && attribute.length === 1 ? ( +
    -
    - )} - {index === attribute.length - 1 && ( - - )} -
    -
    - ))} -
    - - ); - }} - -
    - - {failure && ( -
    - setFailure(null)}> - -

    {failure}

    -
    -
    -
    - )} -
    -
    + ) : ( + +
    + +
    + )} + + {index === attribute.length - 1 && ( +
    + + +
    + )} +
    +
    +
    +
    + ))} +
    + + ); + }} + +
    + + {failure && ( +
    + setFailure(null)}> + +

    {failure}

    +
    +
    +
    + )} +
    + -
    - -
    - -
    - -
    - +
    + +
    + +
    + +
    + -
    - - )} - -
    - -
    -
    - ); +
    + + )} +
    +
    +
    +
    +
    + ); }; -export default CreateSchema; +export default CreateSchema; \ No newline at end of file From 169126c0fe81b43124d0dd9a8e9a774dc62c5dba Mon Sep 17 00:00:00 2001 From: MoulikaKulkarni Date: Tue, 19 Sep 2023 12:28:13 +0530 Subject: [PATCH 035/250] fix:fixed array index in keys Signed-off-by: MoulikaKulkarni --- src/components/Resources/Schema/Create.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Resources/Schema/Create.tsx b/src/components/Resources/Schema/Create.tsx index 08b72bc01..886170ed8 100644 --- a/src/components/Resources/Schema/Create.tsx +++ b/src/components/Resources/Schema/Create.tsx @@ -215,7 +215,7 @@ import { pathRoutes } from '../../../config/pathRoutes'; Attribute: {index + 1} -
    +
    {index === 0 && attribute.length === 1 ? ( -
    +
    + +
  • + +
  • + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + ); +}; + +export default PublicProfile; diff --git a/src/components/publicProfile/PublicUserList.tsx b/src/components/publicProfile/PublicUserList.tsx new file mode 100644 index 000000000..793a51432 --- /dev/null +++ b/src/components/publicProfile/PublicUserList.tsx @@ -0,0 +1,160 @@ +'use client'; + +import React, { ChangeEvent, useEffect, useState } from 'react'; +import type { AxiosResponse } from 'axios'; +import { apiStatusCodes } from '../../config/CommonConstant'; +import { getPublicUsers } from '../../api/organization'; +import SearchInput from '../SearchInput'; +import { Card, Pagination } from 'flowbite-react'; +import CustomAvatar from '../Avatar'; +import CustomSpinner from '../CustomSpinner'; +import { EmptyListMessage } from '../EmptyListComponent'; + +const PublicUserList = () => { + const initialPageState = { + pageNumber: 1, + pageSize: 10, + total: 0, + }; + const [usersData, setUsersData] = useState([]); + const [searchText, setSearchText] = useState(''); + + const [error, setError] = useState(null); + const [loading, setLoading] = useState(false); + const [currentPage, setCurrentPage] = useState(initialPageState); + const onPageChange = (page: number) => { + setCurrentPage({ + ...currentPage, + pageNumber: page, + }); + }; + const getAllPublicUsers = async () => { + setLoading(true); + const response = await getPublicUsers( + currentPage.pageNumber, + currentPage.pageSize, + searchText, + ); + + const { data } = response as AxiosResponse; + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + const totalPages = data?.data?.totalPages; + + const usersList = data?.data?.users.map((users: any) => { + return users; + }); + + setUsersData(usersList); + setCurrentPage({ + ...currentPage, + total: totalPages, + }); + } else { + setError(response as string); + } + setLoading(false); + }; + + useEffect(() => { + let getData: NodeJS.Timeout | undefined; + + if (searchText.length >= 1) { + getData = setTimeout(() => { + getAllPublicUsers(); + }, 1000); + } else { + getAllPublicUsers(); + } + + return () => clearTimeout(getData); + }, [searchText, currentPage.pageNumber]); + + const searchInputChange = (e: ChangeEvent) => { + setSearchText(e.target.value); + }; + + return ( + <> +
    + +
    + +
    + {loading ? ( + <> + + + ) : usersData && usersData?.length > 0 ? ( +
    + {usersData.map( + (user: { + logoUrl: string; + firstName: string; + email: string; + id: number; + username: string; + }) => ( + { + window.location.href = `/user/${user.username}`; + }} + className="transform transition duration-500 hover:scale-[1.02] hover:bg-gray-50 cursor-pointer" + > +
    + {user.logoUrl ? ( + + ) : ( + + )} + +
    +
    +

    {user.firstName}

    +
    +
    +
      +
    • +
      +
      + {user.email} +
      +
      +
    • +
    +
    +
    +
    +
    + ), + )} +
    + ) : ( + usersData && ( +
    + +
    + ) + )} + +
    + {usersData && usersData?.length > 0 && ( + + )} +
    +
    + + ); +}; + +export default PublicUserList; diff --git a/src/components/publicProfile/WalletDetailQRLayout.astro b/src/components/publicProfile/WalletDetailQRLayout.astro new file mode 100644 index 000000000..dcda37070 --- /dev/null +++ b/src/components/publicProfile/WalletDetailQRLayout.astro @@ -0,0 +1,89 @@ +--- +import CustomQRCode from "../../commonComponents/QRcode"; +const {orgData} = Astro.props +interface UserObject { + orgDid:string + ledgers:{ + name:string + networkType:string + } + networkType:string + walletName:string + createDateTime:string +} +--- + +
    +
    +

    Wallet Details

    + + { orgData?.org_agents.length > 0 ? +
    +
      + {orgData?.org_agents ? + orgData?.org_agents?.map((agentData:UserObject) => ( +
    • + DID + : + {agentData?.orgDid} + +
    • +
    • + Ledger + : + {agentData?.ledgers?.name} +
    • +
    • + Network + : + {agentData?.ledgers?.networkType} +
    • +
    • + WalletName + : + {agentData?.walletName} +
    • +
    • + CreationDate + : + {agentData?.createDateTime} +
    • + )) + : +
        + Wallet details are not avilable. Need to create wallet. +
      + + } +
    +
    : +

    + + Wallet details are not avilable. Need to create wallet. +

    + } +
    +{orgData?.org_agents.length > 0 && +
    +
    + { orgData?.org_agents && + +
    + +
    + } +
    +
    } +
    + + diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index e99a7597d..2e5a773af 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -66,6 +66,9 @@ export const apiRoutes = { checkAgentHealth: '/agents/health', agentDedicatedSpinup: '/agents/spinup', agentSharedSpinup: '/agents/wallet' + }, + public:{ + organizations: '/organization/public-profiles', + users:'/users/public-profiles', } - } diff --git a/src/pages/explore.astro b/src/pages/explore.astro new file mode 100644 index 000000000..8edab03cc --- /dev/null +++ b/src/pages/explore.astro @@ -0,0 +1,11 @@ +--- +import PublicProfile from "../components/publicProfile/PublicProfiles" +import PublicProfileLayout from "../app/PublicProfileLayout.astro" +import LayoutCommon from "../app/LayoutCommon.astro"; + +--- + + + + + diff --git a/src/pages/index.astro b/src/pages/index.astro index 9c4eafae8..fb5a00bfe 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -24,6 +24,11 @@ import { pathRoutes } from '../config/pathRoutes'; >
    + Explore { + return users?.user; + }, +); +--- + +
    + + +
    +
    + +
    + +
    + +
    +

    Users

    + +
    +
    +
    +
    diff --git a/src/pages/user/[user].astro b/src/pages/user/[user].astro new file mode 100644 index 000000000..89de7bad5 --- /dev/null +++ b/src/pages/user/[user].astro @@ -0,0 +1,141 @@ +--- +import CustomAvatar from '../../components/Avatar'; +import { pathRoutes } from '../../config/pathRoutes'; + +const { user } = Astro.params; +const baseUrl = process.env.PUBLIC_BASE_URL || import.meta.env.PUBLIC_BASE_URL +const response = await fetch(`${baseUrl}/users/public-profiles/${user}`); +const data = await response.json(); +const userData = data?.data; +--- + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + { + userData?.logoUrl ? ( + + ) : ( + + ) + } +

    + {userData?.firstName}{' '}{userData?.lastName} +

    +
    + + {userData?.email} +
    +
    +
    +
    + + +
    + +
    + { + userData?.userOrgRoles?.map( + (userOrg: { + organisation: { + name: string; + description: string; + logoUrl: string; + id: number; + orgSlug:string + }; + name: string; + }) => { + return ( + userOrg?.organisation?.name && ( + +
    +
    +
    +
    + {userOrg?.name} +
    +

    + {userOrg?.organisation?.name && + userOrg?.organisation?.name } +

    +
    +
    +

    + {userOrg?.organisation?.description && + userOrg?.organisation?.description} +

    +
    + + {userData?.publicProfile && + View More.. + } +
    +
    + ) + ); + }, + ) + } +
    +
    +
    +
    +
    From 4c4e555851b66950d1f6fb4c4a5a81b54374e63b Mon Sep 17 00:00:00 2001 From: karan Date: Wed, 20 Sep 2023 15:56:51 +0530 Subject: [PATCH 040/250] review changes Signed-off-by: karan --- src/services/apiRequests.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/services/apiRequests.ts b/src/services/apiRequests.ts index aaf5e4fcc..020da1c86 100644 --- a/src/services/apiRequests.ts +++ b/src/services/apiRequests.ts @@ -18,6 +18,30 @@ export const axiosGet = async ({ url, config }: APIParameters): Promise => { + try { + const response = await axiosUser.get(url); + + return response + } + catch (error) { + const err = error as AxiosError + return HandleResponse(err.response ? err.response : err) + } +} + +export const axiosPublicOrganisationGet = async ({ url }: APIParameters): Promise => { + try { + const response = await axiosUser.get(url); + + return response + } + catch (error) { + const err = error as AxiosError + return HandleResponse(err.response ? err.response : err) + } +} + export const axiosPost = async ({ url, payload, config }: APIParameters): Promise => { try { From 088b2af8348c05a4fbe4eb94adc50ec2320d0fd9 Mon Sep 17 00:00:00 2001 From: karan Date: Wed, 20 Sep 2023 16:01:26 +0530 Subject: [PATCH 041/250] modifications Signed-off-by: karan --- src/components/Profile/interfaces/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Profile/interfaces/index.ts b/src/components/Profile/interfaces/index.ts index 2102c9f94..72cc41132 100644 --- a/src/components/Profile/interfaces/index.ts +++ b/src/components/Profile/interfaces/index.ts @@ -48,8 +48,8 @@ export interface UserEmail { export interface UserProfile { id: number - profileImg: string - username: string + profileImg?: string + username?: string email: string firstName: string lastName: string From cff3d0f7f04c01a9725cdbe23ac248d10cf56056 Mon Sep 17 00:00:00 2001 From: karan Date: Wed, 20 Sep 2023 18:45:45 +0530 Subject: [PATCH 042/250] refactor schema api Signed-off-by: karan --- src/api/Schema.ts | 5 ++--- src/api/issuance.ts | 6 ++---- src/components/Resources/Schema/Create.tsx | 5 +++-- src/components/organization/CreateOrgFormModal.tsx | 2 +- src/components/organization/Dashboard.tsx | 14 ++++++++++---- src/config/apiRoutes.ts | 3 +++ 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/api/Schema.ts b/src/api/Schema.ts index 866523732..a86d4b49a 100644 --- a/src/api/Schema.ts +++ b/src/api/Schema.ts @@ -1,5 +1,5 @@ import type { GetAllSchemaListParameter, createCredDeffFieldName, createSchema } from "../components/Resources/Schema/interfaces"; -import { axiosDelete, axiosGet, axiosPost } from "../services/apiRequests"; +import { axiosGet, axiosPost } from "../services/apiRequests"; import { apiRoutes } from "../config/apiRoutes"; import { getFromLocalStorage } from "./Auth"; @@ -8,7 +8,7 @@ import { storageKeys } from "../config/CommonConstant"; export const getAllSchemas = async ({itemPerPage, page, allSearch }: GetAllSchemaListParameter) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: `${apiRoutes.Platform.getAllSchemaFromPlatform}?pageSize=${itemPerPage}&searchByText=${allSearch}&pageNumber=${page}`, + url: `${apiRoutes.Platform.getAllSchemaFromPlatform}?pageSize=${itemPerPage}&searchByText=${allSearch}&pageNumber=${page}`, config: { headers: { 'Content-type': 'application/json', @@ -52,7 +52,6 @@ export const getAllSchemasByOrgId = async ({ search, itemPerPage, page }: GetAll export const addSchema = async (payload: createSchema, orgId: number) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - // url: apiRoutes.schema.create, url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.create}`, payload, config: { diff --git a/src/api/issuance.ts b/src/api/issuance.ts index 3c7d0be50..86ef44496 100644 --- a/src/api/issuance.ts +++ b/src/api/issuance.ts @@ -1,13 +1,12 @@ -import type { IssueCredential } from '../common/enums'; import { apiRoutes } from '../config/apiRoutes'; import { storageKeys } from '../config/CommonConstant'; import { getHeaderConfigs } from '../config/GetHeaderConfigs'; import { axiosGet, axiosPost } from '../services/apiRequests'; import { getFromLocalStorage } from './Auth'; -export const getIssuedCredentials = async (state: IssueCredential) => { +export const getIssuedCredentials = async (schemaId: string) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - const url = `${apiRoutes.Issuance.getIssuedCredentials}?orgId=${orgId}`; + const url= `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getCredDefBySchemaId}/${schemaId}/cred-defs`; const axiosPayload = { url, @@ -24,7 +23,6 @@ export const getIssuedCredentials = async (state: IssueCredential) => { export const getCredentialDefinitions = async (schemaId: string) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - // const url = `${apiRoutes.Issuance.getCredDefBySchemaId}?schemaId=${schemaId}&orgId=${orgId}`; const url= `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getCredDefBySchemaId}/${schemaId}/cred-defs`; const axiosPayload = { diff --git a/src/components/Resources/Schema/Create.tsx b/src/components/Resources/Schema/Create.tsx index e6a72c004..76f212f9d 100644 --- a/src/components/Resources/Schema/Create.tsx +++ b/src/components/Resources/Schema/Create.tsx @@ -201,8 +201,8 @@ import React from 'react'; return ( <> -
    - Attributes * +
    + Attributes *
    @@ -540,6 +540,7 @@ import React from 'react'; No, cancel - { - (addSuccess || addfailure || fidoError) && -
    - { - setAddSuccess(null) - setFidoError('') - setAddFailur('') - }} - > - -

    - {addSuccess || addfailure || fidoError} -

    -
    -
    -
    +
    +
    +
    +

    Add Passkey

    +

    With Passkey, no complex passwords to remember.

    +
    + + {deviceList && deviceList.length > 0 && + deviceList.map((element, key) => ( + + ))} + +
    + + + { + (addSuccess || addfailure || fidoError) && +
    + { + setAddSuccess(null) + setFidoError('') + setAddFailur('') + }} + > + +

    + {addSuccess || addfailure || fidoError} +

    +
    +
    +
    + } + +
    + +
    -
    + }
    - -
    - } +
    - ); -}; -export default AddPasskey; + ) +} + +export default AddPasskey \ No newline at end of file diff --git a/src/components/Profile/DisplayUserProfile.tsx b/src/components/Profile/DisplayUserProfile.tsx index e74c2aef2..143cbaa9d 100644 --- a/src/components/Profile/DisplayUserProfile.tsx +++ b/src/components/Profile/DisplayUserProfile.tsx @@ -1,131 +1,102 @@ import type { UserProfile } from "./interfaces"; import CustomAvatar from '../Avatar' import { Formik } from "formik"; -import React from "react"; +import React, { useState } from "react"; import { Button } from "flowbite-react"; +import EditUserProfile from "./EditUserProfile"; interface DisplayUserProfileProps { toggleEditProfile: () => void; userProfileInfo: UserProfile | null; } -// const DisplayUserProfile = ({ toggleEditProfile, userProfileInfo }: DisplayUserProfileProps) => { -const DisplayUserProfile = () => { +const DisplayUserProfile = ({toggleEditProfile, userProfileInfo }: DisplayUserProfileProps) => { + const [isEditing, setIsEditing] = useState(false); + + // const handleEditClick = () => { + // setIsEditing(true); + // }; return (
    - - {/*
    -
      - -
    • - {(userProfileInfo?.profileImg) ? - : - } - - - - - -
    • - -
    • -
      -
      -

      - Name -

      -

      - {userProfileInfo?.firstName} {userProfileInfo?.lastName} -

      -
      - -
      -
    • -
    • -
      - -
      -

      - Email -

      -

      - - {userProfileInfo?.email} -

      -
      -
      -
    • -
    -
    */} -
    + + {/* {isEditing ? () : ( */}
    +
    +

    General

    Basic info, like your first name, last name and profile image that will be displayed

    + + +
    +
    First Name
    -
    - +
    +

    + {userProfileInfo?.firstName} +

    +
    -
    Last Name
    -
    - +
    First Name
    +
    +

    + {userProfileInfo?.lastName} +

    Profile Image
    - {/* */}
    -
    - -
    -
    - - No File Chosen -
    + {(userProfileInfo?.profileImg) ? + : + } +
    + + 'No File Chosen' +
    @@ -133,7 +104,7 @@ const DisplayUserProfile = () => {
    + {/* )} */}
    -
    ); }; diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx index 216e829bc..c7291ed62 100644 --- a/src/components/Profile/EditUserProfile.tsx +++ b/src/components/Profile/EditUserProfile.tsx @@ -5,16 +5,17 @@ import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted, stora import type { AxiosResponse } from "axios"; import CustomAvatar from '../Avatar' import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; -import { Avatar, Button, Label } from "flowbite-react"; +import { Alert, Avatar, Button, Label } from "flowbite-react"; import { Field, Form, Formik, FormikHelpers } from "formik"; import { asset } from "../../lib/data"; import * as yup from "yup" +import React from "react"; interface Values { profileImg: string; firstName: string; lastName: string; - email:string; + email: string; } interface ILogoImage { @@ -28,10 +29,13 @@ interface EditUserProfileProps { updateProfile: (updatedProfile: UserProfile) => void; } -const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: EditUserProfileProps) => { +const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: EditUserProfileProps) => { const [loading, setLoading] = useState(false) const [isImageEmpty, setIsImageEmpty] = useState(true) + const [success, setSuccess] = useState(null) + const [failure, setFailure] = useState(null) + const [initialProfileData, setInitialProfileData] = useState({ profileImg: userProfileInfo?.profileImg || "", firstName: userProfileInfo?.firstName || "", @@ -50,10 +54,9 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } if (userProfileInfo) { setInitialProfileData({ profileImg: userProfileInfo?.profileImg || "", - firstName: userProfileInfo.firstName || '', - lastName: userProfileInfo.lastName || '', + firstName: userProfileInfo.firstName || "", + lastName: userProfileInfo.lastName || "", email: userProfileInfo?.email, - }); setLogoImage({ @@ -121,7 +124,7 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } ...logoImage, imagePreviewUrl: '', }); - + const reader = new FileReader() const file = event?.target?.files @@ -145,10 +148,6 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } const updateUserDetails = async (values: Values) => { - - console.log(`Image::`, logoImage?.imagePreviewUrl); - - setLoading(true) const userData = { @@ -158,7 +157,6 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } profileImg: logoImage?.imagePreviewUrl as string || values?.profileImg } - const resUpdateUserDetails = await updateUserProfile(userData) const { data } = resUpdateUserDetails as AxiosResponse @@ -171,170 +169,206 @@ const UpdateUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile } const validationSchema = yup.object().shape({ 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'), + .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'), 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') + .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') }); - return ( -
    -
    - - ) => { - if (!values.firstName || !values.lastName) { - return; - } - - updateUserDetails(values); - toggleEditProfile(); - }} - - validationSchema={validationSchema}> - {(formikHandlers): JSX.Element => ( -
    -
    -
    +
    +
    +
    +
    + + { + (success === "Profile Edited Successfully" || failure) && + { + setSuccess(null) + setFailure(null) + }} > + +

    + {success || failure} +

    +
    +
    + } + + + + ) => { + if (!values.firstName || !values.lastName) { + return; + } + + updateUserDetails(values); + toggleEditProfile(); + }} + + validationSchema={validationSchema}> + {(formikHandlers): JSX.Element => ( + + +
    +
    + +
    +

    General

    +

    Basic info, like your first name, last name and profile image that will be displayed

    +
    + + - {logoImage.imagePreviewUrl ? ( - Profile Picture - - ) : ( - )} - -
    -

    - Profile Image -

    -
    - JPG, JPEG and PNG . Max size of 1MB +
    -
    - -
    - +
    +
    + First Name + *
    +
    +
    + + {(formikHandlers?.errors?.firstName && formikHandlers?.touched?.firstName) && ( + + {formikHandlers?.errors?.firstName} + + )} +
    +
    -
    - - - -
    - - -
    -
    -
    -
    - - { - (formikHandlers?.errors?.firstName && formikHandlers?.touched?.firstName) && - {formikHandlers?.errors?.firstName} - } -
    - -
    -
    -
    - - { - (formikHandlers?.errors?.lastName && formikHandlers?.touched?.lastName) && - {formikHandlers?.errors?.lastName} - } -
    - -
    - -
    - - )} - +
    +
    + Last Name + * +
    + +
    +
    + + {(formikHandlers?.errors?.lastName && formikHandlers?.touched?.lastName) && ( + + {formikHandlers?.errors?.lastName} + + )} +
    +
    +
    +
    +
    Profile Image
    +
    +
    + {logoImage.imagePreviewUrl ? ( + Profile Picture + ) : ( + )} + +
    + + +
    +
    +
    +
    +
    + +
    +
    + +
    + + )} + +
    +
    +
    ); }; -export default UpdateUserProfile; +export default EditUserProfile; diff --git a/src/components/Profile/UpdatePassword.tsx b/src/components/Profile/UpdatePassword.tsx index 7d0199a41..cc358ed23 100644 --- a/src/components/Profile/UpdatePassword.tsx +++ b/src/components/Profile/UpdatePassword.tsx @@ -4,7 +4,7 @@ import React from 'react' const UpdatePassword = () => { return (
    -
    +
    @@ -17,21 +17,21 @@ const UpdatePassword = () => {
    Current Password
    - +
    New Password
    - +
    Confirm Password
    - +
    diff --git a/src/components/Profile/UserProfile.tsx b/src/components/Profile/UserProfile.tsx new file mode 100644 index 000000000..a89f2826d --- /dev/null +++ b/src/components/Profile/UserProfile.tsx @@ -0,0 +1,132 @@ +import { useEffect, useState } from 'react'; +import type { AxiosResponse } from 'axios'; +import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; +import { getFromLocalStorage, getUserProfile } from '../../api/Auth'; +import BreadCrumbs from '../BreadCrumbs'; +import type { UserProfile} from './interfaces'; +import DisplayUserProfile from './DisplayUserProfile'; +import React from 'react'; +import AddPasskey from './AddPasskey'; +import EditUserProfile from './EditUserProfile'; + +const UserProfile = () => { + const [isEditProfileOpen, setIsEditProfileOpen] = useState(false); + const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(null); + const [openModel, setOpenModel] = useState(false) + + const fetchUserProfile = async () => { + try { + const token = await getFromLocalStorage(storageKeys.TOKEN); + const userDetailsResponse = await getUserProfile(token); + const { data } = userDetailsResponse as AxiosResponse; + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + setPrePopulatedUserProfile(data?.data); + } + } catch (error) { + } + }; + + const toggleEditProfile = async () => { + await fetchUserProfile() + setIsEditProfileOpen(!isEditProfileOpen); + }; + + + useEffect(() => { + fetchUserProfile(); + }, []); + + + const updatePrePopulatedUserProfile = (updatedProfile: UserProfile) => { + setPrePopulatedUserProfile(updatedProfile); + }; + + return ( + +
    + +

    + User's Profile +

    + +
    +
    +
    +
      +
    • + +
    • + {/*
    • + +
    • */} +
    • + +
    • +
    +
    + +
    +
    +
    + +{!isEditProfileOpen && prePopulatedUserProfile && ( + + )} + + {isEditProfileOpen && prePopulatedUserProfile && ( + + )} + +
    + {/*
    + +
    */} + +
    + +
    + +
    +
    + +
    + ); +}; + +export default UserProfile; diff --git a/src/pages/profile.astro b/src/pages/profile.astro index 007222d0c..ea58791c9 100644 --- a/src/pages/profile.astro +++ b/src/pages/profile.astro @@ -1,6 +1,6 @@ --- import LayoutSidebar from '../app/LayoutSidebar.astro'; -import AddPasskey from '../components/Profile/AddPasskey'; +import UserProfile from '../components/Profile/UserProfile'; import { pathRoutes } from '../config/pathRoutes'; import { checkUserSession } from '../utils/check-session'; @@ -12,5 +12,5 @@ if (!response) { --- - + From 61b37bba8d561c27ab026767c6fee15d38df1d72 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Fri, 22 Sep 2023 12:50:34 +0530 Subject: [PATCH 051/250] developed User Profile Page as per new designs Signed-off-by: bhavanakarwade --- src/components/Profile/AddPasskey.tsx | 10 +++--- src/components/Profile/DisplayUserProfile.tsx | 33 ++++++++----------- src/components/Profile/EditUserProfile.tsx | 31 ++++++++--------- src/components/Profile/UserProfile.tsx | 21 ++++++------ 4 files changed, 43 insertions(+), 52 deletions(-) diff --git a/src/components/Profile/AddPasskey.tsx b/src/components/Profile/AddPasskey.tsx index 6d922b904..545dfd232 100644 --- a/src/components/Profile/AddPasskey.tsx +++ b/src/components/Profile/AddPasskey.tsx @@ -157,8 +157,8 @@ const AddPasskey = () => { return (
    -
    -
    +
    +
    {fidoLoader ?
    @@ -170,8 +170,8 @@ const AddPasskey = () => {
    -

    Add Passkey

    -

    With Passkey, no complex passwords to remember.

    +

    Add Passkey

    +

    With Passkey, no complex passwords to remember.

    {deviceList && deviceList.length > 0 && @@ -187,7 +187,7 @@ const AddPasskey = () => { color='bg-primary-800' className='mt-10 text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"' > - + Add Passkey diff --git a/src/components/Profile/DisplayUserProfile.tsx b/src/components/Profile/DisplayUserProfile.tsx index 143cbaa9d..0d73cc5c9 100644 --- a/src/components/Profile/DisplayUserProfile.tsx +++ b/src/components/Profile/DisplayUserProfile.tsx @@ -11,27 +11,21 @@ interface DisplayUserProfileProps { } const DisplayUserProfile = ({toggleEditProfile, userProfileInfo }: DisplayUserProfileProps) => { - const [isEditing, setIsEditing] = useState(false); - - // const handleEditClick = () => { - // setIsEditing(true); - // }; return (
    -
    -
    +
    +
    - {/* {isEditing ? () : ( */}
    -

    General

    -

    Basic info, like your first name, last name and profile image that will be displayed

    +

    General

    +

    Basic info, like your first name, last name and profile image that will be displayed

    -
    +
    +
    - {/* )} */}
    diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx index c7291ed62..f936ae388 100644 --- a/src/components/Profile/EditUserProfile.tsx +++ b/src/components/Profile/EditUserProfile.tsx @@ -183,8 +183,8 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: return (
    -
    -
    +
    +
    { @@ -211,10 +211,6 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: values: Values, { resetForm }: FormikHelpers ) => { - if (!values.firstName || !values.lastName) { - return; - } - updateUserDetails(values); toggleEditProfile(); }} @@ -229,8 +225,8 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }:
    -

    General

    -

    Basic info, like your first name, last name and profile image that will be displayed

    +

    General

    +

    Basic info, like your first name, last name and profile image that will be displayed

    -
    +
    First Name * @@ -262,11 +258,11 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: + className="bg-gray-50 py-3 px-4 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" /> {(formikHandlers?.errors?.firstName && formikHandlers?.touched?.firstName) && ( {formikHandlers?.errors?.firstName} @@ -277,7 +273,7 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }:
    -
    +
    Last Name *
    @@ -286,11 +282,11 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }:
    + className="bg-gray-50 py-3 px-4 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" /> {(formikHandlers?.errors?.lastName && formikHandlers?.touched?.lastName) && ( {formikHandlers?.errors?.lastName} @@ -301,7 +297,7 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }:
    -
    Profile Image
    +
    Profile Image
    {logoImage.imagePreviewUrl ? ( @@ -330,11 +326,11 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }:
    +
    -
    +
    +
    )} diff --git a/src/components/Profile/UserProfile.tsx b/src/components/Profile/UserProfile.tsx index a89f2826d..793711572 100644 --- a/src/components/Profile/UserProfile.tsx +++ b/src/components/Profile/UserProfile.tsx @@ -3,7 +3,7 @@ import type { AxiosResponse } from 'axios'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; import { getFromLocalStorage, getUserProfile } from '../../api/Auth'; import BreadCrumbs from '../BreadCrumbs'; -import type { UserProfile} from './interfaces'; +import type { UserProfile } from './interfaces'; import DisplayUserProfile from './DisplayUserProfile'; import React from 'react'; import AddPasskey from './AddPasskey'; @@ -12,7 +12,6 @@ import EditUserProfile from './EditUserProfile'; const UserProfile = () => { const [isEditProfileOpen, setIsEditProfileOpen] = useState(false); const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(null); - const [openModel, setOpenModel] = useState(false) const fetchUserProfile = async () => { try { @@ -55,14 +54,14 @@ const UserProfile = () => {
    @@ -51,14 +37,6 @@ const PublicProfile = () => { >
    -
    - -
    diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index a1d650476..cb9353209 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -67,7 +67,6 @@ export const apiRoutes = { getAllSchemaFromPlatform: '/platform/schemas', }, public:{ - organizations: '/organization/public-profiles', - users:'/users/public-profiles', + organizations: '/orgs/public-profile', } } diff --git a/src/pages/explore.astro b/src/pages/explore.astro index 8edab03cc..a4d4a52d2 100644 --- a/src/pages/explore.astro +++ b/src/pages/explore.astro @@ -1,6 +1,5 @@ --- import PublicProfile from "../components/publicProfile/PublicProfiles" -import PublicProfileLayout from "../app/PublicProfileLayout.astro" import LayoutCommon from "../app/LayoutCommon.astro"; --- diff --git a/src/pages/org/[org].astro b/src/pages/org/[org].astro index fae0c9afd..0cb46146c 100644 --- a/src/pages/org/[org].astro +++ b/src/pages/org/[org].astro @@ -7,12 +7,17 @@ import OrgUserInfoLayout from '../../components/publicProfile/OrgUserInfoLayout. const { org } = Astro.params; const baseUrl = process.env.PUBLIC_BASE_URL || import.meta.env.PUBLIC_BASE_URL const response = await fetch( - `${baseUrl}/organization/public-profiles/${org}`, + `${baseUrl}/orgs/public-profiles/${org}`, ); const data = await response?.json(); - const orgData = data?.data; -const orgUsersData = orgData?.userOrgRoles?.map( +const orgUsersFilterByRole = orgData?.userOrgRoles?.filter( + (users: { orgRole: {name:string}; }) => { + return users?.orgRole.name === "owner" + }, +); + +const orgUsersData = orgUsersFilterByRole?.map( (users: { user: { firstName: string } }) => { return users?.user; }, From e7f5b212c930de6da8f2d544a60f2830a5a7a4f1 Mon Sep 17 00:00:00 2001 From: MoulikaKulkarni Date: Fri, 29 Sep 2023 18:15:20 +0530 Subject: [PATCH 066/250] fix: dark mode alignment fixes Signed-off-by: MoulikaKulkarni --- src/components/Issuance/CredDefSelection.tsx | 3 ++- src/components/Verification/Verification.tsx | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/Issuance/CredDefSelection.tsx b/src/components/Issuance/CredDefSelection.tsx index 53ebd58a1..697cd1c45 100644 --- a/src/components/Issuance/CredDefSelection.tsx +++ b/src/components/Issuance/CredDefSelection.tsx @@ -60,7 +60,8 @@ const CredDefSelection = () => { const header = [ { columnName: 'Name' }, { columnName: 'Created on' }, - { columnName: 'Revocable?' } + { columnName: 'Revocable?' }, + { columnName: '' } ] //Fetch credential definitions against schemaId diff --git a/src/components/Verification/Verification.tsx b/src/components/Verification/Verification.tsx index 213fbe8c2..c6f1d621c 100644 --- a/src/components/Verification/Verification.tsx +++ b/src/components/Verification/Verification.tsx @@ -208,8 +208,11 @@ const VerificationCred = () => { onClick={() => { window.location.href = `${pathRoutes.back.verification.verification}` }} - className='bg-secondary-700 ring-primary-700 bg-white-700 hover:bg-secondary-700 ring-2 text-black font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 m-2 ml-2 dark:text-white' - style={{ height: '2.5rem', width: '5rem', minWidth: '2rem' }} + className='bg-secondary-700 ring-primary-700 bg-white-700 hover:bg-secondary-700 + ring-2 text-black font-medium rounded-lg text-sm px-4 lg:px-5 py-2 + lg:py-2.5 mr-2 ml-auto dark:text-white dark:hover:text-black + dark:hover:bg-primary-50' + style={{ height: '2.5rem', width: '5rem', minWidth: '2rem' }} > @@ -264,7 +267,7 @@ const VerificationCred = () => {
    } -
    +
    Attribute List
    Date: Fri, 29 Sep 2023 18:23:01 +0530 Subject: [PATCH 067/250] fix: dark mode fixes Signed-off-by: MoulikaKulkarni --- src/components/Issuance/CredDefSelection.tsx | 2 +- src/components/Verification/Verification.tsx | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/Issuance/CredDefSelection.tsx b/src/components/Issuance/CredDefSelection.tsx index 697cd1c45..5778e8b74 100644 --- a/src/components/Issuance/CredDefSelection.tsx +++ b/src/components/Issuance/CredDefSelection.tsx @@ -61,7 +61,7 @@ const CredDefSelection = () => { { columnName: 'Name' }, { columnName: 'Created on' }, { columnName: 'Revocable?' }, - { columnName: '' } + { columnName: ' ' } ] //Fetch credential definitions against schemaId diff --git a/src/components/Verification/Verification.tsx b/src/components/Verification/Verification.tsx index c6f1d621c..84931d348 100644 --- a/src/components/Verification/Verification.tsx +++ b/src/components/Verification/Verification.tsx @@ -208,10 +208,7 @@ const VerificationCred = () => { onClick={() => { window.location.href = `${pathRoutes.back.verification.verification}` }} - className='bg-secondary-700 ring-primary-700 bg-white-700 hover:bg-secondary-700 - ring-2 text-black font-medium rounded-lg text-sm px-4 lg:px-5 py-2 - lg:py-2.5 mr-2 ml-auto dark:text-white dark:hover:text-black - dark:hover:bg-primary-50' + className='bg-secondary-700 ring-primary-700 bg-white-700 hover:bg-secondary-700 ring-2 text-black font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 ml-auto dark:text-white dark:hover:text-black dark:hover:bg-primary-50' style={{ height: '2.5rem', width: '5rem', minWidth: '2rem' }} > From 8c43a252e0f0261ab92a7ba453e5b5642d075293 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Mon, 2 Oct 2023 11:08:56 +0530 Subject: [PATCH 068/250] feat:create ecosystem component Signed-off-by: pranalidhanavade --- src/api/ecosystems.ts | 38 +++ src/app/SideBar.astro | 192 ++++------- .../Ecosystems/CreateEcosystems.tsx | 320 ++++++++++++++++++ src/components/Ecosystems/Dashboard.tsx | 63 ++++ src/config/pathRoutes.ts | 17 +- src/pages/ecosystems/index.astro | 16 + 6 files changed, 504 insertions(+), 142 deletions(-) create mode 100644 src/api/ecosystems.ts create mode 100644 src/components/Ecosystems/CreateEcosystems.tsx create mode 100644 src/components/Ecosystems/Dashboard.tsx create mode 100644 src/pages/ecosystems/index.astro diff --git a/src/api/ecosystems.ts b/src/api/ecosystems.ts new file mode 100644 index 000000000..e2b73952a --- /dev/null +++ b/src/api/ecosystems.ts @@ -0,0 +1,38 @@ +import { axiosGet, axiosPost, axiosPut } from "../services/apiRequests" + +import { apiRoutes } from "../config/apiRoutes"; +import { getFromLocalStorage } from "./Auth"; +import { getHeaderConfigs } from "../config/GetHeaderConfigs"; +import { storageKeys } from "../config/CommonConstant"; + +export const createEcosystems = async (data: object) => { + + // const url = apiRoutes.organizations.create + // const payload = data + // const token = await getFromLocalStorage(storageKeys.TOKEN) + + // const config = { + // headers: { + // 'Content-Type': 'application/json', + // Authorization: `Bearer ${token}` + // } + // } + // const axiosPayload = { + // url, + // payload, + // config + // } + + // try { + // return await axiosPost(axiosPayload); + // } + // catch (error) { + // const err = error as Error + // return err?.message + // } +} + + + + + diff --git a/src/app/SideBar.astro b/src/app/SideBar.astro index 0a0e7247f..252b1f303 100644 --- a/src/app/SideBar.astro +++ b/src/app/SideBar.astro @@ -94,6 +94,63 @@ import { pathRoutes } from "../config/pathRoutes"; + + +
  • + + + Ecosystems + +
  • + + +
  • - - - - - - - +
  • - -
  • diff --git a/src/components/Ecosystems/CreateEcosystems.tsx b/src/components/Ecosystems/CreateEcosystems.tsx new file mode 100644 index 000000000..1f8c243c0 --- /dev/null +++ b/src/components/Ecosystems/CreateEcosystems.tsx @@ -0,0 +1,320 @@ +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 } from '../../config/CommonConstant' +import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; +import { useEffect, useRef, useState } from "react"; + +import { AlertComponent } from "../AlertComponent"; +import type { AxiosResponse } from 'axios'; +import { asset } from '../../lib/data.js'; +import { createEcosystems } from "../../api/ecosystems"; +import React from "react"; + +interface Values { + name: string; + description: string; +} + +interface ILogoImage { + logoFile: string | File + imagePreviewUrl: string | ArrayBuffer | null | File, + fileName: string +} + +const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: string)=> void ; setOpenModal: (flag: boolean) => void }) => { + + const [logoImage, setLogoImage] = useState({ + logoFile: "", + imagePreviewUrl: "", + fileName: '' + }) + + const [loading, setLoading] = useState(false) + + const [isImageEmpty, setIsImageEmpty] = useState(true) + const [initialEcoData, setEcoData] = useState({ + name: '', + description: '', + }) + const [erroMsg, setErrMsg] = useState(null) + + const [imgError, setImgError] = useState('') + + useEffect(() => { + setEcoData({ + name: '', + description: '', + }) + setLogoImage({ + ...logoImage, + logoFile: "", + imagePreviewUrl: "" + }) + }, [props.openModal]) + + + const ProcessImg = (e: any): string | undefined => { + + const file = e?.target.files[0] + if (!file) { return } + + const reader = new FileReader() + reader.readAsDataURL(file) + + reader.onload = (event): void => { + const imgElement = document.createElement("img") + if (imgElement) { + imgElement.src = typeof event?.target?.result === 'string' ? event.target.result : "" + imgElement.onload = (e): void => { + let fileUpdated: File | string = file + let srcEncoded = '' + const canvas = document.createElement("canvas") + + const { width, height, ev } = calculateSize(imgElement, IMG_MAX_WIDTH, IMG_MAX_HEIGHT) + canvas.width = width + canvas.height = height + + const ctx = canvas.getContext("2d") + if (ctx && e?.target) { + ctx.imageSmoothingEnabled = true + ctx.imageSmoothingQuality = "high" + ctx.drawImage(ev, 0, 0, canvas.width, canvas.height) + srcEncoded = ctx.canvas.toDataURL(ev, file.type) + const blob = dataURItoBlob(srcEncoded, file.type) + fileUpdated = new File([blob], file.name, { type: file.type, lastModified: new Date().getTime() }) + setLogoImage({ + logoFile: fileUpdated, + imagePreviewUrl: srcEncoded, + fileName: file.name + }) + } + } + } + } + } + + const isEmpty = (object: any): boolean => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars, guard-for-in + for (const property in object) { + setIsImageEmpty(false) + return false + } + setIsImageEmpty(true) + return true + } + + + const handleImageChange = (event: any): void => { + setImgError('') + const reader = new FileReader() + const file = event?.target?.files + + const fieSize = Number((file[0]?.size / 1024 / 1024)?.toFixed(2)) + const extension = file[0]?.name?.substring(file[0]?.name?.lastIndexOf(".") + 1)?.toLowerCase() + if (extension === "png" || extension === "jpeg" || extension === "jpg") { + if (fieSize <= imageSizeAccepted) { + reader.onloadend = (): void => { + ProcessImg(event) + isEmpty(reader.result) + } + reader.readAsDataURL(file[0]) + event.preventDefault() + } else { + setImgError("Please check image size") + } + } else { + setImgError("Invalid image type") + } + } + + const sumitCreateOrganization = async (values: Values) => { + setLoading(true) + + const ecoData = { + name: values.name, + description: values.description, + logo: logoImage?.imagePreviewUrl as string || "", + website: "" + } + + // const resCreateOrg = await createEcosystems(ecoData) + + // const { data } = resCreateOrg as AxiosResponse + // setLoading(false) + + // if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + // props.setMessage(data?.message) + // props.setOpenModal(false) + + // } else { + // setErrMsg(resCreateOrg as string) + // } + } + return ( + { + setLogoImage({ + logoFile: "", + imagePreviewUrl: "", + fileName: '' + }) + setEcoData(initialEcoData) + props.setOpenModal(false) + } + }> + Create Ecosystem + + { + setErrMsg(null) + }} + /> + + ) => { + + sumitCreateOrganization(values) + }} + > + {(formikHandlers): JSX.Element => ( + +
    +
    +
    + { + typeof (logoImage.logoFile) === "string" ? + : + Jese picture + } + +
    +

    + Ecosystem Logo +

    +
    + JPG, JPEG and PNG . Max size of 1MB +
    +
    + +
    + + +
    + +
    +
    +
    +
    +
    +
    +
    + + { + (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && + {formikHandlers?.errors?.name} + } + +
    +
    +
    +
    + + + { + (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && + {formikHandlers?.errors?.description} + } +
    + + +
    + )} + +
    +
    + +
    + ) +} + +export default CreateEcosystems; diff --git a/src/components/Ecosystems/Dashboard.tsx b/src/components/Ecosystems/Dashboard.tsx new file mode 100644 index 000000000..5323d6bdc --- /dev/null +++ b/src/components/Ecosystems/Dashboard.tsx @@ -0,0 +1,63 @@ +'use client'; +import React, { useState } from 'react'; +import BreadCrumbs from '../BreadCrumbs'; +import CreateEcosystems from './CreateEcosystems'; +import { Features } from '../../utils/enums/features'; +import RoleViewButton from '../RoleViewButton'; + + + +const initialPageState = { + pageNumber: 1, + pageSize: 9, + total: 100, +}; + +const Dashboard = () => { + const [openModal, setOpenModal] = useState(false); + const props = { openModal, setOpenModal }; + + const createEcosystemModel = () => { + props.setOpenModal(true) + } + + return ( +
    +
    + + +

    + Ecosystems +

    +
    +
    + +
    + + + + + +
    + } + onClickEvent={createEcosystemModel} + /> + setMessage(data)} + setOpenModal={props.setOpenModal} setMessage={function (message: string): void { + throw new Error('Function not implemented.'); + } } /> +
    +
    +
  • + ) +} + +export default Dashboard; diff --git a/src/config/pathRoutes.ts b/src/config/pathRoutes.ts index 52bb5ae8f..b91c0e3c7 100644 --- a/src/config/pathRoutes.ts +++ b/src/config/pathRoutes.ts @@ -35,14 +35,15 @@ export const pathRoutes = { }, }, - // ecosystems: { - // root: '/ecosystems', - // frameworks: '/ecosystems/frameworks', - // members: '/ecosystems/members', - // registries: '/ecosystems/registries', - // users: '/organizations/users', - // credentials: '/organizations/credentials' - // }, + ecosystems: { + root: '/ecosystems', + dashboard:'/ecosystems/dashboard' + // frameworks: '/ecosystems/frameworks', + // members: '/ecosystems/members', + // registries: '/ecosystems/registries', + // users: '/organizations/users', + // credentials: '/organizations/credentials' + }, documentation: { root: 'https://docs.credebl.id' }, diff --git a/src/pages/ecosystems/index.astro b/src/pages/ecosystems/index.astro new file mode 100644 index 000000000..99be19b97 --- /dev/null +++ b/src/pages/ecosystems/index.astro @@ -0,0 +1,16 @@ +--- +import LayoutSidebar from '../../app/LayoutSidebar.astro'; +import Dashboard from '../../components/Ecosystems/Dashboard'; +import { checkUserSession } from '../../utils/check-session'; +import { pathRoutes } from '../../config/pathRoutes'; +const response = await checkUserSession(Astro.cookies); +const route: string = pathRoutes.auth.sinIn +if (!response) { + return Astro.redirect(route); +} +--- + + + + + \ No newline at end of file From 13942fd06972735dd8ab810a4ac2a96b2039c6a4 Mon Sep 17 00:00:00 2001 From: karan Date: Mon, 2 Oct 2023 11:55:23 +0530 Subject: [PATCH 069/250] feat ecosystem invite Signed-off-by: karan --- src/components/EcosystemInvite/index.tsx | 314 ++++++++++++++++++++++ src/pages/ecosystem/ecosysteminvite.astro | 21 ++ 2 files changed, 335 insertions(+) create mode 100644 src/components/EcosystemInvite/index.tsx create mode 100644 src/pages/ecosystem/ecosysteminvite.astro diff --git a/src/components/EcosystemInvite/index.tsx b/src/components/EcosystemInvite/index.tsx new file mode 100644 index 000000000..bf596926a --- /dev/null +++ b/src/components/EcosystemInvite/index.tsx @@ -0,0 +1,314 @@ +'use client'; + +import { ChangeEvent, useEffect, useState } from 'react'; +import { apiStatusCodes } from '../../config/CommonConstant'; + +import { AlertComponent } from '../AlertComponent'; +import type { AxiosResponse } from 'axios'; +import { EmptyListMessage } from '../EmptyListComponent'; +import { Features } from '../../utils/enums/features'; +import type { Invitation } from '../../components/organization/interfaces/invitations'; +import type { OrgRole } from '../organization/interfaces'; +import { Card, Pagination } from 'flowbite-react'; +import RoleViewButton from '../../components/RoleViewButton'; +import SendInvitationModal from '../../components/organization/invitations/SendInvitationModal'; +import { TextTittlecase } from '../../utils/TextTransform'; +import { getOrganizationInvitations } from '../../api/invitations'; +import CustomSpinner from '../CustomSpinner'; +import { dateConversion } from '../../utils/DateConversion'; +import DateTooltip from '../Tooltip'; +import CustomAvatar from '../Avatar'; +import DataTable from '../../commonComponents/datatable'; + + +const initialPageState = { + pageNumber: 1, + pageSize: 10, + total: 0, +}; + +const header = [ + { columnName: 'Org Name' }, + { columnName: 'Member Since' }, + { columnName: 'Role' }, + { columnName: 'Status' }, + { columnName: 'Action' }, +]; + + +const Invitations = () => { + const [openModal, setOpenModal] = useState(false); + const [loading, setLoading] = useState(false) + const [message, setMessage] = useState(null) + const [error, setError] = useState(null) + const [currentPage, setCurrentPage] = useState(initialPageState); + const [userRoles, setUserRoles] = useState([]) + const timestamp = Date.now(); + + const onPageChange = (page: number) => { + setCurrentPage({ + ...currentPage, + pageNumber: page + }) + }; + const [searchText, setSearchText] = useState(""); + + const [invitationsList, setInvitationsList] = useState | null>(null) + const props = { openModal, setOpenModal }; + + //Fetch the user organization list + // const getAllInvitations = async () => { + // setLoading(true) + + // const response = await getOrganizationInvitations(currentPage.pageNumber, currentPage.pageSize, searchText); + // const { data } = response as AxiosResponse + + // setLoading(false) + + // if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + + // const totalPages = data?.data?.totalPages; + + // const invitationList = data?.data?.invitations + + // setInvitationsList(invitationList) + // setCurrentPage({ + // ...currentPage, + // total: totalPages + // }) + // } + // else { + // setError(response as string) + + // } + // } + + const credentialList = [ { data:[ + { data: "Master Card" }, + { + data: "06/10/2022" + }, + { data: "Lead" }, + { + data: "Pending" + }, + { + data: ":" + }] + }] + + //This useEffect is called when the searchText changes + // useEffect(() => { + + // // let getData: string | number | NodeJS.Timeout | undefined; + // let getData: NodeJS.Timeout + + // if (searchText.length >= 1) { + // getData = setTimeout(() => { + // getAllInvitations() + + // }, 1000) + // } else { + // getAllInvitations() + // } + + // return () => clearTimeout(getData) + // }, [searchText, openModal, currentPage.pageNumber]) + + + //onCHnage of Search input text + const searchInputChange = (e: ChangeEvent) => { + setSearchText(e.target.value); + } + + const createInvitationsModel = () => { + props.setOpenModal(true) + } +let name="Karan tompe" + + return ( +
    +
    + +
    +
    + {/* {org.logoUrl ? ( + + ) : ( */} + + {/* )} */} + +
    +
    +

    Proactive

    +
    +
    +
      +
    • +
      +
      + {/* {org?.description} */} + my org +
      +
      +
    • +
    +
    +
    +
    + + + } + onClickEvent={createInvitationsModel} + /> +
    +
    + setMessage(data)} + setOpenModal={ + props.setOpenModal + } /> + + { + setMessage(null) + setError(null) + }} + /> + + {/* { + loading + ?
    + + +
    + : invitationsList && invitationsList?.length > 0 ? ( +
    */} + + +

    EcoSystem Members

    + +
    + {/* {invitationsList && invitationsList.length > 0 && */} + + {/* } */} +
    +
    + {/*
    ) + : + invitationsList && ( + + } + />) + } */} + +
    + + +
    +
    +
    + + ) +} + +export default Invitations; + + + +{/*
    +
    + +

    + Verification List +

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

    + {proofReqSuccess || errMsg} +

    +
    +
    +
    + )} + {loading ? ( +
    + +
    + ) : verificationList && verificationList.length > 0 ? ( +
    +
    + {verificationList && verificationList.length > 0 && + + } +
    +
    + ) : ( +
    + + There isn't any data available. + +
    + )} + + +
    +
    +
    */} diff --git a/src/pages/ecosystem/ecosysteminvite.astro b/src/pages/ecosystem/ecosysteminvite.astro new file mode 100644 index 000000000..05efc8519 --- /dev/null +++ b/src/pages/ecosystem/ecosysteminvite.astro @@ -0,0 +1,21 @@ +--- +import LayoutSidebar from '../../app/LayoutSidebar.astro'; +// import Invitations from '../../components/organization/invitations/Invitations' +import { checkUserSession } from '../../utils/check-session'; +import { pathRoutes } from '../../config/pathRoutes'; +import Ecosysteminvite from '../../components/EcosystemInvite' + +// const response = await checkUserSession(Astro.cookies); +// const route: string = pathRoutes.auth.sinIn +// if (!response) { +// return Astro.redirect(route); +// } +--- + + + + + + + + From d064653d58bec17479d8a09688bc96c37eda66a4 Mon Sep 17 00:00:00 2001 From: karan Date: Mon, 2 Oct 2023 12:58:48 +0530 Subject: [PATCH 070/250] removed sonar code smell Signed-off-by: karan --- src/components/Resources/Schema/SchemasList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Resources/Schema/SchemasList.tsx b/src/components/Resources/Schema/SchemasList.tsx index f17a6fd55..8d8db0cbc 100644 --- a/src/components/Resources/Schema/SchemasList.tsx +++ b/src/components/Resources/Schema/SchemasList.tsx @@ -127,7 +127,7 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD const fetchOrganizationDetails = async () => { setLoading(true) const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - const response = await getOrganizationById(orgId as string); + const response = await getOrganizationById(orgId); const { data } = response as AxiosResponse if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { if (data?.data?.org_agents && data?.data?.org_agents?.length > 0) { From c005dbea731b151d9bd4d642fc82330a969d7718 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Mon, 2 Oct 2023 23:04:22 +0530 Subject: [PATCH 071/250] feat:edit ecosystem modal Signed-off-by: pranalidhanavade --- src/api/ecosystems.ts | 46 +- .../Ecosystems/CreateEcosystems.tsx | 18 +- src/components/Ecosystems/Dashboard.tsx | 60 ++- .../Ecosystems/EcosystemDashboard.tsx | 247 ++++++++++ src/components/Ecosystems/EditEcosystems.tsx | 431 ++++++++++++++++++ src/components/Ecosystems/interfaces/index.ts | 13 + src/pages/ecosystems/index.astro | 3 +- src/utils/enums/features.ts | 12 +- 8 files changed, 772 insertions(+), 58 deletions(-) create mode 100644 src/components/Ecosystems/EcosystemDashboard.tsx create mode 100644 src/components/Ecosystems/EditEcosystems.tsx create mode 100644 src/components/Ecosystems/interfaces/index.ts diff --git a/src/api/ecosystems.ts b/src/api/ecosystems.ts index e2b73952a..d7b101564 100644 --- a/src/api/ecosystems.ts +++ b/src/api/ecosystems.ts @@ -7,29 +7,29 @@ import { storageKeys } from "../config/CommonConstant"; export const createEcosystems = async (data: object) => { - // const url = apiRoutes.organizations.create - // const payload = data - // const token = await getFromLocalStorage(storageKeys.TOKEN) - - // const config = { - // headers: { - // 'Content-Type': 'application/json', - // Authorization: `Bearer ${token}` - // } - // } - // const axiosPayload = { - // url, - // payload, - // config - // } - - // try { - // return await axiosPost(axiosPayload); - // } - // catch (error) { - // const err = error as Error - // return err?.message - // } + const url = apiRoutes.organizations.create + const payload = data + const token = await getFromLocalStorage(storageKeys.TOKEN) + + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + } + const axiosPayload = { + url, + payload, + config + } + + try { + return await axiosPost(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } } diff --git a/src/components/Ecosystems/CreateEcosystems.tsx b/src/components/Ecosystems/CreateEcosystems.tsx index 1f8c243c0..ec5992efd 100644 --- a/src/components/Ecosystems/CreateEcosystems.tsx +++ b/src/components/Ecosystems/CreateEcosystems.tsx @@ -139,18 +139,18 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str website: "" } - // const resCreateOrg = await createEcosystems(ecoData) + const resCreateOrg = await createEcosystems(ecoData) - // const { data } = resCreateOrg as AxiosResponse - // setLoading(false) + const { data } = resCreateOrg as AxiosResponse + setLoading(false) - // if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { - // props.setMessage(data?.message) - // props.setOpenModal(false) + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + props.setMessage(data?.message) + props.setOpenModal(false) - // } else { - // setErrMsg(resCreateOrg as string) - // } + } else { + setErrMsg(resCreateOrg as string) + } } return ( { diff --git a/src/components/Ecosystems/Dashboard.tsx b/src/components/Ecosystems/Dashboard.tsx index 5323d6bdc..55ec5c1f8 100644 --- a/src/components/Ecosystems/Dashboard.tsx +++ b/src/components/Ecosystems/Dashboard.tsx @@ -4,6 +4,9 @@ import BreadCrumbs from '../BreadCrumbs'; import CreateEcosystems from './CreateEcosystems'; import { Features } from '../../utils/enums/features'; import RoleViewButton from '../RoleViewButton'; +import { EmptyListMessage } from '../EmptyListComponent'; +import { pathRoutes } from '../../config/pathRoutes'; +import EditEcosystems from './EditEcosystems'; @@ -14,17 +17,30 @@ const initialPageState = { }; const Dashboard = () => { - const [openModal, setOpenModal] = useState(false); - const props = { openModal, setOpenModal }; + const [openModal, setOpenModal,] = useState(false); + const [editEcosystemModal, setEditEcosystemModal] = useState(false); + const props = { openModal, setOpenModal, editEcosystemModal, setEditEcosystemModal }; + const createEcosystemModel = () => { props.setOpenModal(true) } - + + const EditEcosystemsModel = () => { + props.setEditEcosystemModal(true); // Open the EditEcosystems modal + }; + return (
    - +

    Ecosystems @@ -32,28 +48,32 @@ const Dashboard = () => {

    - -
    - - - - - -
    - } - onClickEvent={createEcosystemModel} - /> + > +
    + + setMessage(data)} + setOpenModal={props.setEditEcosystemModal} setMessage={function (message: string): void { + throw new Error('Function not implemented.'); + } } EcoData={null} /> + setMessage(data)} setOpenModal={props.setOpenModal} setMessage={function (message: string): void { throw new Error('Function not implemented.'); } } /> + + + + } + onClick={createEcosystemModel} + />
    diff --git a/src/components/Ecosystems/EcosystemDashboard.tsx b/src/components/Ecosystems/EcosystemDashboard.tsx new file mode 100644 index 000000000..ac82fbee9 --- /dev/null +++ b/src/components/Ecosystems/EcosystemDashboard.tsx @@ -0,0 +1,247 @@ +'use client'; + +import { Button, Card, Pagination } from 'flowbite-react'; +import { ChangeEvent, useEffect, useState } from 'react'; +import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; + +import { AlertComponent } from '../AlertComponent'; +import type { AxiosResponse } from 'axios'; +import BreadCrumbs from '../BreadCrumbs'; +import CreateEcosystems from "./CreateEcosystems"; +import CustomAvatar from '../Avatar' +import { Features } from '../../utils/enums/features'; +import type { Ecosystem } from './interfaces' +import RoleViewButton from '../RoleViewButton'; +import SearchInput from '../SearchInput'; +import { getOrganizations } from '../../api/organization'; +import { pathRoutes } from '../../config/pathRoutes'; +import { setToLocalStorage } from '../../api/Auth'; +import { EmptyListMessage } from '../EmptyListComponent'; +import CustomSpinner from '../CustomSpinner'; +import React from 'react'; + +const initialPageState = { + pageNumber: 1, + pageSize: 9, + total: 100, +}; + +const EcosystemDashbaord = () => { + const [openModal, setOpenModal] = useState(false); + const [loading, setLoading] = useState(true) + const [message, setMessage] = useState(null) + const [error, setError] = useState(null) + const [currentPage, setCurrentPage] = useState(initialPageState); + const onPageChange = (page: number) => { + setCurrentPage({ + ...currentPage, + pageNumber: page + }) + }; + const [searchText, setSearchText] = useState(""); + + const [organizationsList, setOrganizationList] = useState | null>(null) + + const props = { openModal, setOpenModal }; + + const createOrganizationModel = () => { + props.setOpenModal(true) + } + + //Fetch the user organization list + const getAllOrganizations = async () => { + + setLoading(true) + const response = await getOrganizations(currentPage.pageNumber, currentPage.pageSize, searchText); + const { data } = response as AxiosResponse + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + + const totalPages = data?.data?.totalPages; + + // const orgList = data?.data?.organizations.map((userOrg: Ecosystem) => { + // const roles: string[] = userOrg.userOrgRoles.map(role => role.orgRole.name) + // userOrg.roles = roles + // return userOrg; + // }) + +// setOrganizationList(orgList) +// setCurrentPage({ +// ...currentPage, +// total: totalPages +// }) +// } +// else{ +// setError(response as string) + +// } +// setLoading(false) + } + + + //This useEffect is called when the searchText changes + useEffect(() => { + + // let getData: string | number | NodeJS.Timeout | undefined; + let getData: NodeJS.Timeout + + if (searchText.length >= 1) { + getData = setTimeout(() => { + getAllOrganizations() + + }, 1000) + } else { + getAllOrganizations() + } + + return () => clearTimeout(getData) + }, [searchText, openModal, currentPage.pageNumber]) + + useEffect(() => { + const queryParameters = new URLSearchParams(window?.location?.search) + const isModel = queryParameters.get("orgModal") || '' + + if (isModel !== '') { + props.setOpenModal(true) + } + + }, []) + + //onCHnage of Search input text + const searchInputChange = (e: ChangeEvent) => { + setSearchText(e.target.value); + } + + const redirectOrgDashboard = async (activeOrg: Ecosystem) => { + + // await setToLocalStorage(storageKeys.ORG_ID, activeOrg.id.toString()); + // const roles: string[] = activeOrg?.userOrgRoles.map(role => role.orgRole.name) + // activeOrg.roles = roles + + // await setToLocalStorage(storageKeys.ORG_ROLES, roles.toString()); + // window.location.href = pathRoutes.organizations.dashboard + } + + + return ( +
    +
    + + +

    + Organizations +

    +
    +
    +
    +
    + + + + + +
    + } + onClickEvent={createOrganizationModel} + /> +
    + + setMessage(data)} + setOpenModal={ + props.setOpenModal + } /> + + { + setMessage(null) + setError(null) + }} + /> + + {loading + ?
    + +
    + : organizationsList && organizationsList?.length > 0 ? (
    + { + organizationsList.map((org) => ( + redirectOrgDashboard(org)} className='transform transition duration-500 hover:scale-105 hover:bg-gray-50 cursor-pointer overflow-hidden overflow-ellipsis' style={{ maxHeight: '100%', maxWidth: '100%', overflow: 'auto' }}> +
    + {(org.logoUrl) ? : } + +
    +
    +

    + {org.name} +

    +
    +
    +
      +
    • +
      +
      + Roles: + {org.roles && + org.roles.length > 0 && + org.roles.map((role: string, index: number) => { + return ( + + {role.charAt(0).toUpperCase() + role.slice(1)} + + ); + })} +
      +
      +
    • +
    +
    +
    +
    +
    + )) + } +
    ) + : organizationsList && ( + + } />) + } + +
    + + {organizationsList && organizationsList?.length > 0 && ( + + ) + } +
    +
    +
    +
    + ) +} +} +export default EcosystemDashbaord; diff --git a/src/components/Ecosystems/EditEcosystems.tsx b/src/components/Ecosystems/EditEcosystems.tsx new file mode 100644 index 000000000..ca57592dd --- /dev/null +++ b/src/components/Ecosystems/EditEcosystems.tsx @@ -0,0 +1,431 @@ +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 { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; +import { useEffect, useState } from "react"; + +import { AlertComponent } from "../AlertComponent"; +import type { AxiosResponse } from 'axios'; +import { updateOrganization } from "../../api/organization"; +import type { Ecosystem } 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 EditEcosystemsModalProps { + openModal: boolean; + setMessage: (message: string) => void; + setOpenModal: (flag: boolean) => void; + onEditSucess?: () => void; + EcoData: Ecosystem | null; + +} + +const EditEcosystemsModal = (props: EditEcosystemsModalProps) => { + const [logoImage, setLogoImage] = useState({ + logoFile: "", + imagePreviewUrl: props?.EcoData?.logoUrl || "", + fileName: '' , + + }) + const [loading, setLoading] = useState(false) + const [isImageEmpty, setIsImageEmpty] = useState(true) + const [isPublic, setIsPublic] = useState(true) + + const [initialOrgData, setOrgData] = useState({ + name: props?.EcoData?.name || "", + description: props?.EcoData?.description || "", + website: props?.EcoData?.website || "", + }) + + useEffect(() => { + + if (props.EcoData) { + setOrgData({ + name: props.EcoData.name || '', + description: props.EcoData.description || '', + website: props?.EcoData?.website || "", + }); + + setLogoImage({ + logoFile: "", + imagePreviewUrl: props.EcoData.logoUrl || "", + fileName: '' + }); + } + }, [props]); + + + const [erroMsg, setErrMsg] = useState(null) + + const [imgError, setImgError] = useState('') + + useEffect(() => { + if (props.openModal === false) { + setOrgData({ + name: '', + description: '', + website:'' + }) + + setLogoImage({ + ...logoImage, + logoFile: "", + imagePreviewUrl: "" + }) + } + }, [props.openModal]) + + + const ProcessImg = (e: any): string | undefined => { + + const file = e?.target.files[0] + if (!file) { return } + + const reader = new FileReader() + reader.readAsDataURL(file) + + reader.onload = (event): void => { + const imgElement = document.createElement("img") + if (imgElement) { + imgElement.src = typeof event?.target?.result === 'string' ? event.target.result : "" + imgElement.onload = (e): void => { + let fileUpdated: File | string = file + let srcEncoded = '' + const canvas = document.createElement("canvas") + + const { width, height, ev } = calculateSize(imgElement, IMG_MAX_WIDTH, IMG_MAX_HEIGHT) + canvas.width = width + canvas.height = height + + const ctx = canvas.getContext("2d") + if (ctx && e?.target) { + ctx.imageSmoothingEnabled = true + ctx.imageSmoothingQuality = "high" + ctx.drawImage(ev, 0, 0, canvas.width, canvas.height) + srcEncoded = ctx.canvas.toDataURL(ev, file.type) + const blob = dataURItoBlob(srcEncoded, file.type) + fileUpdated = new File([blob], file.name, { type: file.type, lastModified: new Date().getTime() }) + setLogoImage({ + logoFile: fileUpdated, + imagePreviewUrl: srcEncoded, + fileName: file.name + }) + } + } + } + } + } + + const isEmpty = (object: any): boolean => { + for (const property in object) { + setIsImageEmpty(false) + return false + } + setIsImageEmpty(true) + return true + } + + + const handleImageChange = (event: any): void => { + setImgError('') + const reader = new FileReader() + const file = event?.target?.files + + const fieSize = Number((file[0]?.size / 1024 / 1024)?.toFixed(2)) + const extension = file[0]?.name?.substring(file[0]?.name?.lastIndexOf(".") + 1)?.toLowerCase() + if (extension === "png" || extension === "jpeg" || extension === "jpg") { + if (fieSize <= imageSizeAccepted) { + reader.onloadend = (): void => { + ProcessImg(event) + isEmpty(reader.result) + } + reader.readAsDataURL(file[0]) + event.preventDefault() + } else { + setImgError("Please check image size") + } + } else { + setImgError("Invalid image type") + } + } + + const submitUpdateOrganization = async (values: Values) => { + + setLoading(true) + + const EcoData = { + orgId: props?.EcoData?.id, + name: values.name, + description: values.description, + logo: logoImage?.imagePreviewUrl as string || props?.EcoData?.logoUrl, + website: values.website, + isPublic: isPublic + } + + const resUpdateOrg = await updateOrganization(EcoData, EcoData.orgId?.toString() as string) + + const { data } = resUpdateOrg as AxiosResponse + setLoading(false) + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + if (props?.onEditSucess) { + props?.onEditSucess() + } + props.setOpenModal(false) + } else { + setErrMsg(resUpdateOrg as string) + } + } + + return ( + { + setLogoImage({ + logoFile: "", + imagePreviewUrl: "", + fileName: '' + }) + setOrgData(initialOrgData) + props.setOpenModal(false) + } + }> + Edit Ecosystem + + { + setErrMsg(null) + }} + /> + + ) => { + submitUpdateOrganization(values) + }} + > + {(formikHandlers): JSX.Element => ( + +
    +
    +
    + + + { + (typeof (logoImage.logoFile) === "string" && props?.EcoData?.logoUrl) ? + Jese picture + : typeof (logoImage.logoFile) === "string" ? + : + Jese picture + } + + +
    +

    + Ecosystem Logo +

    +
    + JPG, JPEG and PNG . Max size of 1MB +
    +
    + +
    + + +
    + +
    +
    +
    +
    +
    +
    +
    + + { + (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && + {formikHandlers?.errors?.name} + } + +
    + + +
    +
    +
    + + + { + (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && + {formikHandlers?.errors?.description} + } +
    +
    + {/*
    +
    */} + {/* */} + +
    + {/*
    + +
    +
    +
    + setIsPublic(false)} + id="private" + name="private" + /> + Private + Only the connected organization can see you organization details + +
    +
    +
    +
    + setIsPublic(true)} + checked={isPublic === true} + id="public" + name="public" + /> + + Public + Your profile and organization details can be seen by everyone +
    +
    */} + + +
    + )} + +
    +
    + +
    + ) +} + +export default EditEcosystemsModal; diff --git a/src/components/Ecosystems/interfaces/index.ts b/src/components/Ecosystems/interfaces/index.ts new file mode 100644 index 000000000..b968799a9 --- /dev/null +++ b/src/components/Ecosystems/interfaces/index.ts @@ -0,0 +1,13 @@ +export interface Ecosystem { + id: number + createDateTime: string + createdBy: number + lastChangedDateTime: string + lastChangedBy: number + name: string + description: string + logoUrl: string + website: string + roles: string[] + +} \ No newline at end of file diff --git a/src/pages/ecosystems/index.astro b/src/pages/ecosystems/index.astro index 99be19b97..dc759a44e 100644 --- a/src/pages/ecosystems/index.astro +++ b/src/pages/ecosystems/index.astro @@ -3,6 +3,7 @@ import LayoutSidebar from '../../app/LayoutSidebar.astro'; import Dashboard from '../../components/Ecosystems/Dashboard'; import { checkUserSession } from '../../utils/check-session'; import { pathRoutes } from '../../config/pathRoutes'; +import EcosystemDashbaord from '../../components/Ecosystems/EcosystemDashboard'; const response = await checkUserSession(Astro.cookies); const route: string = pathRoutes.auth.sinIn if (!response) { @@ -12,5 +13,5 @@ if (!response) { - + \ No newline at end of file diff --git a/src/utils/enums/features.ts b/src/utils/enums/features.ts index cc574a15e..6347715de 100644 --- a/src/utils/enums/features.ts +++ b/src/utils/enums/features.ts @@ -1,9 +1,11 @@ + export enum Features { - SEND_INVITATION = 'send_invitations', - CRETAE_ORG = 'create_org', - CRETAE_SCHEMA = 'create_schema', - ISSUENCE = 'issuence', - VERIFICATION = 'verification' + SEND_INVITATION = 'send_invitations', + CRETAE_ORG = 'create_org', + CRETAE_SCHEMA = 'create_schema', + ISSUENCE = 'issuence', + VERIFICATION = 'verification', + CREATE_ECOSYSTEMS = "CREATE_ECOSYSTEMS" } \ No newline at end of file From a91a972df620db1f043cba742ebca330a2fd2277 Mon Sep 17 00:00:00 2001 From: karan Date: Tue, 3 Oct 2023 13:12:13 +0530 Subject: [PATCH 072/250] added edit button Signed-off-by: karan --- src/components/EcosystemInvite/index.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/EcosystemInvite/index.tsx b/src/components/EcosystemInvite/index.tsx index bf596926a..55107a371 100644 --- a/src/components/EcosystemInvite/index.tsx +++ b/src/components/EcosystemInvite/index.tsx @@ -158,6 +158,7 @@ let name="Karan tompe"
    +
    } onClickEvent={createInvitationsModel} - /> + /> + +
    Date: Tue, 3 Oct 2023 15:52:51 +0530 Subject: [PATCH 073/250] added scroll and dark mode Signed-off-by: karan --- src/components/Verification/ProofRequestPopup.tsx | 2 +- src/components/Verification/SchemaCredDefDetails.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Verification/ProofRequestPopup.tsx b/src/components/Verification/ProofRequestPopup.tsx index 8ed725d20..f2561a07b 100644 --- a/src/components/Verification/ProofRequestPopup.tsx +++ b/src/components/Verification/ProofRequestPopup.tsx @@ -91,7 +91,7 @@ const ProofRequest = (props: { Close modal
    -

    +

    {' '} Verification Details

    diff --git a/src/components/Verification/SchemaCredDefDetails.tsx b/src/components/Verification/SchemaCredDefDetails.tsx index 939be9fe9..a945660a6 100644 --- a/src/components/Verification/SchemaCredDefDetails.tsx +++ b/src/components/Verification/SchemaCredDefDetails.tsx @@ -15,7 +15,7 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { Schema Id
    :
    {' '} -
    {Object.values(item)[2]}
    @@ -29,7 +29,7 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { {' '} :
    {' '} -
    +
    {Object.values(item)[1] ? Object.values(item)[1] : ''} From 7a48babfdc800fda8f94c9d2e3603b28375f6527 Mon Sep 17 00:00:00 2001 From: karan Date: Tue, 3 Oct 2023 16:17:11 +0530 Subject: [PATCH 074/250] removed unwanted code Signed-off-by: karan --- src/components/Verification/SchemaCredDefDetails.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Verification/SchemaCredDefDetails.tsx b/src/components/Verification/SchemaCredDefDetails.tsx index a945660a6..d1cf1b9d2 100644 --- a/src/components/Verification/SchemaCredDefDetails.tsx +++ b/src/components/Verification/SchemaCredDefDetails.tsx @@ -8,15 +8,15 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { return ( <> {schemaCredDefList.map((item) => ( -
    +
    Schema Id
    :
    {' '} -
    +
    {Object.values(item)[2]}
    @@ -29,7 +29,7 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { {' '} :
    {' '} -
    +
    {Object.values(item)[1] ? Object.values(item)[1] : ''} From bad553fb2f7015207daf6054e57bbdc4d15f0e6d Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Tue, 3 Oct 2023 16:20:54 +0530 Subject: [PATCH 075/250] refactor:create ecosystem api Signed-off-by: pranalidhanavade --- src/api/ecosystems.ts | 2 +- .../Ecosystems/CreateEcosystems.tsx | 25 +++++++++++++------ src/config/apiRoutes.ts | 6 ++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/api/ecosystems.ts b/src/api/ecosystems.ts index d7b101564..c9944b326 100644 --- a/src/api/ecosystems.ts +++ b/src/api/ecosystems.ts @@ -7,7 +7,7 @@ import { storageKeys } from "../config/CommonConstant"; export const createEcosystems = async (data: object) => { - const url = apiRoutes.organizations.create + const url = apiRoutes.ecosystem.create const payload = data const token = await getFromLocalStorage(storageKeys.TOKEN) diff --git a/src/components/Ecosystems/CreateEcosystems.tsx b/src/components/Ecosystems/CreateEcosystems.tsx index ec5992efd..3e2f3190f 100644 --- a/src/components/Ecosystems/CreateEcosystems.tsx +++ b/src/components/Ecosystems/CreateEcosystems.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 } from '../../config/CommonConstant' +import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted, storageKeys } from '../../config/CommonConstant' import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; import { useEffect, useRef, useState } from "react"; @@ -11,10 +11,12 @@ import type { AxiosResponse } from 'axios'; import { asset } from '../../lib/data.js'; import { createEcosystems } from "../../api/ecosystems"; import React from "react"; +import { getFromLocalStorage } from "../../api/Auth"; interface Values { name: string; description: string; + } interface ILogoImage { @@ -129,16 +131,19 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str } } - const sumitCreateOrganization = async (values: Values) => { + const submitCreateEcosystem = async (values: Values) => { +try{ setLoading(true) - + const user_data = JSON.parse(await getFromLocalStorage(storageKeys.USER_PROFILE)) + const organizationId = await getFromLocalStorage(storageKeys.ORG_ID); const ecoData = { name: values.name, description: values.description, - logo: logoImage?.imagePreviewUrl as string || "", - website: "" + tag:"", + orgId: Number(organizationId), + userId:Number(user_data?.id) } - + const resCreateOrg = await createEcosystems(ecoData) const { data } = resCreateOrg as AxiosResponse @@ -152,6 +157,12 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str setErrMsg(resCreateOrg as string) } } + catch (error) + { + console.error("An error occurred:", error); + setLoading(false); + } +} return ( { setLogoImage({ @@ -196,7 +207,7 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str { resetForm }: FormikHelpers ) => { - sumitCreateOrganization(values) + submitCreateEcosystem(values) }} > {(formikHandlers): JSX.Element => ( diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index a1d650476..800c0bb5c 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -26,6 +26,7 @@ export const apiRoutes = { orgRoles: '/orgs/roles', editUserROle: '/user-roles' }, + connection: { create: '/connections', }, @@ -69,5 +70,8 @@ export const apiRoutes = { public:{ organizations: '/organization/public-profiles', users:'/users/public-profiles', - } + }, + ecosystem:{ + create:'/ecosystem' + } } From 2ead2ebf45369abd9fbbb8aea3fa5f90bc015ca5 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Tue, 3 Oct 2023 19:18:21 +0530 Subject: [PATCH 076/250] refactor:create and edit ecosystem api Signed-off-by: pranalidhanavade --- src/api/ecosystems.ts | 26 ++ .../Ecosystems/CreateEcosystems.tsx | 8 +- src/components/Ecosystems/Dashboard.tsx | 94 +++---- .../Ecosystems/EcosystemDashboard.tsx | 247 ------------------ src/components/Ecosystems/EditEcosystems.tsx | 84 +----- .../organization/CreateOrgFormModal.tsx | 2 +- src/pages/ecosystems/index.astro | 3 +- 7 files changed, 91 insertions(+), 373 deletions(-) delete mode 100644 src/components/Ecosystems/EcosystemDashboard.tsx diff --git a/src/api/ecosystems.ts b/src/api/ecosystems.ts index c9944b326..d26382d04 100644 --- a/src/api/ecosystems.ts +++ b/src/api/ecosystems.ts @@ -32,6 +32,32 @@ export const createEcosystems = async (data: object) => { } } +export const updateEcosystem = async (data: object, orgId:string) => { + + const url = `${apiRoutes.organizations.update}/${orgId}` + const payload = data + const token = await getFromLocalStorage(storageKeys.TOKEN) + + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + } + const axiosPayload = { + url, + payload, + config + } + + try { + return await axiosPut(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} diff --git a/src/components/Ecosystems/CreateEcosystems.tsx b/src/components/Ecosystems/CreateEcosystems.tsx index 3e2f3190f..aa9f1ed2b 100644 --- a/src/components/Ecosystems/CreateEcosystems.tsx +++ b/src/components/Ecosystems/CreateEcosystems.tsx @@ -16,7 +16,6 @@ import { getFromLocalStorage } from "../../api/Auth"; interface Values { name: string; description: string; - } interface ILogoImage { @@ -139,11 +138,11 @@ try{ const ecoData = { name: values.name, description: values.description, + logo: logoImage?.imagePreviewUrl as string || "", tag:"", orgId: Number(organizationId), userId:Number(user_data?.id) } - const resCreateOrg = await createEcosystems(ecoData) const { data } = resCreateOrg as AxiosResponse @@ -243,11 +242,11 @@ try{
    -
    - ) -} -} -export default EcosystemDashbaord; diff --git a/src/components/Ecosystems/EditEcosystems.tsx b/src/components/Ecosystems/EditEcosystems.tsx index ca57592dd..d55bb1226 100644 --- a/src/components/Ecosystems/EditEcosystems.tsx +++ b/src/components/Ecosystems/EditEcosystems.tsx @@ -8,7 +8,7 @@ import { useEffect, useState } from "react"; import { AlertComponent } from "../AlertComponent"; import type { AxiosResponse } from 'axios'; -import { updateOrganization } from "../../api/organization"; +import { updateEcosystem } from "../../api/ecosystems"; import type { Ecosystem } from "./interfaces"; import React from "react"; @@ -44,7 +44,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => { const [isImageEmpty, setIsImageEmpty] = useState(true) const [isPublic, setIsPublic] = useState(true) - const [initialOrgData, setOrgData] = useState({ + const [initialEcoData, setEcoData] = useState({ name: props?.EcoData?.name || "", description: props?.EcoData?.description || "", website: props?.EcoData?.website || "", @@ -53,7 +53,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => { useEffect(() => { if (props.EcoData) { - setOrgData({ + setEcoData({ name: props.EcoData.name || '', description: props.EcoData.description || '', website: props?.EcoData?.website || "", @@ -74,7 +74,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => { useEffect(() => { if (props.openModal === false) { - setOrgData({ + setEcoData({ name: '', description: '', website:'' @@ -162,7 +162,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => { } } - const submitUpdateOrganization = async (values: Values) => { + const submitUpdateEcosystem = async (values: Values) => { setLoading(true) @@ -175,7 +175,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => { isPublic: isPublic } - const resUpdateOrg = await updateOrganization(EcoData, EcoData.orgId?.toString() as string) + const resUpdateOrg = await updateEcosystem(EcoData, EcoData.orgId?.toString() as string) const { data } = resUpdateOrg as AxiosResponse setLoading(false) @@ -197,7 +197,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => { imagePreviewUrl: "", fileName: '' }) - setOrgData(initialOrgData) + setEcoData(initialEcoData) props.setOpenModal(false) } }> @@ -212,7 +212,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => { /> { values: Values, { resetForm }: FormikHelpers ) => { - submitUpdateOrganization(values) + submitUpdateEcosystem(values) }} > {(formikHandlers): JSX.Element => ( @@ -280,11 +280,11 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
    -
    - {/*
    -
    */} - {/* */} +
    - {/*
    - -
    -
    -
    - setIsPublic(false)} - id="private" - name="private" - /> - Private - Only the connected organization can see you organization details - -
    -
    -
    -
    - setIsPublic(true)} - checked={isPublic === true} - id="public" - name="public" - /> - - Public - Your profile and organization details can be seen by everyone -
    -
    */} )} - diff --git a/src/components/organization/CreateOrgFormModal.tsx b/src/components/organization/CreateOrgFormModal.tsx index 2d57380b9..d2d74da56 100644 --- a/src/components/organization/CreateOrgFormModal.tsx +++ b/src/components/organization/CreateOrgFormModal.tsx @@ -10,6 +10,7 @@ import { AlertComponent } from "../AlertComponent"; import type { AxiosResponse } from 'axios'; import { asset } from '../../lib/data.js'; import { createOrganization } from "../../api/organization"; +import React from "react"; interface Values { name: string; @@ -138,7 +139,6 @@ const CreateOrgFormModal = (props: { openModal: boolean; setMessage: (message: s logo: logoImage?.imagePreviewUrl as string || "", website: "" } - const resCreateOrg = await createOrganization(orgData) const { data } = resCreateOrg as AxiosResponse diff --git a/src/pages/ecosystems/index.astro b/src/pages/ecosystems/index.astro index dc759a44e..bb9899381 100644 --- a/src/pages/ecosystems/index.astro +++ b/src/pages/ecosystems/index.astro @@ -3,7 +3,7 @@ import LayoutSidebar from '../../app/LayoutSidebar.astro'; import Dashboard from '../../components/Ecosystems/Dashboard'; import { checkUserSession } from '../../utils/check-session'; import { pathRoutes } from '../../config/pathRoutes'; -import EcosystemDashbaord from '../../components/Ecosystems/EcosystemDashboard'; + const response = await checkUserSession(Astro.cookies); const route: string = pathRoutes.auth.sinIn if (!response) { @@ -13,5 +13,4 @@ if (!response) { - \ No newline at end of file From 6051e4376c621dd093a3bb00c9b80f1c4b7d0660 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Tue, 3 Oct 2023 19:34:51 +0530 Subject: [PATCH 077/250] refactor:changes in payload Signed-off-by: pranalidhanavade --- src/components/Ecosystems/CreateEcosystems.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Ecosystems/CreateEcosystems.tsx b/src/components/Ecosystems/CreateEcosystems.tsx index aa9f1ed2b..2ebee1ec3 100644 --- a/src/components/Ecosystems/CreateEcosystems.tsx +++ b/src/components/Ecosystems/CreateEcosystems.tsx @@ -139,7 +139,7 @@ try{ name: values.name, description: values.description, logo: logoImage?.imagePreviewUrl as string || "", - tag:"", + tags:"", orgId: Number(organizationId), userId:Number(user_data?.id) } From b224c9a48ac510fa25aa7cc7136d01e8c3265abf Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 11:45:53 +0530 Subject: [PATCH 078/250] fix:sonarcloud issue Signed-off-by: pranalidhanavade --- .../Ecosystems/CreateEcosystems.tsx | 119 +++++++++--------- 1 file changed, 58 insertions(+), 61 deletions(-) diff --git a/src/components/Ecosystems/CreateEcosystems.tsx b/src/components/Ecosystems/CreateEcosystems.tsx index 2ebee1ec3..de23594b1 100644 --- a/src/components/Ecosystems/CreateEcosystems.tsx +++ b/src/components/Ecosystems/CreateEcosystems.tsx @@ -5,28 +5,26 @@ import { Field, Form, Formik, FormikHelpers } from 'formik'; import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted, storageKeys } from '../../config/CommonConstant' import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; import { useEffect, useRef, useState } from "react"; - import { AlertComponent } from "../AlertComponent"; import type { AxiosResponse } from 'axios'; import { asset } from '../../lib/data.js'; import { createEcosystems } from "../../api/ecosystems"; -import React from "react"; import { getFromLocalStorage } from "../../api/Auth"; -interface Values { +interface EcoValues { name: string; description: string; } -interface ILogoImage { +interface LogoImage { logoFile: string | File imagePreviewUrl: string | ArrayBuffer | null | File, fileName: string } -const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: string)=> void ; setOpenModal: (flag: boolean) => void }) => { +const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: string) => void; setOpenModal: (flag: boolean) => void }) => { - const [logoImage, setLogoImage] = useState({ + const [ecologoImage, setEcoLogoImage] = useState({ logoFile: "", imagePreviewUrl: "", fileName: '' @@ -34,25 +32,25 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str const [loading, setLoading] = useState(false) - const [isImageEmpty, setIsImageEmpty] = useState(true) + const [islogoImageEmpty, setIsLogoImageEmpty] = useState(true) const [initialEcoData, setEcoData] = useState({ name: '', description: '', }) - const [erroMsg, setErrMsg] = useState(null) + const [errorMsg, setErrorMsg] = useState(null) - const [imgError, setImgError] = useState('') + const [imageError, setImageError] = useState('') useEffect(() => { setEcoData({ name: '', description: '', }) - setLogoImage({ - ...logoImage, + setEcoLogoImage({ + ...ecologoImage, logoFile: "", imagePreviewUrl: "" - }) + }) }, [props.openModal]) @@ -85,7 +83,7 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str srcEncoded = ctx.canvas.toDataURL(ev, file.type) const blob = dataURItoBlob(srcEncoded, file.type) fileUpdated = new File([blob], file.name, { type: file.type, lastModified: new Date().getTime() }) - setLogoImage({ + setEcoLogoImage({ logoFile: fileUpdated, imagePreviewUrl: srcEncoded, fileName: file.name @@ -99,16 +97,16 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str const isEmpty = (object: any): boolean => { // eslint-disable-next-line @typescript-eslint/no-unused-vars, guard-for-in for (const property in object) { - setIsImageEmpty(false) + setIsLogoImageEmpty(false) return false } - setIsImageEmpty(true) + setIsLogoImageEmpty(true) return true } const handleImageChange = (event: any): void => { - setImgError('') + setImageError('') const reader = new FileReader() const file = event?.target?.files @@ -123,48 +121,47 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str reader.readAsDataURL(file[0]) event.preventDefault() } else { - setImgError("Please check image size") + setImageError("Please check image size") } } else { - setImgError("Invalid image type") + setImageError("Invalid image type") } } - const submitCreateEcosystem = async (values: Values) => { -try{ - setLoading(true) - const user_data = JSON.parse(await getFromLocalStorage(storageKeys.USER_PROFILE)) - const organizationId = await getFromLocalStorage(storageKeys.ORG_ID); - const ecoData = { - name: values.name, - description: values.description, - logo: logoImage?.imagePreviewUrl as string || "", - tags:"", - orgId: Number(organizationId), - userId:Number(user_data?.id) - } - const resCreateOrg = await createEcosystems(ecoData) + const submitCreateEcosystem = async (values: EcoValues) => { + try { + setLoading(true) + const user_data = JSON.parse(await getFromLocalStorage(storageKeys.USER_PROFILE)) + const organizationId = await getFromLocalStorage(storageKeys.ORG_ID); + const ecoData = { + name: values.name, + description: values.description, + logo: ecologoImage?.imagePreviewUrl as string || "", + tags: "", + orgId: Number(organizationId), + userId: Number(user_data?.id) + } + const resCreateOrg = await createEcosystems(ecoData) - const { data } = resCreateOrg as AxiosResponse - setLoading(false) + const { data } = resCreateOrg as AxiosResponse + setLoading(false) - if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { - props.setMessage(data?.message) - props.setOpenModal(false) + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + props.setMessage(data?.message) + props.setOpenModal(false) - } else { - setErrMsg(resCreateOrg as string) + } else { + setErrorMsg(resCreateOrg as string) + } + } + catch (error) { + console.error("An error occurred:", error); + setLoading(false); } } - catch (error) - { - console.error("An error occurred:", error); - setLoading(false); - } -} return ( { - setLogoImage({ + setEcoLogoImage({ logoFile: "", imagePreviewUrl: "", fileName: '' @@ -175,13 +172,13 @@ try{ }> Create Ecosystem - { - setErrMsg(null) + onAlertClose={() => { + setErrorMsg(null) }} - /> + /> + values: EcoValues, + { resetForm }: FormikHelpers ) => { submitCreateEcosystem(values) @@ -221,13 +218,13 @@ try{ className="items-center sm:flex 2xl:flex sm:space-x-4 xl:space-x-4 2xl:space-x-4" > { - typeof (logoImage.logoFile) === "string" ? + typeof (ecologoImage.logoFile) === "string" ? : Jese picture } @@ -249,7 +246,7 @@ try{ id="ecosystemlogo" title="" onChange={(event): void => handleImageChange(event)} /> {/* {selectedImage || 'No File Chosen'} */} - {imgError ?
    {imgError}
    : {logoImage.fileName || 'No File Chosen'}} + {imageError ?
    {imageError}
    : {ecologoImage.fileName || 'No File Chosen'}}
    @@ -308,13 +305,13 @@ try{ From 51fdabe7108e7c199f684d427d2e7bbac95f71df Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 12:07:48 +0530 Subject: [PATCH 079/250] fix:sonarcloud bugs and issues Signed-off-by: pranalidhanavade --- src/api/ecosystems.ts | 4 +--- src/components/Ecosystems/CreateEcosystems.tsx | 6 +++--- src/components/Ecosystems/Dashboard.tsx | 12 +++--------- src/components/Ecosystems/EditEcosystems.tsx | 15 ++++++--------- .../organization/CreateOrgFormModal.tsx | 9 ++++----- 5 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/api/ecosystems.ts b/src/api/ecosystems.ts index d26382d04..069f339f2 100644 --- a/src/api/ecosystems.ts +++ b/src/api/ecosystems.ts @@ -1,8 +1,6 @@ -import { axiosGet, axiosPost, axiosPut } from "../services/apiRequests" - +import { axiosPost, axiosPut } from "../services/apiRequests" import { apiRoutes } from "../config/apiRoutes"; import { getFromLocalStorage } from "./Auth"; -import { getHeaderConfigs } from "../config/GetHeaderConfigs"; import { storageKeys } from "../config/CommonConstant"; export const createEcosystems = async (data: object) => { diff --git a/src/components/Ecosystems/CreateEcosystems.tsx b/src/components/Ecosystems/CreateEcosystems.tsx index de23594b1..bddfbf60d 100644 --- a/src/components/Ecosystems/CreateEcosystems.tsx +++ b/src/components/Ecosystems/CreateEcosystems.tsx @@ -40,7 +40,7 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str const [errorMsg, setErrorMsg] = useState(null) const [imageError, setImageError] = useState('') - +const newEcoData = initialEcoData useEffect(() => { setEcoData({ name: '', @@ -166,7 +166,7 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str imagePreviewUrl: "", fileName: '' }) - setEcoData(initialEcoData) + setEcoData(newEcoData) props.setOpenModal(false) } }> @@ -180,7 +180,7 @@ const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: str }} /> { } const EditEcosystemsModel = () => { - props.setEditEcosystemModal(true); // Open the EditEcosystems modal + props.setEditEcosystemModal(true); }; return (
    -
    diff --git a/src/components/Ecosystems/Dashboard.tsx b/src/components/Ecosystems/Dashboard.tsx index 63daf41a3..3bf73a980 100644 --- a/src/components/Ecosystems/Dashboard.tsx +++ b/src/components/Ecosystems/Dashboard.tsx @@ -4,6 +4,8 @@ import BreadCrumbs from '../BreadCrumbs'; import CreateEcosystems from './CreateEcosystems'; import { EmptyListMessage } from '../EmptyListComponent'; import EditEcosystems from './EditEcosystems'; +import PopupModal from '../PopupModal'; +import React from 'react'; @@ -30,14 +32,6 @@ const Dashboard = () => { return (
    -

    Ecosystems @@ -48,17 +42,12 @@ const Dashboard = () => { >
    - - - void ; setOpenModal: (flag: boolean) => void }) => { +console.log("cbcb") + const [logoImage, setLogoImage] = useState({ + logoFile: "", + imagePreviewUrl: "", + fileName: '' + }) + + const [loading, setLoading] = useState(false) + + const [isImageEmpty, setIsImageEmpty] = useState(true) + const [initialOrgData, setOrgData] = useState({ + name: '', + description: '', + }) + const [erroMsg, setErrMsg] = useState(null) + + const [imgError, setImgError] = useState('') + + useEffect(() => { + setOrgData({ + name: '', + description: '', + }) + setLogoImage({ + ...logoImage, + logoFile: "", + imagePreviewUrl: "" + }) + }, [props.openModal]) + + + const ProcessImg = (e: any): string | undefined => { + + const file = e?.target.files[0] + if (!file) { return } + + const reader = new FileReader() + reader.readAsDataURL(file) + + reader.onload = (event): void => { + const imgElement = document.createElement("img") + if (imgElement) { + imgElement.src = typeof event?.target?.result === 'string' ? event.target.result : "" + imgElement.onload = (e): void => { + let fileUpdated: File | string = file + let srcEncoded = '' + const canvas = document.createElement("canvas") + + const { width, height, ev } = calculateSize(imgElement, IMG_MAX_WIDTH, IMG_MAX_HEIGHT) + canvas.width = width + canvas.height = height + + const ctx = canvas.getContext("2d") + if (ctx && e?.target) { + ctx.imageSmoothingEnabled = true + ctx.imageSmoothingQuality = "high" + ctx.drawImage(ev, 0, 0, canvas.width, canvas.height) + srcEncoded = ctx.canvas.toDataURL(ev, file.type) + const blob = dataURItoBlob(srcEncoded, file.type) + fileUpdated = new File([blob], file.name, { type: file.type, lastModified: new Date().getTime() }) + setLogoImage({ + logoFile: fileUpdated, + imagePreviewUrl: srcEncoded, + fileName: file.name + }) + } + } + } + } + } + + const isEmpty = (object: any): boolean => { + + for (const property in object) { + setIsImageEmpty(false) + return false + } + setIsImageEmpty(true) + return true + } + + + const handleImageChange = (event: any): void => { + setImgError('') + const reader = new FileReader() + const file = event?.target?.files + + const fieSize = Number((file[0]?.size / 1024 / 1024)?.toFixed(2)) + const extension = file[0]?.name?.substring(file[0]?.name?.lastIndexOf(".") + 1)?.toLowerCase() + if (extension === "png" || extension === "jpeg" || extension === "jpg") { + if (fieSize <= imageSizeAccepted) { + reader.onloadend = (): void => { + ProcessImg(event) + isEmpty(reader.result) + } + reader.readAsDataURL(file[0]) + event.preventDefault() + } else { + setImgError("Please check image size") + } + } else { + setImgError("Invalid image type") + } + } + + const sumitCreateOrganization = async (values: Values) => { + setLoading(true) + + const orgData = { + name: values.name, + description: values.description, + logo: logoImage?.imagePreviewUrl as string || "", + website: "" + } + const resCreateOrg = await createOrganization(orgData) + + const { data } = resCreateOrg as AxiosResponse + setLoading(false) + + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + props.setMessage(data?.message) + props.setOpenModal(false) + + } else { + setErrMsg(resCreateOrg as string) + } + } + const submitCreateEcosystem = async (values: EcoValues) => { + try { + setLoading(true) + const user_data = JSON.parse(await getFromLocalStorage(storageKeys.USER_PROFILE)) + const organizationId = await getFromLocalStorage(storageKeys.ORG_ID); + const ecoData = { + name: values.name, + description: values.description, + logo: logoImage?.imagePreviewUrl as string || "", + tags: "", + orgId: Number(organizationId), + userId: Number(user_data?.id) + } + const resCreateEco = await createEcosystems(ecoData) + + const { data } = resCreateEco as AxiosResponse + setLoading(false) + + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + props.setMessage(data?.message) + props.setOpenModal(false) + + } else { + setErrMsg(resCreateEco as string) + } + } + catch (error) { + console.error("An error occurred:", error); + setLoading(false); + } + } + const renderEcosystemModal = () =>{ + return( + { + setLogoImage({ + logoFile: "", + imagePreviewUrl: "", + fileName: '' + }) + setOrgData(initialOrgData) + props.setOpenModal(false) + } + }> + Create Ecosystem + + { + setErrMsg(null) + }} + /> + + ) => { + + submitCreateEcosystem(values) + + }} + > + {(formikHandlers): JSX.Element => ( + +
    +
    +
    + { + typeof (logoImage.logoFile) === "string" ? + : + Jese picture + } + +
    +

    + Ecosystem Logo +

    +
    + JPG, JPEG and PNG . Max size of 1MB +
    +
    + +
    + + +
    + +
    +
    +
    +
    +
    +
    +
    + + { + (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && + {formikHandlers?.errors?.name} + } + +
    +
    +
    +
    + + + { + (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && + {formikHandlers?.errors?.description} + } +
    + + +
    + )} + +
    +
    + +
    + ) + } + + const renderOrgFormModal = () =>{ + return( + { + setLogoImage({ + logoFile: "", + imagePreviewUrl: "", + fileName: '' + }) + setOrgData(initialOrgData) + props.setOpenModal(false) + } + }> + Create Organizationbcvbccvbv + + { + setErrMsg(null) + }} + /> + + ) => { + + sumitCreateOrganization(values) + + }} + > + {(formikHandlers): JSX.Element => ( + +
    +
    +
    + { + typeof (logoImage.logoFile) === "string" ? + : + Jese picture + } + +
    +

    + Organization Logo +

    +
    + JPG, JPEG and PNG . Max size of 1MB +
    +
    + +
    + + +
    + +
    +
    +
    +
    +
    +
    +
    + + { + (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && + {formikHandlers?.errors?.name} + } + +
    +
    +
    +
    + + + { + (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && + {formikHandlers?.errors?.description} + } +
    + + +
    + )} + +
    +
    + +
    + ) + } + return ( + <> + {props?.isorgModal ? renderOrgFormModal() : renderEcosystemModal()} + + + ) + +} + +export default PopupModal; diff --git a/src/components/organization/OrganizationsList.tsx b/src/components/organization/OrganizationsList.tsx index 88f49df5a..263745c35 100644 --- a/src/components/organization/OrganizationsList.tsx +++ b/src/components/organization/OrganizationsList.tsx @@ -19,6 +19,7 @@ import { setToLocalStorage } from '../../api/Auth'; import { EmptyListMessage } from '../EmptyListComponent'; import CustomSpinner from '../CustomSpinner'; import React from 'react'; +import PopupModal from '../PopupModal'; const initialPageState = { pageNumber: 1, @@ -154,12 +155,13 @@ const OrganizationsList = () => { />
    - setMessage(data)} setOpenModal={ props.setOpenModal - } /> + } + isorgModal={true} /> Date: Wed, 4 Oct 2023 17:29:34 +0530 Subject: [PATCH 085/250] refactor:removed unneccessary components Signed-off-by: pranalidhanavade --- .../Ecosystems/CreateEcosystems.tsx | 326 ---------------- src/components/Ecosystems/EditEcosystems.tsx | 368 ------------------ .../organization/CreateOrgFormModal.tsx | 321 --------------- 3 files changed, 1015 deletions(-) delete mode 100644 src/components/Ecosystems/CreateEcosystems.tsx delete mode 100644 src/components/Ecosystems/EditEcosystems.tsx delete mode 100644 src/components/organization/CreateOrgFormModal.tsx diff --git a/src/components/Ecosystems/CreateEcosystems.tsx b/src/components/Ecosystems/CreateEcosystems.tsx deleted file mode 100644 index 1c5f11e58..000000000 --- a/src/components/Ecosystems/CreateEcosystems.tsx +++ /dev/null @@ -1,326 +0,0 @@ -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 { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; -import { useEffect, useRef, useState } from "react"; -import { AlertComponent } from "../AlertComponent"; -import type { AxiosResponse } from 'axios'; -import { asset } from '../../lib/data.js'; -import { createEcosystems } from "../../api/ecosystems"; -import { getFromLocalStorage } from "../../api/Auth"; - -interface EcoValues { - name: string; - description: string; -} - -interface LogoImage { - logoFile: string | File - imagePreviewUrl: string | ArrayBuffer | null | File, - fileName: string -} - -const CreateEcosystems = (props: { openModal: boolean; setMessage: (message: string) => void; setOpenModal: (flag: boolean) => void }) => { - - const [ecologoImage, setEcoLogoImage] = useState({ - logoFile: "", - imagePreviewUrl: "", - fileName: '' - }) - - const [loading, setLoading] = useState(false) - - const [islogoImageEmpty, setIsLogoImageEmpty] = useState(true) - const [initialEcoData, setEcoData] = useState({ - name: '', - description: '', - }) - const [errorMsg, setErrorMsg] = useState(null) - - const [imageError, setImageError] = useState('') - const newEcoData = initialEcoData - useEffect(() => { - setEcoData({ - name: '', - description: '', - }) - setEcoLogoImage({ - ...ecologoImage, - logoFile: "", - imagePreviewUrl: "" - }) - }, [props.openModal]) - - - const ProcessImg = (e: any): string | undefined => { - - const file = e?.target.files[0] - if (!file) { return } - - const reader = new FileReader() - reader.readAsDataURL(file) - - reader.onload = (event): void => { - const imgElement = document.createElement("img") - if (imgElement) { - imgElement.src = typeof event?.target?.result === 'string' ? event.target.result : "" - imgElement.onload = (e): void => { - let fileUpdated: File | string = file - let srcEncoded = '' - const canvas = document.createElement("canvas") - - const { width, height, ev } = calculateSize(imgElement, IMG_MAX_WIDTH, IMG_MAX_HEIGHT) - canvas.width = width - canvas.height = height - - const ctx = canvas.getContext("2d") - if (ctx && e?.target) { - ctx.imageSmoothingEnabled = true - ctx.imageSmoothingQuality = "high" - ctx.drawImage(ev, 0, 0, canvas.width, canvas.height) - srcEncoded = ctx.canvas.toDataURL(ev, file.type) - const blob = dataURItoBlob(srcEncoded, file.type) - fileUpdated = new File([blob], file.name, { type: file.type, lastModified: new Date().getTime() }) - setEcoLogoImage({ - logoFile: fileUpdated, - imagePreviewUrl: srcEncoded, - fileName: file.name - }) - } - } - } - } - } - - const isEmpty = (object: any): boolean => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars, guard-for-in - for (const property in object) { - setIsLogoImageEmpty(false) - return false - } - setIsLogoImageEmpty(true) - return true - } - - - const handleImageChange = (event: any): void => { - setImageError('') - const reader = new FileReader() - const file = event?.target?.files - - const fieSize = Number((file[0]?.size / 1024 / 1024)?.toFixed(2)) - const extension = file[0]?.name?.substring(file[0]?.name?.lastIndexOf(".") + 1)?.toLowerCase() - if (extension === "png" || extension === "jpeg" || extension === "jpg") { - if (fieSize <= imageSizeAccepted) { - reader.onloadend = (): void => { - ProcessImg(event) - isEmpty(reader.result) - } - reader.readAsDataURL(file[0]) - event.preventDefault() - } else { - setImageError("Please check image size") - } - } else { - setImageError("Invalid image type") - } - } - - const submitCreateEcosystem = async (values: EcoValues) => { - try { - setLoading(true) - const user_data = JSON.parse(await getFromLocalStorage(storageKeys.USER_PROFILE)) - const organizationId = await getFromLocalStorage(storageKeys.ORG_ID); - const ecoData = { - name: values.name, - description: values.description, - logo: ecologoImage?.imagePreviewUrl as string || "", - tags: "", - orgId: Number(organizationId), - userId: Number(user_data?.id) - } - const resCreateEco = await createEcosystems(ecoData) - - const { data } = resCreateEco as AxiosResponse - setLoading(false) - - if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { - props.setMessage(data?.message) - props.setOpenModal(false) - - } else { - setErrorMsg(resCreateEco as string) - } - } - catch (error) { - console.error("An error occurred:", error); - setLoading(false); - } - } - return ( - { - setEcoLogoImage({ - logoFile: "", - imagePreviewUrl: "", - fileName: '' - }) - setEcoData(newEcoData) - props.setOpenModal(false) - } - }> - Create Ecosystem - - { - setErrorMsg(null) - }} - /> - - ) => { - - submitCreateEcosystem(values) - }} - > - {(formikHandlers): JSX.Element => ( - -
    -
    -
    - { - typeof (ecologoImage.logoFile) === "string" ? - : - Jese picture - } - -
    -

    - Ecosystem Logo -

    -
    - JPG, JPEG and PNG . Max size of 1MB -
    -
    - -
    - - -
    - -
    -
    -
    -
    -
    -
    -
    - - { - (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && - {formikHandlers?.errors?.name} - } - -
    -
    -
    -
    - - - { - (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && - {formikHandlers?.errors?.description} - } -
    - - -
    - )} - -
    -
    - -
    - ) -} -export default CreateEcosystems; diff --git a/src/components/Ecosystems/EditEcosystems.tsx b/src/components/Ecosystems/EditEcosystems.tsx deleted file mode 100644 index 7fb5cac87..000000000 --- a/src/components/Ecosystems/EditEcosystems.tsx +++ /dev/null @@ -1,368 +0,0 @@ -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 } from '../../config/CommonConstant' -import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; -import { useEffect, useState } from "react"; -import { AlertComponent } from "../AlertComponent"; -import type { AxiosResponse } from 'axios'; -import { updateEcosystem } from "../../api/ecosystems"; -import type { Ecosystem } from "./interfaces"; - -interface EditEcoValues { - website: any; - name: string; - description: string; -} - -interface EditLogoImage { - logoFile: string | File - imagePreviewUrl: string | ArrayBuffer | null | File, - fileName: string -} - -interface EditEcosystemsModalProps { - openModal: boolean; - setMessage: (message: string) => void; - setOpenModal: (flag: boolean) => void; - onEditSucess?: () => void; - EditEcoData: Ecosystem | null; - -} - -const EditEcosystemsModal = (props: EditEcosystemsModalProps) => { - const [editLogoImage, setEditLogoImage] = useState({ - logoFile: "", - imagePreviewUrl: props?.EditEcoData?.logoUrl ?? "", - fileName: '', - - }) - const [loading, setLoading] = useState(false) - // const [isEditImageEmpty, setIsEditImageEmpty] = useState(true) - - - const [initialEditEcoData, setEditEcoData] = useState({ - name: props?.EditEcoData?.name ?? "", - description: props?.EditEcoData?.description ?? "", - website: props?.EditEcoData?.website ?? "", - }) - const newInitialEcoData = initialEditEcoData - useEffect(() => { - - if (props.EditEcoData) { - setEditEcoData({ - name: props.EditEcoData.name ?? '', - description: props.EditEcoData.description ?? '', - website: props?.EditEcoData?.website ?? "", - }); - - setEditLogoImage({ - logoFile: "", - imagePreviewUrl: props.EditEcoData.logoUrl ?? "", - fileName: '' - }); - } - }, [props]); - - - const [errorMsg, setErrorMsg] = useState(null) - - const [imgError, setImgError] = useState('') - - useEffect(() => { - if (props.openModal === false) { - setEditEcoData({ - name: '', - description: '', - website: '' - }) - - setEditLogoImage({ - ...editLogoImage, - logoFile: "", - imagePreviewUrl: "" - }) - } - }, [props.openModal]) - - - const ProcessImg = (e: any): string | undefined => { - - const file = e?.target.files[0] - if (!file) { return } - - const reader = new FileReader() - reader.readAsDataURL(file) - - reader.onload = (event): void => { - const imgElement = document.createElement("img") - if (imgElement) { - imgElement.src = typeof event?.target?.result === 'string' ? event.target.result : "" - imgElement.onload = (e): void => { - let fileUpdated: File | string = file - let srcEncoded = '' - const canvas = document.createElement("canvas") - - const { width, height, ev } = calculateSize(imgElement, IMG_MAX_WIDTH, IMG_MAX_HEIGHT) - canvas.width = width - canvas.height = height - - const ctx = canvas.getContext("2d") - if (ctx && e?.target) { - ctx.imageSmoothingEnabled = true - ctx.imageSmoothingQuality = "high" - ctx.drawImage(ev, 0, 0, canvas.width, canvas.height) - srcEncoded = ctx.canvas.toDataURL(ev, file.type) - const blob = dataURItoBlob(srcEncoded, file.type) - fileUpdated = new File([blob], file.name, { type: file.type, lastModified: new Date().getTime() }) - setEditLogoImage({ - logoFile: fileUpdated, - imagePreviewUrl: srcEncoded, - fileName: file.name - }) - } - } - } - } - } - - const isEmpty = (object: any): boolean => { - for (const item in object) { - // setIsEditImageEmpty(false) - return false - } - // setIsEditImageEmpty(true) - return true - } - - - const handleImageChange = (event: any): void => { - setImgError('') - const reader = new FileReader() - const file = event?.target?.files - - const fieSize = Number((file[0]?.size / 1024 / 1024)?.toFixed(2)) - const extension = file[0]?.name?.substring(file[0]?.name?.lastIndexOf(".") + 1)?.toLowerCase() - if (extension === "png" || extension === "jpeg" || extension === "jpg") { - if (fieSize <= imageSizeAccepted) { - reader.onloadend = (): void => { - ProcessImg(event) - isEmpty(reader.result) - } - reader.readAsDataURL(file[0]) - event.preventDefault() - } else { - setImgError("Please check image size") - } - } else { - setImgError("Invalid image type") - } - } - - const submitUpdateEcosystem = async (values: EditEcoValues) => { - - setLoading(true) - - const EcoData = { - orgId: props?.EditEcoData?.id, - name: values.name, - description: values.description, - logo: editLogoImage?.imagePreviewUrl as string || props?.EditEcoData?.logoUrl, - website: values.website, - - } - - const resUpdateEco = await updateEcosystem(EcoData, EcoData.orgId?.toString() as string) - - const { data } = resUpdateEco as AxiosResponse - setLoading(false) - - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - if (props?.onEditSucess) { - props?.onEditSucess() - } - props.setOpenModal(false) - } else { - setErrorMsg(resUpdateEco as string) - } - } - - return ( - { - setEditLogoImage({ - logoFile: "", - imagePreviewUrl: "", - fileName: '' - }) - setEditEcoData(newInitialEcoData) - props.setOpenModal(false) - } - }> - Edit Ecosystem - - { - setErrorMsg(null) - }} - /> - - ) => { - submitUpdateEcosystem(values) - }} - > - {(formikHandlers): JSX.Element => ( - -
    -
    -
    - - - { - props?.EditEcoData?.logoUrl ? - Jese picture - : typeof (editLogoImage.logoFile) === "string" ? - : - Jese picture - } - - -
    -

    - Ecosystem Logo -

    -
    - JPG, JPEG and PNG . Max size of 1MB -
    -
    - -
    - - -
    - -
    -
    -
    -
    -
    -
    -
    - - { - (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && - {formikHandlers?.errors?.name} - } - -
    - - -
    -
    -
    - - - { - (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && - {formikHandlers?.errors?.description} - } -
    -
    - - -
    - - -
    - )} -
    -
    - -
    - ) -} - -export default EditEcosystemsModal; diff --git a/src/components/organization/CreateOrgFormModal.tsx b/src/components/organization/CreateOrgFormModal.tsx deleted file mode 100644 index 23df6c043..000000000 --- a/src/components/organization/CreateOrgFormModal.tsx +++ /dev/null @@ -1,321 +0,0 @@ -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 } from '../../config/CommonConstant' -import { calculateSize, dataURItoBlob } from "../../utils/CompressImage"; -import { useEffect, useState } from "react"; -import { AlertComponent } from "../AlertComponent"; -import type { AxiosResponse } from 'axios'; -import { asset } from '../../lib/data.js'; -import { createOrganization } from "../../api/organization"; - - -interface Values { - name: string; - description: string; -} - -interface ILogoImage { - logoFile: string | File - imagePreviewUrl: string | ArrayBuffer | null | File, - fileName: string -} - - -const CreateOrgFormModal = (props: { openModal: boolean; setMessage: (message: string)=> void ; setOpenModal: (flag: boolean) => void }) => { - - const [logoImage, setLogoImage] = useState({ - logoFile: "", - imagePreviewUrl: "", - fileName: '' - }) - - const [loading, setLoading] = useState(false) - - const [isImageEmpty, setIsImageEmpty] = useState(true) - const [initialOrgData, setOrgData] = useState({ - name: '', - description: '', - }) - const [erroMsg, setErrMsg] = useState(null) - - const [imgError, setImgError] = useState('') - - useEffect(() => { - setOrgData({ - name: '', - description: '', - }) - setLogoImage({ - ...logoImage, - logoFile: "", - imagePreviewUrl: "" - }) - }, [props.openModal]) - - - const ProcessImg = (e: any): string | undefined => { - - const file = e?.target.files[0] - if (!file) { return } - - const reader = new FileReader() - reader.readAsDataURL(file) - - reader.onload = (event): void => { - const imgElement = document.createElement("img") - if (imgElement) { - imgElement.src = typeof event?.target?.result === 'string' ? event.target.result : "" - imgElement.onload = (e): void => { - let fileUpdated: File | string = file - let srcEncoded = '' - const canvas = document.createElement("canvas") - - const { width, height, ev } = calculateSize(imgElement, IMG_MAX_WIDTH, IMG_MAX_HEIGHT) - canvas.width = width - canvas.height = height - - const ctx = canvas.getContext("2d") - if (ctx && e?.target) { - ctx.imageSmoothingEnabled = true - ctx.imageSmoothingQuality = "high" - ctx.drawImage(ev, 0, 0, canvas.width, canvas.height) - srcEncoded = ctx.canvas.toDataURL(ev, file.type) - const blob = dataURItoBlob(srcEncoded, file.type) - fileUpdated = new File([blob], file.name, { type: file.type, lastModified: new Date().getTime() }) - setLogoImage({ - logoFile: fileUpdated, - imagePreviewUrl: srcEncoded, - fileName: file.name - }) - } - } - } - } - } - - const isEmpty = (object: any): boolean => { - - for (const property in object) { - setIsImageEmpty(false) - return false - } - setIsImageEmpty(true) - return true - } - - - const handleImageChange = (event: any): void => { - setImgError('') - const reader = new FileReader() - const file = event?.target?.files - - const fieSize = Number((file[0]?.size / 1024 / 1024)?.toFixed(2)) - const extension = file[0]?.name?.substring(file[0]?.name?.lastIndexOf(".") + 1)?.toLowerCase() - if (extension === "png" || extension === "jpeg" || extension === "jpg") { - if (fieSize <= imageSizeAccepted) { - reader.onloadend = (): void => { - ProcessImg(event) - isEmpty(reader.result) - } - reader.readAsDataURL(file[0]) - event.preventDefault() - } else { - setImgError("Please check image size") - } - } else { - setImgError("Invalid image type") - } - } - - const sumitCreateOrganization = async (values: Values) => { - setLoading(true) - - const orgData = { - name: values.name, - description: values.description, - logo: logoImage?.imagePreviewUrl as string || "", - website: "" - } - const resCreateOrg = await createOrganization(orgData) - - const { data } = resCreateOrg as AxiosResponse - setLoading(false) - - if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { - props.setMessage(data?.message) - props.setOpenModal(false) - - } else { - setErrMsg(resCreateOrg as string) - } - } - - return ( - { - setLogoImage({ - logoFile: "", - imagePreviewUrl: "", - fileName: '' - }) - setOrgData(initialOrgData) - props.setOpenModal(false) - } - }> - Create Organization - - { - setErrMsg(null) - }} - /> - - ) => { - - sumitCreateOrganization(values) - - }} - > - {(formikHandlers): JSX.Element => ( - -
    -
    -
    - { - typeof (logoImage.logoFile) === "string" ? - : - Jese picture - } - -
    -

    - Organization Logo -

    -
    - JPG, JPEG and PNG . Max size of 1MB -
    -
    - -
    - - -
    - -
    -
    -
    -
    -
    -
    -
    - - { - (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && - {formikHandlers?.errors?.name} - } - -
    -
    -
    -
    - - - { - (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && - {formikHandlers?.errors?.description} - } -
    - - -
    - )} - -
    -
    - -
    - ) -} - -export default CreateOrgFormModal; From fb1d5a5135d5b4d3a69d683e79fd7609a6299bd4 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 18:50:02 +0530 Subject: [PATCH 086/250] refactor:popupModal.tsx Signed-off-by: pranalidhanavade --- src/components/Dashboard.tsx | 4 +- src/components/Ecosystems/Dashboard.tsx | 4 +- src/components/PopupModal/index.tsx | 176 +----------------- .../organization/OrganizationsList.tsx | 3 +- 4 files changed, 10 insertions(+), 177 deletions(-) diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index 92cd0f1a1..aa98b04de 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -1,9 +1,9 @@ 'use client'; import { Button } from 'flowbite-react'; -import CreateOrgFormModal from "./organization/CreateOrgFormModal.js"; -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import PopupModal from '../components/PopupModal/index.js' +import React from 'react'; export default function Dashboard() { diff --git a/src/components/Ecosystems/Dashboard.tsx b/src/components/Ecosystems/Dashboard.tsx index 3bf73a980..07e071666 100644 --- a/src/components/Ecosystems/Dashboard.tsx +++ b/src/components/Ecosystems/Dashboard.tsx @@ -1,9 +1,7 @@ 'use client'; import { useState } from 'react'; import BreadCrumbs from '../BreadCrumbs'; -import CreateEcosystems from './CreateEcosystems'; import { EmptyListMessage } from '../EmptyListComponent'; -import EditEcosystems from './EditEcosystems'; import PopupModal from '../PopupModal'; import React from 'react'; @@ -49,8 +47,10 @@ const Dashboard = () => { }} isorgModal={false} /> + void ; setOpenModal: (flag: boolean) => void }) => { -console.log("cbcb") + const [logoImage, setLogoImage] = useState({ logoFile: "", imagePreviewUrl: "", @@ -203,7 +203,7 @@ console.log("cbcb") props.setOpenModal(false) } }> - Create Ecosystem + {props.isorgModal? "Create Organization":"Create Ecosystem"} ) => { - submitCreateEcosystem(values) + {props.isorgModal? sumitCreateOrganization(values):submitCreateEcosystem(values)} }} > @@ -265,7 +265,7 @@ console.log("cbcb")

    - Ecosystem Logo + {props.isorgModal? "Organization Logo":"Ecosystem Logo"} Ecosystem Logo

    JPG, JPEG and PNG . Max size of 1MB @@ -358,175 +358,9 @@ console.log("cbcb") ) } - const renderOrgFormModal = () =>{ - return( - { - setLogoImage({ - logoFile: "", - imagePreviewUrl: "", - fileName: '' - }) - setOrgData(initialOrgData) - props.setOpenModal(false) - } - }> - Create Organizationbcvbccvbv - - { - setErrMsg(null) - }} - /> - - ) => { - - sumitCreateOrganization(values) - - }} - > - {(formikHandlers): JSX.Element => ( - -
    -
    -
    - { - typeof (logoImage.logoFile) === "string" ? - : - Jese picture - } - -
    -

    - Organization Logo -

    -
    - JPG, JPEG and PNG . Max size of 1MB -
    -
    - -
    - - -
    - -
    -
    -
    -
    -
    -
    -
    - - { - (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && - {formikHandlers?.errors?.name} - } - -
    -
    -
    -
    - - - { - (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && - {formikHandlers?.errors?.description} - } -
    - - -
    - )} - -
    -
    - -
    - ) - } return ( <> - {props?.isorgModal ? renderOrgFormModal() : renderEcosystemModal()} + {renderEcosystemModal()} ) diff --git a/src/components/organization/OrganizationsList.tsx b/src/components/organization/OrganizationsList.tsx index 263745c35..ed23f86ab 100644 --- a/src/components/organization/OrganizationsList.tsx +++ b/src/components/organization/OrganizationsList.tsx @@ -1,13 +1,12 @@ 'use client'; -import { Button, Card, Pagination } from 'flowbite-react'; +import {Button,Card ,Pagination } from 'flowbite-react'; import { ChangeEvent, useEffect, useState } from 'react'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; import { AlertComponent } from '../AlertComponent'; import type { AxiosResponse } from 'axios'; import BreadCrumbs from '../BreadCrumbs'; -import CreateOrgFormModal from "./CreateOrgFormModal"; import CustomAvatar from '../Avatar' import { Features } from '../../utils/enums/features'; import type { Organisation } from './interfaces' From 06cdd590715aa8c2cf316635fa8259bf001099dd Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 18:59:49 +0530 Subject: [PATCH 087/250] refactor:popupModal.tsx Signed-off-by: pranalidhanavade --- src/components/PopupModal/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/PopupModal/index.tsx b/src/components/PopupModal/index.tsx index 1a73b0812..0d187373e 100644 --- a/src/components/PopupModal/index.tsx +++ b/src/components/PopupModal/index.tsx @@ -106,7 +106,7 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag const isEmpty = (object: any): boolean => { - for (const property in object) { + for (const property1 in object) { setIsImageEmpty(false) return false } From e602acd033a0fbf029db21fc6038527ba53a95ad Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 19:02:03 +0530 Subject: [PATCH 088/250] refactor:popupModal.tsx Signed-off-by: pranalidhanavade --- src/components/PopupModal/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/PopupModal/index.tsx b/src/components/PopupModal/index.tsx index 0d187373e..2047bea1f 100644 --- a/src/components/PopupModal/index.tsx +++ b/src/components/PopupModal/index.tsx @@ -107,6 +107,7 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag const isEmpty = (object: any): boolean => { for (const property1 in object) { + console.log("",property1) setIsImageEmpty(false) return false } From c79a044439b02186643aab72161ef437dcf4f7db Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 19:15:41 +0530 Subject: [PATCH 089/250] refactor:popupModal Signed-off-by: pranalidhanavade --- src/components/PopupModal/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/PopupModal/index.tsx b/src/components/PopupModal/index.tsx index 2047bea1f..b659e64bd 100644 --- a/src/components/PopupModal/index.tsx +++ b/src/components/PopupModal/index.tsx @@ -1,4 +1,4 @@ -import React from "react"; + import * as yup from "yup" @@ -192,6 +192,16 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag setLoading(false); } } + + + const submit= (values :EcoValues | Values)=>{ + if(props.isorgModal){ + sumitCreateOrganization(values) + }else{ + submitCreateEcosystem(values) + } + + } const renderEcosystemModal = () =>{ return( { @@ -237,7 +247,7 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag { resetForm }: FormikHelpers ) => { - {props.isorgModal? sumitCreateOrganization(values):submitCreateEcosystem(values)} + submit(values) }} > From b88cd1dae48e7bd4690034b00967e49231a30cdf Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 19:22:14 +0530 Subject: [PATCH 090/250] refactor:popupmodal issues Signed-off-by: pranalidhanavade --- src/components/PopupModal/index.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/components/PopupModal/index.tsx b/src/components/PopupModal/index.tsx index b659e64bd..5e5361a63 100644 --- a/src/components/PopupModal/index.tsx +++ b/src/components/PopupModal/index.tsx @@ -41,8 +41,6 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag }) const [loading, setLoading] = useState(false) - - const [isImageEmpty, setIsImageEmpty] = useState(true) const [initialOrgData, setOrgData] = useState({ name: '', description: '', @@ -51,6 +49,7 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag const [imgError, setImgError] = useState('') + const newinitialOrgData = initialOrgData useEffect(() => { setOrgData({ name: '', @@ -106,12 +105,6 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag const isEmpty = (object: any): boolean => { - for (const property1 in object) { - console.log("",property1) - setIsImageEmpty(false) - return false - } - setIsImageEmpty(true) return true } @@ -210,7 +203,7 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag imagePreviewUrl: "", fileName: '' }) - setOrgData(initialOrgData) + setOrgData(newinitialOrgData) props.setOpenModal(false) } }> From 87182a352d5ec491ac9a18f0c7a69ce6f13438b0 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 19:43:26 +0530 Subject: [PATCH 091/250] refactor:popupmodal sonacloud issue Signed-off-by: pranalidhanavade --- src/components/Ecosystems/Dashboard.tsx | 2 +- src/components/PopupModal/index.tsx | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/Ecosystems/Dashboard.tsx b/src/components/Ecosystems/Dashboard.tsx index 07e071666..a8e2e2607 100644 --- a/src/components/Ecosystems/Dashboard.tsx +++ b/src/components/Ecosystems/Dashboard.tsx @@ -47,7 +47,7 @@ const Dashboard = () => { }} isorgModal={false} /> - + { - const file = e?.target.files[0] - if (!file) { return } + const imgfile = e?.target.files[0] + if (!imgfile) { return } const reader = new FileReader() - reader.readAsDataURL(file) + reader.readAsDataURL(imgfile) reader.onload = (event): void => { const imgElement = document.createElement("img") if (imgElement) { imgElement.src = typeof event?.target?.result === 'string' ? event.target.result : "" imgElement.onload = (e): void => { - let fileUpdated: File | string = file + let fileUpdated: File | string = imgfile let srcEncoded = '' const canvas = document.createElement("canvas") @@ -89,13 +89,13 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag ctx.imageSmoothingEnabled = true ctx.imageSmoothingQuality = "high" ctx.drawImage(ev, 0, 0, canvas.width, canvas.height) - srcEncoded = ctx.canvas.toDataURL(ev, file.type) - const blob = dataURItoBlob(srcEncoded, file.type) - fileUpdated = new File([blob], file.name, { type: file.type, lastModified: new Date().getTime() }) + srcEncoded = ctx.canvas.toDataURL(ev, imgfile.type) + const blob = dataURItoBlob(srcEncoded, imgfile.type) + fileUpdated = new File([blob], imgfile.name, { type: imgfile.type, lastModified: new Date().getTime() }) setLogoImage({ logoFile: fileUpdated, imagePreviewUrl: srcEncoded, - fileName: file.name + fileName: imgfile.name }) } } @@ -269,7 +269,7 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag

    - {props.isorgModal? "Organization Logo":"Ecosystem Logo"} Ecosystem Logo + {props.isorgModal? "Organization Logo":"Ecosystem Logo"}

    JPG, JPEG and PNG . Max size of 1MB From 9bc08bab9192ee34d5cc45ca595e62eab94a6561 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 19:51:44 +0530 Subject: [PATCH 092/250] refactor:popupmodal duplication issue Signed-off-by: pranalidhanavade --- src/components/PopupModal/index.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/PopupModal/index.tsx b/src/components/PopupModal/index.tsx index fe3ddceb8..4334b0f50 100644 --- a/src/components/PopupModal/index.tsx +++ b/src/components/PopupModal/index.tsx @@ -68,10 +68,10 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag const imgfile = e?.target.files[0] if (!imgfile) { return } - const reader = new FileReader() - reader.readAsDataURL(imgfile) + const imgreader = new FileReader() + imgreader.readAsDataURL(imgfile) - reader.onload = (event): void => { + imgreader.onload = (event): void => { const imgElement = document.createElement("img") if (imgElement) { imgElement.src = typeof event?.target?.result === 'string' ? event.target.result : "" @@ -107,17 +107,15 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag return true } - - const handleImageChange = (event: any): void => { setImgError('') const reader = new FileReader() const file = event?.target?.files - const fieSize = Number((file[0]?.size / 1024 / 1024)?.toFixed(2)) + const imgfieSize = Number((file[0]?.size / 1024 / 1024)?.toFixed(2)) const extension = file[0]?.name?.substring(file[0]?.name?.lastIndexOf(".") + 1)?.toLowerCase() if (extension === "png" || extension === "jpeg" || extension === "jpg") { - if (fieSize <= imageSizeAccepted) { + if (imgfieSize <= imageSizeAccepted) { reader.onloadend = (): void => { ProcessImg(event) isEmpty(reader.result) From 4621f9937893bfb0199a8ddabe21eb936493c0ee Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 4 Oct 2023 20:12:56 +0530 Subject: [PATCH 093/250] refactor:createorg and createecosystems modal Signed-off-by: pranalidhanavade --- src/components/PopupModal/index.tsx | 53 ++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/src/components/PopupModal/index.tsx b/src/components/PopupModal/index.tsx index 4334b0f50..fb0d7cc4a 100644 --- a/src/components/PopupModal/index.tsx +++ b/src/components/PopupModal/index.tsx @@ -130,7 +130,7 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag } } - const sumitCreateOrganization = async (values: Values) => { + const submitCreateOrganization = async (values: Values) => { setLoading(true) const orgData = { @@ -187,12 +187,40 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag const submit= (values :EcoValues | Values)=>{ if(props.isorgModal){ - sumitCreateOrganization(values) + submitCreateOrganization(values) }else{ submitCreateEcosystem(values) } } + + const orgErrorMsg = { + name: yup + .string() + .min(2, 'Organization name must be at least 2 characters') + .max(50, 'Organization name must be at most 50 characters') + .required('Organization name is required') + .trim(), + description: yup + .string() + .min(2, 'Description must be at least 2 characters') + .max(255, 'Description must be at most 255 characters') + .required('Description is required'), + }; + + const ecoErrorMsg = { + name: yup + .string() + .min(2, 'Ecosystem name must be at least 2 characters') + .max(50, 'Ecosystem name must be at most 50 characters') + .required('Ecosystem name is required') + .trim(), + description: yup + .string() + .min(2, 'Description must be at least 2 characters') + .max(255, 'Description must be at most 255 characters') + .required('Description is required'), + }; const renderEcosystemModal = () =>{ return( { @@ -216,20 +244,13 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag /> Date: Thu, 5 Oct 2023 11:12:53 +0530 Subject: [PATCH 094/250] refactor:removed unwanted code Signed-off-by: pranalidhanavade --- src/api/ecosystems.ts | 7 +++++-- src/app/SideBar.astro | 2 +- src/config/pathRoutes.ts | 5 ----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/api/ecosystems.ts b/src/api/ecosystems.ts index 069f339f2..73551ff6c 100644 --- a/src/api/ecosystems.ts +++ b/src/api/ecosystems.ts @@ -3,10 +3,13 @@ import { apiRoutes } from "../config/apiRoutes"; import { getFromLocalStorage } from "./Auth"; import { storageKeys } from "../config/CommonConstant"; -export const createEcosystems = async (data: object) => { +interface datapayload{ +data:object +} +export const createEcosystems = async (Datapayload:datapayload) => { const url = apiRoutes.ecosystem.create - const payload = data + const payload = Datapayload const token = await getFromLocalStorage(storageKeys.TOKEN) const config = { diff --git a/src/app/SideBar.astro b/src/app/SideBar.astro index 252b1f303..dbd4faba0 100644 --- a/src/app/SideBar.astro +++ b/src/app/SideBar.astro @@ -114,7 +114,7 @@ import { pathRoutes } from "../config/pathRoutes"; d="M.99 5.24A2.25 2.25 0 013.25 3h13.5A2.25 2.25 0 0119 5.25l.01 9.5A2.25 2.25 0 0116.76 17H3.26A2.267 2.267 0 011 14.74l-.01-9.5zm8.26 9.52v-.625a.75.75 0 00-.75-.75H3.25a.75.75 0 00-.75.75v.615c0 .414.336.75.75.75h5.373a.75.75 0 00.627-.74zm1.5 0a.75.75 0 00.627.74h5.373a.75.75 0 00.75-.75v-.615a.75.75 0 00-.75-.75H11.5a.75.75 0 00-.75.75v.625zm6.75-3.63v-.625a.75.75 0 00-.75-.75H11.5a.75.75 0 00-.75.75v.625c0 .414.336.75.75.75h5.25a.75.75 0 00.75-.75zm-8.25 0v-.625a.75.75 0 00-.75-.75H3.25a.75.75 0 00-.75.75v.625c0 .414.336.75.75.75H8.5a.75.75 0 00.75-.75zM17.5 7.5v-.625a.75.75 0 00-.75-.75H11.5a.75.75 0 00-.75.75V7.5c0 .414.336.75.75.75h5.25a.75.75 0 00.75-.75zm-8.25 0v-.625a.75.75 0 00-.75-.75H3.25a.75.75 0 00-.75.75V7.5c0 .414.336.75.75.75H8.5a.75.75 0 00.75-.75z" > - Ecosystems + Ecosystem @@ -25,8 +24,8 @@ import { pathRoutes } from "../config/pathRoutes"; class="flex-1 px-3 space-y-1 bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-gray-700" > - - + + + + Verification + + + + + - - - -
  • - - -
  • + + --> +
    - - - + + + Support +
    +
    -

    - - + - + sidebarBackdrop?.addEventListener('click', () => { + toggleSidebarMobile( + sidebar, + sidebarBackdrop, + toggleSidebarMobileHamburger, + toggleSidebarMobileClose, + ); + }); + } + +
    + diff --git a/src/assets/endorser-card.svg b/src/assets/endorser-card.svg new file mode 100644 index 000000000..66676af22 --- /dev/null +++ b/src/assets/endorser-card.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/common/enums.ts b/src/common/enums.ts index 5b52d2eb8..fcbc1ba66 100644 --- a/src/common/enums.ts +++ b/src/common/enums.ts @@ -36,3 +36,8 @@ export enum IssueCredentialUserText { done = 'Accepted', abandoned = 'Declined' } + +export enum EcosystemRoles { + member = "member", + lead = "lead" +} \ No newline at end of file diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx new file mode 100644 index 000000000..242866228 --- /dev/null +++ b/src/components/Ecosystem/Dashboard.tsx @@ -0,0 +1,151 @@ +import type { IEcosystem } from './interfaces' +import { apiStatusCodes } from '../../config/CommonConstant'; +import { useEffect, useState } from 'react'; + +import { Alert, Button } from 'flowbite-react'; +import type { AxiosResponse } from 'axios'; +import BreadCrumbs from '../BreadCrumbs'; +import CustomAvatar from '../Avatar'; +import CustomSpinner from '../CustomSpinner'; +import endorseIcon from '../../assets/endorser-card.svg'; +import userCard from '../../assets/User_Card.svg'; +import MemberList from './MemberList'; +import { getEcosystem } from '../../api/ecosystem'; + +const Dashboard = () => { + const [ecosystemDetails, setEcosystemDetails] = useState() + const [success, setSuccess] = useState(null); + const [failure, setFailure] = useState(null) + + const [loading, setLoading] = useState(true) + + const fetchEcosystemDetails = async () => { + + setLoading(true) + + const response = await getEcosystem(); + + const { data } = response as AxiosResponse + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + setEcosystemDetails({ + logoUrl: "", + name: "Ecosystem 1234", + description: "Test" + }) + } else { + setFailure(response as string) + } + setLoading(false) + } + + useEffect(() => { + fetchEcosystemDetails() + }, []) + + return ( +
    +
    + +
    +
    +
    +
    +
    + {(ecosystemDetails?.logoUrl) ? : } +
    + {ecosystemDetails ? +
    +

    + {ecosystemDetails?.name} +

    + +

    + {ecosystemDetails?.description} +

    +
    + : !ecosystemDetails && loading ? + + : "" + } +
    + +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    +

    + Member +

    + 23 + +
    +
    + +
    +
    +

    + Endorsements +

    + + 598 + +
    +
    +
    +
    + { + (success || failure) && + setFailure(null)} + > + +

    + {success || failure} +

    +
    +
    + } +
    + +
    +
    +
    + ) + +} + +export default Dashboard \ No newline at end of file diff --git a/src/components/Ecosystem/MemberList.tsx b/src/components/Ecosystem/MemberList.tsx new file mode 100644 index 000000000..a32d9e1c5 --- /dev/null +++ b/src/components/Ecosystem/MemberList.tsx @@ -0,0 +1,7 @@ +const MemberList = () => { + return ( +

    Members List

    + ) +} + +export default MemberList \ No newline at end of file diff --git a/src/components/Ecosystem/interfaces/index.ts b/src/components/Ecosystem/interfaces/index.ts new file mode 100644 index 000000000..8840a69b1 --- /dev/null +++ b/src/components/Ecosystem/interfaces/index.ts @@ -0,0 +1,5 @@ +export interface IEcosystem { + name: string + description: string + logoUrl: string +} \ No newline at end of file diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index cb9353209..83a6ebe43 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -1,15 +1,15 @@ export const apiRoutes = { - auth:{ - sendMail:'/auth/verification-mail', + auth: { + sendMail: '/auth/verification-mail', sinIn: '/auth/signin', - verifyEmail:'/auth/verify', - addDetails:'/auth/signup', - passkeyUserDetails:'/users/password/', - profile:'/profile', + verifyEmail: '/auth/verify', + addDetails: '/auth/signup', + passkeyUserDetails: '/users/password/', + profile: '/profile', }, - users:{ + users: { userProfile: '/users/profile', - checkUser:'/users/', + checkUser: '/users/', invitations: '/users/org-invitations', fetchUsers: '/users', update: '/users', @@ -32,7 +32,7 @@ export const apiRoutes = { schema: { create: '/schemas', getAll: '/schemas', - getSchemaById:'/schemas', + getSchemaById: '/schemas', createCredentialDefinition: '/cred-defs', getCredDefBySchemaId: '/schemas', }, @@ -58,15 +58,18 @@ export const apiRoutes = { presentationVerification: '/proofs', proofRequestAttributesVerification: '/proofs' }, - Agent:{ - checkAgentHealth: '/agents/health', - agentDedicatedSpinup: '/agents/spinup', - agentSharedSpinup: '/agents/wallet' - }, - Platform: { - getAllSchemaFromPlatform: '/platform/schemas', - }, - public:{ - organizations: '/orgs/public-profile', - } + Agent: { + checkAgentHealth: '/agents/health', + agentDedicatedSpinup: '/agents/spinup', + agentSharedSpinup: '/agents/wallet' + }, + Platform: { + getAllSchemaFromPlatform: '/platform/schemas', + }, + Public: { + organizations: '/orgs/public-profile', + }, + Ecosystem: { + getEcosystem: '/ecosystem' + } } diff --git a/src/config/ecosystem.ts b/src/config/ecosystem.ts new file mode 100644 index 000000000..22db593e8 --- /dev/null +++ b/src/config/ecosystem.ts @@ -0,0 +1,12 @@ +import { EcosystemRoles } from "../common/enums" + +const isEnabledEcosystem = true +const ecosystemRole = EcosystemRoles.member + +const checkEcosystem = () => ({ + isEnabledEcosystem, + isEcosystemMember: ecosystemRole === EcosystemRoles.member && isEnabledEcosystem, + isEcosystemLead: ecosystemRole === EcosystemRoles.lead && isEnabledEcosystem +}) + +export default checkEcosystem \ No newline at end of file diff --git a/src/config/pathRoutes.ts b/src/config/pathRoutes.ts index 52bb5ae8f..2675d45fc 100644 --- a/src/config/pathRoutes.ts +++ b/src/config/pathRoutes.ts @@ -34,15 +34,10 @@ export const pathRoutes = { verify:'/organizations/verification/schemas/cred-defs/connections/verification' }, }, - - // ecosystems: { - // root: '/ecosystems', - // frameworks: '/ecosystems/frameworks', - // members: '/ecosystems/members', - // registries: '/ecosystems/registries', - // users: '/organizations/users', - // credentials: '/organizations/credentials' - // }, + ecosystem: { + profile: "/ecosystem/profile", + endorsements: "/ecosystem/endorsements" + }, documentation: { root: 'https://docs.credebl.id' }, diff --git a/src/pages/ecosystem/profile.astro b/src/pages/ecosystem/profile.astro new file mode 100644 index 000000000..1437e6e6f --- /dev/null +++ b/src/pages/ecosystem/profile.astro @@ -0,0 +1,8 @@ +--- +import LayoutSidebar from '../../app/LayoutSidebar.astro'; +import Dashboard from '../../components/Ecosystem/Dashboard'; +--- + + + + \ No newline at end of file From e9b7097a1aecd53ec3763a445a9c0b570f2d91f0 Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Fri, 6 Oct 2023 11:55:46 +0530 Subject: [PATCH 098/250] refactor: integrated API data Signed-off-by: sanjay-k1910 --- src/components/Ecosystem/Dashboard.tsx | 11 ++++--- src/config/pathRoutes.ts | 44 ++++++++++++-------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index 242866228..243b845ab 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -28,10 +28,11 @@ const Dashboard = () => { const { data } = response as AxiosResponse if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + const { logoUrl, name, description } = data?.data[0] setEcosystemDetails({ - logoUrl: "", - name: "Ecosystem 1234", - description: "Test" + logoUrl, + name, + description }) } else { setFailure(response as string) @@ -61,11 +62,11 @@ const Dashboard = () => { {ecosystemDetails ?

    - {ecosystemDetails?.name} + {ecosystemDetails?.name || "Dummy Name"}

    - {ecosystemDetails?.description} + {ecosystemDetails?.description || "Dummy Desc"}

    : !ecosystemDetails && loading ? diff --git a/src/config/pathRoutes.ts b/src/config/pathRoutes.ts index 2675d45fc..cc61a0acf 100644 --- a/src/config/pathRoutes.ts +++ b/src/config/pathRoutes.ts @@ -20,18 +20,17 @@ export const pathRoutes = { credentials: '/organizations/verification', createSchema: '/organizations/schemas/create', viewSchema: '/organizations/schemas/view-schema', - Issuance: { schema: '/organizations/credentials-issued/schemas', - credDef:'/organizations/credentials-issued/schemas/cred-defs', - connections:'/organizations/credentials-issued/schemas/cred-defs/connections', - issuance:'/organizations/credentials-issued/schemas/cred-defs/connections/issuance' + credDef: '/organizations/credentials-issued/schemas/cred-defs', + connections: '/organizations/credentials-issued/schemas/cred-defs/connections', + issuance: '/organizations/credentials-issued/schemas/cred-defs/connections/issuance' }, verification: { schema: '/organizations/verification/schemas', - credDef:'/organizations/verification/schemas/cred-defs', - connections:'/organizations/verification/schemas/cred-defs/connections', - verify:'/organizations/verification/schemas/cred-defs/connections/verification' + credDef: '/organizations/verification/schemas/cred-defs', + connections: '/organizations/verification/schemas/cred-defs/connections', + verify: '/organizations/verification/schemas/cred-defs/connections/verification' }, }, ecosystem: { @@ -48,20 +47,19 @@ export const pathRoutes = { createCredentialDefinition: '/credential-definitions', getCredDeffBySchemaId: '/schemas/credential-definitions' }, - - back:{ - schema:{ - schemas:'/organizations/schemas' - }, - verification:{ - credDef:'/organizations/verification/schemas/cred-defs', - schemas:'/organizations/verification/schemas', - verification:'/organizations/verification/schemas/cred-defs/connections', - }, - issuance:{ - credDef:'/organizations/credentials-issued/schemas/cred-defs', - schemas:'/organizations/credentials-issued/schemas', - connections: '/organizations/credentials-issued/schemas/cred-defs/connections' - } - } + back: { + schema: { + schemas: '/organizations/schemas' + }, + verification: { + credDef: '/organizations/verification/schemas/cred-defs', + schemas: '/organizations/verification/schemas', + verification: '/organizations/verification/schemas/cred-defs/connections', + }, + issuance: { + credDef: '/organizations/credentials-issued/schemas/cred-defs', + schemas: '/organizations/credentials-issued/schemas', + connections: '/organizations/credentials-issued/schemas/cred-defs/connections' + } + } } From c596e51ae6ded70b1e6ffcabffcd033d9f09401d Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Fri, 6 Oct 2023 12:14:09 +0530 Subject: [PATCH 099/250] refactor: handled ecosystem dashboard and create ecosystem conditionally Signed-off-by: sanjay-k1910 --- src/components/Ecosystem/Dashboard.tsx | 213 +++++++++++------- src/components/Ecosystem/interfaces/index.ts | 13 ++ src/components/Ecosystems/Dashboard.tsx | 68 ------ src/components/Ecosystems/interfaces/index.ts | 13 -- tailwind.config.cjs | 55 ++--- 5 files changed, 171 insertions(+), 191 deletions(-) delete mode 100644 src/components/Ecosystems/Dashboard.tsx delete mode 100644 src/components/Ecosystems/interfaces/index.ts diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index 243b845ab..606b7ae08 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -11,6 +11,8 @@ import endorseIcon from '../../assets/endorser-card.svg'; import userCard from '../../assets/User_Card.svg'; import MemberList from './MemberList'; import { getEcosystem } from '../../api/ecosystem'; +import PopupModal from '../PopupModal'; +import { EmptyListMessage } from '../EmptyListComponent'; const Dashboard = () => { const [ecosystemDetails, setEcosystemDetails] = useState() @@ -19,6 +21,19 @@ const Dashboard = () => { const [loading, setLoading] = useState(true) + const [openModal, setOpenModal,] = useState(false); + const [editEcosystemModal, setEditEcosystemModal] = useState(false); + const props = { openModal, setOpenModal, editEcosystemModal, setEditEcosystemModal }; + + + const createEcosystemModel = () => { + props.setOpenModal(true) + } + + const EditEcosystemsModel = () => { + props.setEditEcosystemModal(true); + }; + const fetchEcosystemDetails = async () => { setLoading(true) @@ -49,101 +64,131 @@ const Dashboard = () => {
    -
    -
    -
    -
    - {(ecosystemDetails?.logoUrl) ? : } -
    - {ecosystemDetails ? -
    -

    - {ecosystemDetails?.name || "Dummy Name"} -

    - -

    - {ecosystemDetails?.description || "Dummy Desc"} -

    + { + ecosystemDetails ? +
    +
    +
    +
    + {(ecosystemDetails?.logoUrl) ? : } +
    + {ecosystemDetails ? +
    +

    + {ecosystemDetails?.name || "Dummy Name"} +

    + +

    + {ecosystemDetails?.description || "Dummy Desc"} +

    +
    + : !ecosystemDetails && loading ? + + : "" + }
    - : !ecosystemDetails && loading ? - - : "" - } -
    -
    - -
    - +
    + +
    + +
    +
    -
    -
    - -
    -
    +
    -
    -

    - Member -

    - 23 - +
    +
    +
    +

    + Member +

    + 23 + +
    +
    + +
    +
    +

    + Endorsements +

    + + 598 + +
    +
    - + { + (success || failure) && + setFailure(null)} + > + +

    + {success || failure} +

    +
    +
    + } +
    + +
    +
    + : !ecosystemDetails && loading ? +
    + +
    + :
    -
    -

    - Endorsements -

    - - 598 - +
    + + + + } + onClick={createEcosystemModel} + />
    -
    -
    - { - (success || failure) && - setFailure(null)} - > - -

    - {success || failure} -

    -
    -
    - } -
    - -
    -
    + }
    ) diff --git a/src/components/Ecosystem/interfaces/index.ts b/src/components/Ecosystem/interfaces/index.ts index 8840a69b1..3772fadde 100644 --- a/src/components/Ecosystem/interfaces/index.ts +++ b/src/components/Ecosystem/interfaces/index.ts @@ -2,4 +2,17 @@ export interface IEcosystem { name: string description: string logoUrl: string +} + +export interface Ecosystem { + id: number + createDateTime: string + createdBy: number + lastChangedDateTime: string + lastChangedBy: number + name: string + description: string + logoUrl: string + website: string + roles: string[] } \ No newline at end of file diff --git a/src/components/Ecosystems/Dashboard.tsx b/src/components/Ecosystems/Dashboard.tsx deleted file mode 100644 index a8e2e2607..000000000 --- a/src/components/Ecosystems/Dashboard.tsx +++ /dev/null @@ -1,68 +0,0 @@ -'use client'; -import { useState } from 'react'; -import BreadCrumbs from '../BreadCrumbs'; -import { EmptyListMessage } from '../EmptyListComponent'; -import PopupModal from '../PopupModal'; -import React from 'react'; - - - -const initialPageState = { - pageNumber: 1, - pageSize: 9, - total: 100, -}; - -const Dashboard = () => { - const [openModal, setOpenModal,] = useState(false); - const [editEcosystemModal, setEditEcosystemModal] = useState(false); - const props = { openModal, setOpenModal, editEcosystemModal, setEditEcosystemModal }; - - - const createEcosystemModel = () => { - props.setOpenModal(true) - } - - const EditEcosystemsModel = () => { - props.setEditEcosystemModal(true); - }; - - return ( -
    -
    - -

    - Ecosystems -

    -
    -
    -
    - - - - - - - } - onClick={createEcosystemModel} - /> -
    -
    -
    - ) -} - -export default Dashboard; diff --git a/src/components/Ecosystems/interfaces/index.ts b/src/components/Ecosystems/interfaces/index.ts deleted file mode 100644 index b968799a9..000000000 --- a/src/components/Ecosystems/interfaces/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -export interface Ecosystem { - id: number - createDateTime: string - createdBy: number - lastChangedDateTime: string - lastChangedBy: number - name: string - description: string - logoUrl: string - website: string - roles: string[] - -} \ No newline at end of file diff --git a/tailwind.config.cjs b/tailwind.config.cjs index 7614fac1b..00e84c980 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -16,41 +16,41 @@ module.exports = { extend: { colors: { accentColor: '#20ACDF', - - primary: { - DEFAULT: '#1F4EAD', - 50: '#DCE6F9', - 100: '#CBD9F6', - 200: '#A9C0F0', - 300: '#86A7E9', - 400: '#638EE3', - 500: '#4174DD', - 600: '#255ED0', - 700: '#1F4EAD', - 800: '#16397D', - 900: '#0E234E', + + primary: { + DEFAULT: '#1F4EAD', + 50: '#DCE6F9', + 100: '#CBD9F6', + 200: '#A9C0F0', + 300: '#86A7E9', + 400: '#638EE3', + 500: '#4174DD', + 600: '#255ED0', + 700: '#1F4EAD', + 800: '#16397D', + 900: '#0E234E', 950: '#0A1836' }, - secondary: { - DEFAULT: '#D6F5F5', - 50: '#FFFFFF', - 100: '#FFFFFF', - 200: '#FFFFFF', - 300: '#FFFFFF', - 400: '#FFFFFF', - 500: '#FFFFFF', - 600: '#F7FDFD', - 700: '#D6F5F5', - 800: '#A9EAEA', - 900: '#7CDFDF', + secondary: { + DEFAULT: '#D6F5F5', + 50: '#FFFFFF', + 100: '#FFFFFF', + 200: '#FFFFFF', + 300: '#FFFFFF', + 400: '#FFFFFF', + 500: '#FFFFFF', + 600: '#F7FDFD', + 700: '#D6F5F5', + 800: '#A9EAEA', + 900: '#7CDFDF', 950: '#65DADA' }, }, fontFamily: { sans: [ ...defaultTheme.fontFamily.sans, - 'Inter var', + 'Inter var', 'ui-sans-serif', 'system-ui', '-apple-system', @@ -103,6 +103,9 @@ module.exports = { }, maxWidth: { '100/6rem': 'calc(100% - 6rem)' + }, + minHeight: { + '100/18rem': 'calc(100vh - 18rem)' } }, }, From 0c3946cd6636654c5ef4b86ba7b3b0c02af4b661 Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Fri, 6 Oct 2023 14:21:56 +0530 Subject: [PATCH 100/250] fix: sonallint issues and handled create ecosystem response Signed-off-by: sanjay-k1910 --- src/api/ecosystem.ts | 2 +- src/api/ecosystems.ts | 19 +- src/components/Ecosystem/Dashboard.tsx | 109 +++--- src/components/PopupModal/index.tsx | 372 ++++++++++--------- src/components/Verification/Verification.tsx | 2 +- src/config/apiRoutes.ts | 2 +- 6 files changed, 258 insertions(+), 248 deletions(-) diff --git a/src/api/ecosystem.ts b/src/api/ecosystem.ts index f64a212c6..7a49d1ff3 100644 --- a/src/api/ecosystem.ts +++ b/src/api/ecosystem.ts @@ -6,7 +6,7 @@ import { storageKeys } from "../config/CommonConstant"; export const getEcosystem = async () => { - const url = `${apiRoutes.Ecosystem.getEcosystem}` + const url = `${apiRoutes.Ecosystem.root}` const token = await getFromLocalStorage(storageKeys.TOKEN) diff --git a/src/api/ecosystems.ts b/src/api/ecosystems.ts index 73551ff6c..382401d6c 100644 --- a/src/api/ecosystems.ts +++ b/src/api/ecosystems.ts @@ -1,15 +1,20 @@ -import { axiosPost, axiosPut } from "../services/apiRequests" +import { axiosPost, axiosPut } from "../services/apiRequests" import { apiRoutes } from "../config/apiRoutes"; import { getFromLocalStorage } from "./Auth"; import { storageKeys } from "../config/CommonConstant"; -interface datapayload{ -data:object +interface DataPayload { + name: string + description: string + logo: string + tags: string + orgId: number + userId: number } -export const createEcosystems = async (Datapayload:datapayload) => { - const url = apiRoutes.ecosystem.create - const payload = Datapayload +export const createEcosystems = async (dataPayload: DataPayload) => { + const url = apiRoutes.Ecosystem.root + const payload = dataPayload const token = await getFromLocalStorage(storageKeys.TOKEN) const config = { @@ -33,7 +38,7 @@ export const createEcosystems = async (Datapayload:datapayload) => { } } -export const updateEcosystem = async (data: object, orgId:string) => { +export const updateEcosystem = async (data: object, orgId: string) => { const url = `${apiRoutes.organizations.update}/${orgId}` const payload = data diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index 606b7ae08..5a892f0c1 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -21,19 +21,14 @@ const Dashboard = () => { const [loading, setLoading] = useState(true) - const [openModal, setOpenModal,] = useState(false); - const [editEcosystemModal, setEditEcosystemModal] = useState(false); - const props = { openModal, setOpenModal, editEcosystemModal, setEditEcosystemModal }; + const [openModal, setOpenModal] = useState(false); + const props = { openModal, setOpenModal }; const createEcosystemModel = () => { props.setOpenModal(true) } - const EditEcosystemsModel = () => { - props.setEditEcosystemModal(true); - }; - const fetchEcosystemDetails = async () => { setLoading(true) @@ -43,11 +38,11 @@ const Dashboard = () => { const { data } = response as AxiosResponse if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const { logoUrl, name, description } = data?.data[0] + const ecosystemData = data?.data[0] setEcosystemDetails({ - logoUrl, - name, - description + logoUrl: ecosystemData.logoUrl, + name: ecosystemData.name, + description: ecosystemData.description }) } else { setFailure(response as string) @@ -64,6 +59,22 @@ const Dashboard = () => {
    + { + (success || failure) && + { + setSuccess(null) + setFailure(null) + }} + > + +

    + {success ?? failure} +

    +
    +
    + } { ecosystemDetails ?
    @@ -86,9 +97,7 @@ const Dashboard = () => { {ecosystemDetails?.description || "Dummy Desc"}

    - : !ecosystemDetails && loading ? - - : "" + : }
    @@ -144,50 +153,42 @@ const Dashboard = () => {
    - { - (success || failure) && - setFailure(null)} - > - -

    - {success || failure} -

    -
    -
    - }
    - : !ecosystemDetails && loading ? -
    - -
    - : -
    -
    - - - - } - onClick={createEcosystemModel} - /> -
    -
    + :
    + { + !ecosystemDetails && loading ? +
    + +
    + : +
    +
    + { + setSuccess(value) + fetchEcosystemDetails() + }} + isorgModal={false} + /> + + + } + onClick={() => createEcosystemModel()} + /> +
    +
    + } +
    }
    ) diff --git a/src/components/PopupModal/index.tsx b/src/components/PopupModal/index.tsx index fb0d7cc4a..5c60e1298 100644 --- a/src/components/PopupModal/index.tsx +++ b/src/components/PopupModal/index.tsx @@ -30,9 +30,14 @@ interface EcoValues { description: string; } +interface IProps { + openModal: boolean; + isorgModal: boolean; + setMessage: (message: string) => void; + setOpenModal: (flag: boolean) => void +} - -const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessage: (message: string)=> void ; setOpenModal: (flag: boolean) => void }) => { +const PopupModal = (props: IProps) => { const [logoImage, setLogoImage] = useState({ logoFile: "", @@ -104,7 +109,7 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag } const isEmpty = (object: any): boolean => { - + return true } const handleImageChange = (event: any): void => { @@ -166,14 +171,13 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag userId: Number(user_data?.id) } const resCreateEco = await createEcosystems(ecoData) - + const { data } = resCreateEco as AxiosResponse setLoading(false) if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { props.setMessage(data?.message) props.setOpenModal(false) - } else { setErrMsg(resCreateEco as string) } @@ -185,10 +189,10 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag } - const submit= (values :EcoValues | Values)=>{ - if(props.isorgModal){ + const submit = (values: EcoValues | Values) => { + if (props.isorgModal) { submitCreateOrganization(values) - }else{ + } else { submitCreateEcosystem(values) } @@ -196,198 +200,198 @@ const PopupModal = (props: { openModal: boolean; isorgModal : boolean ;setMessag const orgErrorMsg = { name: yup - .string() - .min(2, 'Organization name must be at least 2 characters') - .max(50, 'Organization name must be at most 50 characters') - .required('Organization name is required') - .trim(), + .string() + .min(2, 'Organization name must be at least 2 characters') + .max(50, 'Organization name must be at most 50 characters') + .required('Organization name is required') + .trim(), description: yup - .string() - .min(2, 'Description must be at least 2 characters') - .max(255, 'Description must be at most 255 characters') - .required('Description is required'), - }; - - const ecoErrorMsg = { + .string() + .min(2, 'Description must be at least 2 characters') + .max(255, 'Description must be at most 255 characters') + .required('Description is required'), + }; + + const ecoErrorMsg = { name: yup - .string() - .min(2, 'Ecosystem name must be at least 2 characters') - .max(50, 'Ecosystem name must be at most 50 characters') - .required('Ecosystem name is required') - .trim(), + .string() + .min(2, 'Ecosystem name must be at least 2 characters') + .max(50, 'Ecosystem name must be at most 50 characters') + .required('Ecosystem name is required') + .trim(), description: yup - .string() - .min(2, 'Description must be at least 2 characters') - .max(255, 'Description must be at most 255 characters') - .required('Description is required'), - }; - const renderEcosystemModal = () =>{ - return( - { - setLogoImage({ - logoFile: "", - imagePreviewUrl: "", - fileName: '' - }) - setOrgData(newinitialOrgData) - props.setOpenModal(false) - } - }> - {props.isorgModal? "Create Organization":"Create Ecosystem"} - - { - setErrMsg(null) - }} - /> - - ) => { - - submit(values) - - }} - > - {(formikHandlers): JSX.Element => ( - -
    + .string() + .min(2, 'Description must be at least 2 characters') + .max(255, 'Description must be at most 255 characters') + .required('Description is required'), + }; + const renderEcosystemModal = () => { + const popupName = props.isorgModal ? "Organization" : "Ecosystem" + return ( + { + setLogoImage({ + logoFile: "", + imagePreviewUrl: "", + fileName: '' + }) + setOrgData(newinitialOrgData) + props.setOpenModal(false) + } + }> + Create {popupName} + + { + setErrMsg(null) + }} + /> + + ) => { + + submit(values) + + }} + > + {(formikHandlers): JSX.Element => ( + + +
    -
    - { - typeof (logoImage.logoFile) === "string" ? - : - Jese picture - } - -
    -

    - {props.isorgModal? "Organization Logo":"Ecosystem Logo"} -

    -
    - JPG, JPEG and PNG . Max size of 1MB -
    -
    - -
    - - -
    - + { + typeof (logoImage.logoFile) === "string" ? + : + Jese picture + } + +
    +

    + {popupName} Logo +

    +
    + JPG, JPEG and PNG . Max size of 1MB +
    +
    + +
    + +
    +
    -
    -
    -
    - - { - (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && - {formikHandlers?.errors?.name} - } - +
    +
    +
    +
    -
    -
    -
    - - - { - (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && - {formikHandlers?.errors?.description} - } + + { + (formikHandlers?.errors?.name && formikHandlers?.touched?.name) && + {formikHandlers?.errors?.name} + } + +
    +
    +
    +
    - - - - )} - - - - - + + + { + (formikHandlers?.errors?.description && formikHandlers?.touched?.description) && + {formikHandlers?.errors?.description} + } +
    + + + + )} + + + + + ) - } + } return ( - <> - {renderEcosystemModal()} + <> + {renderEcosystemModal()} - + ) - + } export default PopupModal; diff --git a/src/components/Verification/Verification.tsx b/src/components/Verification/Verification.tsx index 2ea2387f3..4340b96c5 100644 --- a/src/components/Verification/Verification.tsx +++ b/src/components/Verification/Verification.tsx @@ -56,7 +56,7 @@ const VerificationCred = () => { const schemaAttributes = await getFromLocalStorage(storageKeys.SCHEMA_ATTR) const parsedSchemaDetails = JSON.parse(schemaAttributes) || []; const attributes = parsedSchemaDetails.attribute.map((ele: any) => { - const attributes = ele.displayName ? ele.displayName : 'Not available'; + const attributes = ele.attributeName ? ele.attributeName : 'Not available'; return { data: [ { diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index 199047593..2d36e8dbf 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -71,6 +71,6 @@ export const apiRoutes = { organizations: '/orgs/public-profile', }, Ecosystem: { - getEcosystem: '/ecosystem' + root: '/ecosystem' } } From 180e74f2ff4f670dd04a6b661d54efb2dca97fb7 Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Fri, 6 Oct 2023 14:25:05 +0530 Subject: [PATCH 101/250] fix: updated path Signed-off-by: sanjay-k1910 --- src/pages/ecosystems/index.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ecosystems/index.astro b/src/pages/ecosystems/index.astro index bb9899381..ae15c77de 100644 --- a/src/pages/ecosystems/index.astro +++ b/src/pages/ecosystems/index.astro @@ -1,6 +1,6 @@ --- import LayoutSidebar from '../../app/LayoutSidebar.astro'; -import Dashboard from '../../components/Ecosystems/Dashboard'; +import Dashboard from '../../components/Ecosystem/Dashboard'; import { checkUserSession } from '../../utils/check-session'; import { pathRoutes } from '../../config/pathRoutes'; From 5861f8a2bffaf4a80053661764ffbac6e998bb9a Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Fri, 6 Oct 2023 16:08:05 +0530 Subject: [PATCH 102/250] fix: resolved comments Signed-off-by: sanjay-k1910 --- src/common/enums.ts | 4 +-- .../index.tsx | 10 +++--- src/components/Dashboard.tsx | 17 +++++---- src/components/Ecosystem/Dashboard.tsx | 22 +++++------- src/components/Verification/Verification.tsx | 8 ++--- .../organization/OrganizationsList.tsx | 35 +++++++++---------- src/config/ecosystem.ts | 6 ++-- 7 files changed, 46 insertions(+), 56 deletions(-) rename src/components/{PopupModal => CreateEcosystemOrgModal}/index.tsx (98%) diff --git a/src/common/enums.ts b/src/common/enums.ts index fcbc1ba66..e42f95434 100644 --- a/src/common/enums.ts +++ b/src/common/enums.ts @@ -38,6 +38,6 @@ export enum IssueCredentialUserText { } export enum EcosystemRoles { - member = "member", - lead = "lead" + ecosystemMember = "Ecosystem Member", + ecosystemLead = "Ecosystem Lead" } \ No newline at end of file diff --git a/src/components/PopupModal/index.tsx b/src/components/CreateEcosystemOrgModal/index.tsx similarity index 98% rename from src/components/PopupModal/index.tsx rename to src/components/CreateEcosystemOrgModal/index.tsx index 5c60e1298..d8f6882f0 100644 --- a/src/components/PopupModal/index.tsx +++ b/src/components/CreateEcosystemOrgModal/index.tsx @@ -33,11 +33,11 @@ interface EcoValues { interface IProps { openModal: boolean; isorgModal: boolean; - setMessage: (message: string) => void; + setMessage?: (message: string) => void; setOpenModal: (flag: boolean) => void } -const PopupModal = (props: IProps) => { +const CreateEcosystemOrgModal = (props: IProps) => { const [logoImage, setLogoImage] = useState({ logoFile: "", @@ -150,7 +150,7 @@ const PopupModal = (props: IProps) => { setLoading(false) if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { - props.setMessage(data?.message) + props.setMessage && props.setMessage(data?.message) props.setOpenModal(false) } else { @@ -176,7 +176,7 @@ const PopupModal = (props: IProps) => { setLoading(false) if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { - props.setMessage(data?.message) + props.setMessage && props.setMessage(data?.message) props.setOpenModal(false) } else { setErrMsg(resCreateEco as string) @@ -394,4 +394,4 @@ const PopupModal = (props: IProps) => { } -export default PopupModal; +export default CreateEcosystemOrgModal; diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index aa98b04de..800f2ab1b 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -1,9 +1,8 @@ 'use client'; import { Button } from 'flowbite-react'; -import { useState } from 'react'; -import PopupModal from '../components/PopupModal/index.js' -import React from 'react'; +import { useState } from 'react'; +import CreateEcosystemOrgModal from './CreateEcosystemOrgModal'; export default function Dashboard() { @@ -14,7 +13,7 @@ export default function Dashboard() { props.setOpenModal(true) } - + return (
    @@ -32,11 +31,11 @@ export default function Dashboard() { { props.openModal && - + }
    diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index 5a892f0c1..d43951569 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -2,7 +2,7 @@ import type { IEcosystem } from './interfaces' import { apiStatusCodes } from '../../config/CommonConstant'; import { useEffect, useState } from 'react'; -import { Alert, Button } from 'flowbite-react'; +import { Button } from 'flowbite-react'; import type { AxiosResponse } from 'axios'; import BreadCrumbs from '../BreadCrumbs'; import CustomAvatar from '../Avatar'; @@ -11,8 +11,9 @@ import endorseIcon from '../../assets/endorser-card.svg'; import userCard from '../../assets/User_Card.svg'; import MemberList from './MemberList'; import { getEcosystem } from '../../api/ecosystem'; -import PopupModal from '../PopupModal'; import { EmptyListMessage } from '../EmptyListComponent'; +import CreateEcosystemOrgModal from '../CreateEcosystemOrgModal'; +import { AlertComponent } from '../AlertComponent'; const Dashboard = () => { const [ecosystemDetails, setEcosystemDetails] = useState() @@ -61,19 +62,14 @@ const Dashboard = () => {
    { (success || failure) && - { + { setSuccess(null) setFailure(null) }} - > - -

    - {success ?? failure} -

    -
    -
    + /> } { ecosystemDetails ? @@ -168,7 +164,7 @@ const Dashboard = () => { 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" >
    - { setSuccess(value) diff --git a/src/components/Verification/Verification.tsx b/src/components/Verification/Verification.tsx index 4340b96c5..6279c1a79 100644 --- a/src/components/Verification/Verification.tsx +++ b/src/components/Verification/Verification.tsx @@ -166,16 +166,12 @@ const VerificationCred = () => { if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { setProofReqSuccess(data?.message); setRequestLoader(false); - await clearLocalStorage() + clearLocalStorage() setTimeout(()=>{ window.location.href = '/organizations/verification' - - }, 5000) - - + }, 2000) } else { setErrMsg(response as string); - } } setTimeout(()=>{ diff --git a/src/components/organization/OrganizationsList.tsx b/src/components/organization/OrganizationsList.tsx index ed23f86ab..7736e68f9 100644 --- a/src/components/organization/OrganizationsList.tsx +++ b/src/components/organization/OrganizationsList.tsx @@ -1,6 +1,6 @@ 'use client'; -import {Button,Card ,Pagination } from 'flowbite-react'; +import { Card, Pagination } from 'flowbite-react'; import { ChangeEvent, useEffect, useState } from 'react'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; @@ -17,8 +17,7 @@ import { pathRoutes } from '../../config/pathRoutes'; import { setToLocalStorage } from '../../api/Auth'; import { EmptyListMessage } from '../EmptyListComponent'; import CustomSpinner from '../CustomSpinner'; -import React from 'react'; -import PopupModal from '../PopupModal'; +import CreateEcosystemOrgModal from '../CreateEcosystemOrgModal'; const initialPageState = { pageNumber: 1, @@ -71,7 +70,7 @@ const OrganizationsList = () => { total: totalPages }) } - else{ + else { setError(response as string) } @@ -114,12 +113,12 @@ const OrganizationsList = () => { const redirectOrgDashboard = async (activeOrg: Organisation) => { - await setToLocalStorage(storageKeys.ORG_ID, activeOrg.id.toString()); - const roles: string[] = activeOrg?.userOrgRoles.map(role => role.orgRole.name) - activeOrg.roles = roles + await setToLocalStorage(storageKeys.ORG_ID, activeOrg.id.toString()); + const roles: string[] = activeOrg?.userOrgRoles.map(role => role.orgRole.name) + activeOrg.roles = roles - await setToLocalStorage(storageKeys.ORG_ROLES, roles.toString()); - window.location.href = pathRoutes.organizations.dashboard + await setToLocalStorage(storageKeys.ORG_ROLES, roles.toString()); + window.location.href = pathRoutes.organizations.dashboard } @@ -151,10 +150,10 @@ const OrganizationsList = () => {
    } onClickEvent={createOrganizationModel} - /> + />
    - setMessage(data)} setOpenModal={ @@ -172,8 +171,8 @@ const OrganizationsList = () => { /> {loading - ?
    - + ?
    +
    : organizationsList && organizationsList?.length > 0 ? (
    { @@ -231,11 +230,11 @@ const OrganizationsList = () => {
    {organizationsList && organizationsList?.length > 0 && ( - + ) }
    diff --git a/src/config/ecosystem.ts b/src/config/ecosystem.ts index 22db593e8..2d7053f9f 100644 --- a/src/config/ecosystem.ts +++ b/src/config/ecosystem.ts @@ -1,12 +1,12 @@ import { EcosystemRoles } from "../common/enums" const isEnabledEcosystem = true -const ecosystemRole = EcosystemRoles.member +const ecosystemRole = EcosystemRoles.ecosystemMember const checkEcosystem = () => ({ isEnabledEcosystem, - isEcosystemMember: ecosystemRole === EcosystemRoles.member && isEnabledEcosystem, - isEcosystemLead: ecosystemRole === EcosystemRoles.lead && isEnabledEcosystem + isEcosystemMember: ecosystemRole === EcosystemRoles.ecosystemMember && isEnabledEcosystem, + isEcosystemLead: ecosystemRole === EcosystemRoles.ecosystemLead && isEnabledEcosystem }) export default checkEcosystem \ No newline at end of file From 2effdaff549497e6cfd792f390a86f451c1823b0 Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Fri, 6 Oct 2023 16:22:31 +0530 Subject: [PATCH 103/250] fix: sonarlint issues Signed-off-by: sanjay-k1910 --- .../CreateEcosystemOrgModal/index.tsx | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/CreateEcosystemOrgModal/index.tsx b/src/components/CreateEcosystemOrgModal/index.tsx index d8f6882f0..14c811c90 100644 --- a/src/components/CreateEcosystemOrgModal/index.tsx +++ b/src/components/CreateEcosystemOrgModal/index.tsx @@ -46,17 +46,17 @@ const CreateEcosystemOrgModal = (props: IProps) => { }) const [loading, setLoading] = useState(false) - const [initialOrgData, setOrgData] = useState({ + const [formData, setFormData] = useState({ name: '', description: '', }) - const [erroMsg, setErrMsg] = useState(null) + const [errMsg, setErrMsg] = useState(null) const [imgError, setImgError] = useState('') - const newinitialOrgData = initialOrgData + const initialFormData = formData useEffect(() => { - setOrgData({ + setFormData({ name: '', description: '', }) @@ -150,7 +150,9 @@ const CreateEcosystemOrgModal = (props: IProps) => { setLoading(false) if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { - props.setMessage && props.setMessage(data?.message) + if (props.setMessage) { + props.setMessage(data?.message) + } props.setOpenModal(false) } else { @@ -176,7 +178,9 @@ const CreateEcosystemOrgModal = (props: IProps) => { setLoading(false) if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { - props.setMessage && props.setMessage(data?.message) + if (props.setMessage) { + props.setMessage(data?.message) + } props.setOpenModal(false) } else { setErrMsg(resCreateEco as string) @@ -234,21 +238,21 @@ const CreateEcosystemOrgModal = (props: IProps) => { imagePreviewUrl: "", fileName: '' }) - setOrgData(newinitialOrgData) + setFormData(initialFormData) props.setOpenModal(false) } }> Create {popupName} { setErrMsg(null) }} /> Date: Fri, 6 Oct 2023 16:29:08 +0530 Subject: [PATCH 104/250] refactor: added condition for roles Signed-off-by: sanjay-k1910 --- src/components/Ecosystem/Dashboard.tsx | 106 ++++++++++++++----------- src/config/ecosystem.ts | 2 +- 2 files changed, 60 insertions(+), 48 deletions(-) diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index d43951569..61d2e2ad0 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -14,6 +14,7 @@ import { getEcosystem } from '../../api/ecosystem'; import { EmptyListMessage } from '../EmptyListComponent'; import CreateEcosystemOrgModal from '../CreateEcosystemOrgModal'; import { AlertComponent } from '../AlertComponent'; +import checkEcosystem from '../../config/ecosystem'; const Dashboard = () => { const [ecosystemDetails, setEcosystemDetails] = useState() @@ -55,6 +56,8 @@ const Dashboard = () => { fetchEcosystemDetails() }, []) + const { isEcosystemLead } = checkEcosystem() + return (
    @@ -97,61 +100,70 @@ const Dashboard = () => { }
    -
    - -
    - + { + isEcosystemLead && +
    + +
    + +
    -
    + }
    -
    -
    + { + isEcosystemLead && + <>
    -
    -

    - Member -

    - 23 - +
    +
    +
    +

    + Member +

    + 23 + +
    +
    + +
    +
    +

    + Endorsements +

    + + 598 + +
    +
    - -
    -
    -

    - Endorsements -

    - - 598 - -
    +
    +
    -
    -
    -
    - -
    + + } +
    :
    { diff --git a/src/config/ecosystem.ts b/src/config/ecosystem.ts index 2d7053f9f..3b5c2654c 100644 --- a/src/config/ecosystem.ts +++ b/src/config/ecosystem.ts @@ -1,7 +1,7 @@ import { EcosystemRoles } from "../common/enums" const isEnabledEcosystem = true -const ecosystemRole = EcosystemRoles.ecosystemMember +const ecosystemRole = EcosystemRoles.ecosystemLead const checkEcosystem = () => ({ isEnabledEcosystem, From d9d28d4856fd83bd5ae714bb75362b45c4c062dd Mon Sep 17 00:00:00 2001 From: karan Date: Fri, 6 Oct 2023 17:06:41 +0530 Subject: [PATCH 105/250] feat: ecosystem invitation Signed-off-by: karan --- src/api/invitations.ts | 81 +++++ .../{index.tsx => EcoSystemInvitation.tsx} | 84 +++-- .../EcoSystemReceivedInvitations.tsx | 328 ++++++++++++++++++ .../EcosystemInvite/SentInvitations.tsx | 317 +++++++++++++++++ src/components/organization/OrgDropDown.tsx | 7 + .../organization/interfaces/invitations.ts | 3 +- .../invitations/ReceivedInvitations.tsx | 4 +- .../invitations/SendInvitationModal.tsx | 33 +- src/config/apiRoutes.ts | 4 + src/pages/ecosystem/ecosysteminvite.astro | 14 +- src/pages/ecosystem/invitation.astro | 20 ++ src/pages/ecosystem/sent-invitations.astro | 20 ++ 12 files changed, 866 insertions(+), 49 deletions(-) rename src/components/EcosystemInvite/{index.tsx => EcoSystemInvitation.tsx} (88%) create mode 100644 src/components/EcosystemInvite/EcoSystemReceivedInvitations.tsx create mode 100644 src/components/EcosystemInvite/SentInvitations.tsx create mode 100644 src/pages/ecosystem/invitation.astro create mode 100644 src/pages/ecosystem/sent-invitations.astro diff --git a/src/api/invitations.ts b/src/api/invitations.ts index ee2af5f76..e893926a8 100644 --- a/src/api/invitations.ts +++ b/src/api/invitations.ts @@ -68,6 +68,61 @@ export const createInvitations = async (invitationList: Array) => { } } +export const getEcosystemList = async () => { + + const url = `${apiRoutes.ecosystem.root}` + + const token = await getFromLocalStorage(storageKeys.TOKEN) + + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + } + const axiosPayload = { + url, + config + } + + try { + return await axiosGet(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} +export const createEcoSystemInvitations = async (invitationList: Array) => { + + // const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.organizations.invitations}` + const url = `${apiRoutes.ecosystem.root}/2139b71b-ea35-4835-a912-09eea0e95344${apiRoutes.organizations.invitations}` + + const payload = { + invitations: invitationList, + } + const token = await getFromLocalStorage(storageKeys.TOKEN) + + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + } + const axiosPayload = { + url, + payload, + config + } + + try { + return await axiosPost(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} // Received Invitations by User export const getUserInvitations = async (pageNumber: number, pageSize: number, search = '') => { @@ -95,6 +150,32 @@ export const getUserInvitations = async (pageNumber: number, pageSize: number, s } } +export const getEcosystemInvitations = async (pageNumber: number, pageSize: number, search:string) => { + + const url = `${apiRoutes.ecosystem.root}/2139b71b-ea35-4835-a912-09eea0e95344${apiRoutes.ecosystem.invitations}` + + const token = await getFromLocalStorage(storageKeys.TOKEN) + + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + } + const axiosPayload = { + url, + config + } + + try { + return await axiosGet(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} + // Accept/ Reject Invitations export const acceptRejectInvitations = async (invitationId: number,orgId: number, status: string) => { diff --git a/src/components/EcosystemInvite/index.tsx b/src/components/EcosystemInvite/EcoSystemInvitation.tsx similarity index 88% rename from src/components/EcosystemInvite/index.tsx rename to src/components/EcosystemInvite/EcoSystemInvitation.tsx index 55107a371..39ecf1cbb 100644 --- a/src/components/EcosystemInvite/index.tsx +++ b/src/components/EcosystemInvite/EcoSystemInvitation.tsx @@ -2,18 +2,18 @@ import { ChangeEvent, useEffect, useState } from 'react'; import { apiStatusCodes } from '../../config/CommonConstant'; - +import axios from 'axios'; import { AlertComponent } from '../AlertComponent'; import type { AxiosResponse } from 'axios'; import { EmptyListMessage } from '../EmptyListComponent'; import { Features } from '../../utils/enums/features'; -import type { Invitation } from '../../components/organization/interfaces/invitations'; +import type { Invitation } from '../organization/interfaces/invitations'; import type { OrgRole } from '../organization/interfaces'; import { Card, Pagination } from 'flowbite-react'; -import RoleViewButton from '../../components/RoleViewButton'; -import SendInvitationModal from '../../components/organization/invitations/SendInvitationModal'; +import RoleViewButton from '../RoleViewButton'; +import SendInvitationModal from '../organization/invitations/SendInvitationModal'; import { TextTittlecase } from '../../utils/TextTransform'; -import { getOrganizationInvitations } from '../../api/invitations'; +import { getEcosystemList, getOrganizationInvitations } from '../../api/invitations'; import CustomSpinner from '../CustomSpinner'; import { dateConversion } from '../../utils/DateConversion'; import DateTooltip from '../Tooltip'; @@ -36,7 +36,7 @@ const header = [ ]; -const Invitations = () => { +const Ecosysteminvitation = () => { const [openModal, setOpenModal] = useState(false); const [loading, setLoading] = useState(false) const [message, setMessage] = useState(null) @@ -55,33 +55,35 @@ const Invitations = () => { const [invitationsList, setInvitationsList] = useState | null>(null) const props = { openModal, setOpenModal }; +console.log("invitationsList",invitationsList); //Fetch the user organization list - // const getAllInvitations = async () => { - // setLoading(true) + const getAllEcosystem = async () => { + setLoading(true) - // const response = await getOrganizationInvitations(currentPage.pageNumber, currentPage.pageSize, searchText); - // const { data } = response as AxiosResponse + const response = await getEcosystemList(); + const { data } = response as AxiosResponse +console.log("data",data); - // setLoading(false) + setLoading(false) - // if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - // const totalPages = data?.data?.totalPages; + // const totalPages = data?.data?.totalPages; - // const invitationList = data?.data?.invitations + const invitationList = data?.data - // setInvitationsList(invitationList) - // setCurrentPage({ - // ...currentPage, - // total: totalPages - // }) - // } - // else { - // setError(response as string) + setInvitationsList(invitationList) + // setCurrentPage({ + // ...currentPage, + // total: totalPages + // }) + } + else { + setError(response as string) - // } - // } + } + } const credentialList = [ { data:[ { data: "Master Card" }, @@ -125,12 +127,26 @@ const Invitations = () => { props.setOpenModal(true) } let name="Karan tompe" - +useEffect(()=>{ + getAllEcosystem() + + },[]) return (
    + { + setMessage(null) + setError(null) + }} + />
    @@ -167,7 +183,7 @@ let name="Karan tompe" } onClickEvent={createInvitationsModel} - /> + /> + +
    +
    + +
    + +
    +
    + + ))} + +
    + + ) : ( + invitationsList && ( + + ) + )} + +
    + +
    + + + + ); +}; + +export default ReceivedInvitations; diff --git a/src/components/EcosystemInvite/SentInvitations.tsx b/src/components/EcosystemInvite/SentInvitations.tsx new file mode 100644 index 000000000..570bd131a --- /dev/null +++ b/src/components/EcosystemInvite/SentInvitations.tsx @@ -0,0 +1,317 @@ +import { Button, Pagination } from 'flowbite-react'; +import { ChangeEvent, useEffect, useState } from 'react'; +import { + acceptRejectInvitations, + getEcosystemInvitations, + getUserInvitations, +} from '../../api/invitations'; + +import { AlertComponent } from '../AlertComponent'; +import type { AxiosResponse } from 'axios'; +import BreadCrumbs from '../BreadCrumbs'; +import type { Invitation } from '../organization/interfaces/invitations'; +import type { OrgRole } from '../organization/interfaces'; +import SendInvitationModal from '../organization/invitations/SendInvitationModal'; +import { apiStatusCodes } from '../../config/CommonConstant'; +import { pathRoutes } from '../../config/pathRoutes'; +import { EmptyListMessage } from '../EmptyListComponent'; +import CustomSpinner from '../CustomSpinner'; + +const initialPageState = { + pageNumber: 1, + pageSize: 10, + total: 0, +}; + +const SentInvitations = () => { + const [openModal, setOpenModal] = useState(false); + const [loading, setLoading] = useState(false); + const [message, setMessage] = useState(null); + const [error, setError] = useState(null); + + const [currentPage, setCurrentPage] = useState(initialPageState); + const timestamp = Date.now(); + // "bcdbaed0-48e7-4394-8249-6584de1fb031" + const onPageChange = (page: number) => { + setCurrentPage({ + ...currentPage, + pageNumber: page, + }); + }; + const [searchText, setSearchText] = useState(''); + + const [invitationsList, setInvitationsList] = + useState | null>(null); + console.log('invitationsList1111111111', invitationsList); + + const props = { openModal, setOpenModal }; + + //Fetch the user organization list + const getAllSentInvitations = async () => { + setLoading(true); + const response = await getEcosystemInvitations( + currentPage.pageNumber, + currentPage.pageSize, + searchText, + ); + const { data } = response as AxiosResponse; +console.log("11111111111",data); + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + const totalPages = data?.data?.totalPages; + + const invitationList = data?.data?.invitations; + + setInvitationsList(invitationList); + setCurrentPage({ + ...currentPage, + total: totalPages, + }); + } else { + setError(response as string); + } + + setLoading(false); + }; + + //This useEffect is called when the searchText changes + useEffect(() => { + let getData: NodeJS.Timeout; + + if (searchText.length >= 1) { + getData = setTimeout(() => { + getAllSentInvitations(); + }, 1000); + } else { + getAllSentInvitations(); + } + + return () => clearTimeout(getData); + }, [searchText, openModal, currentPage.pageNumber]); + + //onChange of Search input text + const searchInputChange = (e: ChangeEvent) => { + setSearchText(e.target.value); + }; + + // const respondToInvitations = async (invite: Invitation, status: string) => { + // setLoading(true); + // const response = await acceptRejectInvitations( + // invite.id, + // invite.orgId, + // status, + // ); + // const { data } = response as AxiosResponse; + // if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + // setMessage(data?.message); + // setLoading(false); + // window.location.href = pathRoutes.organizations.root; + // } else { + // setError(response as string); + // setLoading(false); + // } + // }; + const [selectedId, setSelectedId] = useState('1'); // Initialize the selected ID state + + const handleDropdownChange = (e: { target: { value: any } }) => { + const value = e.target.value; + setSelectedId(value); + // sendToApi(value); // Call the function to send data to the API + }; + + return ( +
    +
    + + +
    +
    +
    + {/* setMessage(data)} + setOpenModal={props.setOpenModal} + /> */} +

    + Sent Ecosystem Invitations +

    + + { + setMessage(null); + setError(null); + }} + /> + + {loading ? ( +
    + +
    + ) : invitationsList && invitationsList?.length > 0 ? ( +
    +
    +
      + {invitationsList.map((invitation) => ( +
    • +
      +
      +
      + + + + + + + + + + + + + + + +
      +

      + {invitation.email} +

      + +
      +
        +
      • +
        +
        + Roles: + Ecosystem Member + {/* {role.name + .charAt(0) + .toUpperCase() + + role.name.slice(1)} */} + + {invitation.orgRoles && + invitation.orgRoles.length > 0 && + invitation.orgRoles.map( + (role: OrgRole, index: number) => { + return ( + + Ecosystem Member + {/* {role.name + .charAt(0) + .toUpperCase() + + role.name.slice(1)} */} + + ); + }, + )} +
        +
        +
      • +
      +
      + {/*

      + Received On: {dateConversion(invitation.createDateTime)} +

      */} +
      +
      + +
      + +
      +
      + +
      + Status: + + Pending + +
      +
      +
    • + ))} +
    +
    +
    + ) : ( + invitationsList && ( + + ) + )} + +
    + +
    +
    +
    +
    + ); +}; + +export default SentInvitations; diff --git a/src/components/organization/OrgDropDown.tsx b/src/components/organization/OrgDropDown.tsx index 740fef4f0..04f4f8f55 100644 --- a/src/components/organization/OrgDropDown.tsx +++ b/src/components/organization/OrgDropDown.tsx @@ -12,6 +12,9 @@ import { pathRoutes } from '../../config/pathRoutes'; const OrgDropDown = () => { const [orgList, setOrgList] = useState([]); const [activeOrg, setactiveOrg] = useState(null) + console.log("activeOrg",orgList); + +console.log("activeOrg",activeOrg?.id); useEffect(() => { getAllorgs() @@ -45,8 +48,12 @@ const OrgDropDown = () => { let activeOrg: Organisation | null = null const orgId = await getFromLocalStorage(storageKeys.ORG_ID) + console.log("activeOrgfindID",orgId); + if (orgId) { activeOrg = organizations?.find(org => org.id === Number(orgId)) as Organisation + console.log("activeOrgfind",activeOrg); + setactiveOrg(activeOrg || null) } else { activeOrg = organizations && organizations[0] diff --git a/src/components/organization/interfaces/invitations.ts b/src/components/organization/interfaces/invitations.ts index 4378939ab..45da32baf 100644 --- a/src/components/organization/interfaces/invitations.ts +++ b/src/components/organization/interfaces/invitations.ts @@ -1,6 +1,7 @@ import type { OrgRole, Organisation } from "." export interface Invitation { + ecosystem: any id: number createDateTime: string createdBy: number @@ -13,4 +14,4 @@ export interface Invitation { orgRoles: OrgRole[] email: string organisation: Organisation -} \ No newline at end of file +} diff --git a/src/components/organization/invitations/ReceivedInvitations.tsx b/src/components/organization/invitations/ReceivedInvitations.tsx index 8cb2984dc..856910f72 100644 --- a/src/components/organization/invitations/ReceivedInvitations.tsx +++ b/src/components/organization/invitations/ReceivedInvitations.tsx @@ -135,8 +135,8 @@ const ReceivedInvitations = () => { } /> { setMessage(null) setError(null) diff --git a/src/components/organization/invitations/SendInvitationModal.tsx b/src/components/organization/invitations/SendInvitationModal.tsx index a66b17410..611e8034a 100644 --- a/src/components/organization/invitations/SendInvitationModal.tsx +++ b/src/components/organization/invitations/SendInvitationModal.tsx @@ -7,8 +7,9 @@ import { useEffect, useRef, useState } from "react"; import { AlertComponent } from "../../AlertComponent"; import type { AxiosResponse } from 'axios'; import { apiStatusCodes } from "../../../config/CommonConstant"; -import { createInvitations } from "../../../api/invitations"; +import { createEcoSystemInvitations, createInvitations } from "../../../api/invitations"; import { getOrganizationRoles } from "../../../api/organization"; +import axios from "axios"; interface Values { email: string; @@ -27,7 +28,7 @@ interface RoleI { } -const SendInvitationModal = (props: { openModal: boolean; setMessage: (message: string) => void; setOpenModal: (flag: boolean) => void }) => { +const SendInvitationModal = (props: {flag:boolean; openModal: boolean; setMessage: (message: string) => void; setOpenModal: (flag: boolean) => void }) => { const [loading, setLoading] = useState(false) @@ -113,6 +114,32 @@ const SendInvitationModal = (props: { openModal: boolean; setMessage: (message: } + + const sendEcoSystemInvitations = async () => { + + setLoading(true) + + const invitationPayload = invitations.map(invitation => { + return { + email: invitation.email, + } + }) + console.log("hhhhhhhhhhhhhhhhhhhhhhhhhhhh",invitationPayload); + + const resCreateOrg = await createEcoSystemInvitations(invitationPayload) + + const { data } = resCreateOrg as AxiosResponse + + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + props.setMessage(data?.message) + props.setOpenModal(false) + + } else { + setErrMsg(resCreateOrg as string) + } + setLoading(false) + + } return ( + + + + + ) : ( +
    + + +
    + ) } + + +
    + ); +}; + +export default EndorsementPopup; \ No newline at end of file From 42af753a80406df0cfd992a189c7d235f432379d Mon Sep 17 00:00:00 2001 From: MoulikaKulkarni Date: Fri, 6 Oct 2023 19:04:54 +0530 Subject: [PATCH 107/250] feat: endorsement popups Signed-off-by: MoulikaKulkarni --- .../Ecosystems/EndorsementPopup.tsx | 105 +++++------------- 1 file changed, 27 insertions(+), 78 deletions(-) diff --git a/src/components/Ecosystems/EndorsementPopup.tsx b/src/components/Ecosystems/EndorsementPopup.tsx index 562390d88..35622fb0c 100644 --- a/src/components/Ecosystems/EndorsementPopup.tsx +++ b/src/components/Ecosystems/EndorsementPopup.tsx @@ -90,77 +90,6 @@ const EndorsementPopup = (props: { ) } - - {/* - -
    - {props.name && -

    - {props.name} -

    - } - {props.version && -

    - Version: {props.version} -

    - } - - - {props.tag && -

    - ID: {props.tag} -

    - } - -

    - Schema ID: {props.id} -

    - - {props.authorDID && -

    - Author DID: {props.authorDID} -

    - } -

    - Ledger: {props.ledger} -

    - - {props.ecosystemRole=== EcosystemRoles.lead && -

    - Org. Name: {props.organizationName} -

    - } - - {props.attrNames && -

    - Attributes: - {props.attrNames && - props.attrNames.length > 0 && - props.attrNames.map((element: string) => ( - - {element} - - ))} -

    - } - - {props.endorsementType===RequestedType.credDef && -
    - Revocable: -
    - {props.revocable ? 'Yes' : 'No'} -
    -
    - } -
    -
    */} -
    {props.endorsementType === RequestedType.schema ? ( @@ -174,8 +103,7 @@ const EndorsementPopup = (props: { - {/* display: flex padding: 12px align-items: flex-start gap: 12px border-radius: 8px border: 1px solid #1F4EAD; */} - + Reject @@ -197,12 +125,33 @@ const EndorsementPopup = (props: {
    ) : (
    - - + + +
    ) }
    From 70c165e4111ec83feeb832f8a31d8081ba85d000 Mon Sep 17 00:00:00 2001 From: MoulikaKulkarni Date: Fri, 6 Oct 2023 19:34:51 +0530 Subject: [PATCH 108/250] feat: endorsement popups Signed-off-by: MoulikaKulkarni --- src/commonComponents/SchemaCard.tsx | 2 +- .../Ecosystems/EndorsementPopup.tsx | 22 +++---------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/commonComponents/SchemaCard.tsx b/src/commonComponents/SchemaCard.tsx index 62e90154f..e8d9516cc 100644 --- a/src/commonComponents/SchemaCard.tsx +++ b/src/commonComponents/SchemaCard.tsx @@ -2,7 +2,7 @@ import { Card } from 'flowbite-react'; import { dateConversion } from '../utils/DateConversion'; import DateTooltip from '../components/Tooltip'; -const SchemaCard = (props: {className?:string, schemaName: string, version: string, schemaId: string, issuerDid: string, attributes: [], created: string, onClickCallback: (schemaId: string, attributes: string[], issuerDid:string, created:string) => void; isLarge:boolean}) => { +const SchemaCard = (props: {schemaName: string, version: string, schemaId: string, issuerDid: string, attributes: [], created: string, onClickCallback: (schemaId: string, attributes: string[], issuerDid:string, created:string) => void; isLarge:boolean}) => { return ( { props.onClickCallback(props.schemaId, props.attributes, props.issuerDid, props.created) diff --git a/src/components/Ecosystems/EndorsementPopup.tsx b/src/components/Ecosystems/EndorsementPopup.tsx index 35622fb0c..737d6eae9 100644 --- a/src/components/Ecosystems/EndorsementPopup.tsx +++ b/src/components/Ecosystems/EndorsementPopup.tsx @@ -1,12 +1,7 @@ -import { Button, Card, Modal } from 'flowbite-react'; +import { Button,Modal } from 'flowbite-react'; import React from 'react'; -import { pathRoutes } from '../../config/pathRoutes'; import { EcosystemRoles, RequestedType } from '../../common/enums'; import SchemaCard from '../../commonComponents/SchemaCard'; -import DateTooltip from '../Tooltip'; -import { dateConversion } from '../../utils/DateConversion'; -import { date } from 'yup'; -import checkEcosystem from './EcosystemRoles'; const EndorsementPopup = (props: { openModal: boolean; @@ -20,19 +15,10 @@ const EndorsementPopup = (props: { revocable: boolean; endorsementType: RequestedType; organizationName: string; - tag: string; ecosystemRole: EcosystemRoles; - ledger: string; attrNames: []; created: string; }) => { - const schemaCallback = (schemaId: string) => { - window.location.href = `${pathRoutes.ecosystems.schema}`; - }; - const credDefCallback = (schemaId: string, credentialDefinitionId: string) => { - window.location.href = `${pathRoutes.ecosystems.credDef}`; - }; - return ( @@ -49,7 +35,6 @@ const EndorsementPopup = (props: { - {/* {props.endorsementType=== RequestedType.schema} */} } - {props.endorsementType=== RequestedType.credDef ? (
    @@ -115,7 +99,7 @@ const EndorsementPopup = (props: { fill="none" viewBox="0 0 24 24" stroke="currentColor"> - + Accept @@ -132,7 +116,7 @@ const EndorsementPopup = (props: { fill="none" viewBox="0 0 24 24" stroke="currentColor"> - + Signed From dfb80987b471cc46a7196e7c4c762c7ee1bd7896 Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Fri, 6 Oct 2023 20:41:19 +0530 Subject: [PATCH 109/250] fix: dark mode issue and api endpoint for ecosystem Signed-off-by: sanjay-k1910 --- src/api/ecosystem.ts | 68 ++++++++++++++++-- src/api/ecosystems.ts | 70 ------------------- src/app/SideBar.astro | 2 +- .../CreateEcosystemOrgModal/index.tsx | 2 +- 4 files changed, 66 insertions(+), 76 deletions(-) delete mode 100644 src/api/ecosystems.ts diff --git a/src/api/ecosystem.ts b/src/api/ecosystem.ts index 7a49d1ff3..c08b1266a 100644 --- a/src/api/ecosystem.ts +++ b/src/api/ecosystem.ts @@ -1,15 +1,75 @@ -import { axiosGet } from "../services/apiRequests" - +import { axiosGet, axiosPost, axiosPut } from "../services/apiRequests" import { apiRoutes } from "../config/apiRoutes"; import { getFromLocalStorage } from "./Auth"; import { storageKeys } from "../config/CommonConstant"; -export const getEcosystem = async () => { +interface DataPayload { + name: string + description: string + logo: string + tags: string + userId: number +} + - const url = `${apiRoutes.Ecosystem.root}` +export const createEcosystems = async (dataPayload: DataPayload) => { + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); + + const url = `${apiRoutes.Ecosystem.root}/${orgId}` + const payload = dataPayload + + const token = await getFromLocalStorage(storageKeys.TOKEN) + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + } + const axiosPayload = { + url, + payload, + config + } + + try { + return await axiosPost(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} +export const updateEcosystem = async (data: object) => { + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); + const url = `${apiRoutes.Ecosystem.root}/${orgId}` + const payload = data const token = await getFromLocalStorage(storageKeys.TOKEN) + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + } + const axiosPayload = { + url, + payload, + config + } + + try { + return await axiosPut(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} +export const getEcosystem = async () => { + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); + const url = `${apiRoutes.Ecosystem.root}/${orgId}` + const token = await getFromLocalStorage(storageKeys.TOKEN) const config = { headers: { 'Content-Type': 'application/json', diff --git a/src/api/ecosystems.ts b/src/api/ecosystems.ts deleted file mode 100644 index 382401d6c..000000000 --- a/src/api/ecosystems.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { axiosPost, axiosPut } from "../services/apiRequests" -import { apiRoutes } from "../config/apiRoutes"; -import { getFromLocalStorage } from "./Auth"; -import { storageKeys } from "../config/CommonConstant"; - -interface DataPayload { - name: string - description: string - logo: string - tags: string - orgId: number - userId: number -} - -export const createEcosystems = async (dataPayload: DataPayload) => { - const url = apiRoutes.Ecosystem.root - const payload = dataPayload - const token = await getFromLocalStorage(storageKeys.TOKEN) - - const config = { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - } - } - const axiosPayload = { - url, - payload, - config - } - - try { - return await axiosPost(axiosPayload); - } - catch (error) { - const err = error as Error - return err?.message - } -} - -export const updateEcosystem = async (data: object, orgId: string) => { - - const url = `${apiRoutes.organizations.update}/${orgId}` - const payload = data - const token = await getFromLocalStorage(storageKeys.TOKEN) - - const config = { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - } - } - const axiosPayload = { - url, - payload, - config - } - - try { - return await axiosPut(axiosPayload); - } - catch (error) { - const err = error as Error - return err?.message - } -} - - - - diff --git a/src/app/SideBar.astro b/src/app/SideBar.astro index 6342b804a..e633df0db 100644 --- a/src/app/SideBar.astro +++ b/src/app/SideBar.astro @@ -822,7 +822,7 @@ import { pathRoutes } from '../config/pathRoutes';
    diff --git a/src/components/CreateEcosystemOrgModal/index.tsx b/src/components/CreateEcosystemOrgModal/index.tsx index 14c811c90..91a90dd4d 100644 --- a/src/components/CreateEcosystemOrgModal/index.tsx +++ b/src/components/CreateEcosystemOrgModal/index.tsx @@ -12,7 +12,7 @@ import type { AxiosResponse } from 'axios'; import { asset } from '../../lib/data.js'; import { createOrganization } from "../../api/organization"; import { getFromLocalStorage } from "../../api/Auth"; -import { createEcosystems } from "../../api/ecosystems"; +import { createEcosystems } from "../../api/ecosystem"; interface Values { From 1955ec9ab13922473adc07366c0b37f6623b917a Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Fri, 6 Oct 2023 21:01:59 +0530 Subject: [PATCH 110/250] fix: ecosystem issue Signed-off-by: sanjay-k1910 --- src/components/Ecosystem/Dashboard.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index 61d2e2ad0..277667cb4 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -40,12 +40,14 @@ const Dashboard = () => { const { data } = response as AxiosResponse if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const ecosystemData = data?.data[0] - setEcosystemDetails({ - logoUrl: ecosystemData.logoUrl, - name: ecosystemData.name, - description: ecosystemData.description - }) + if (data?.data.length > 0) { + const ecosystemData = data?.data[0] + setEcosystemDetails({ + logoUrl: ecosystemData.logoUrl, + name: ecosystemData.name, + description: ecosystemData.description + }) + } } else { setFailure(response as string) } From 411599af7457de1cb56a71957b41cc0e35c0fd52 Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Sat, 7 Oct 2023 11:32:07 +0530 Subject: [PATCH 111/250] refactor: added endorsement request apis and implemented confirmpopup custom component Signed-off-by: sanjay-k1910 --- src/api/ecosystem.ts | 111 ++++++++--- src/commonComponents/ConfirmPopup.tsx | 88 +++++++++ src/commonComponents/SchemaCard.tsx | 2 +- src/components/Ecosystem/Dashboard.tsx | 6 +- .../Ecosystem/Endorsement/index.tsx | 87 ++++---- src/components/Resources/Schema/Create.tsx | 186 ++++++++---------- .../Resources/Schema/ViewSchema.tsx | 24 ++- src/config/apiRoutes.ts | 12 +- src/config/ecosystem.ts | 2 +- tailwind.config.cjs | 3 + 10 files changed, 341 insertions(+), 180 deletions(-) create mode 100644 src/commonComponents/ConfirmPopup.tsx diff --git a/src/api/ecosystem.ts b/src/api/ecosystem.ts index c08b1266a..3960c0235 100644 --- a/src/api/ecosystem.ts +++ b/src/api/ecosystem.ts @@ -1,7 +1,9 @@ import { axiosGet, axiosPost, axiosPut } from "../services/apiRequests" + import { apiRoutes } from "../config/apiRoutes"; import { getFromLocalStorage } from "./Auth"; import { storageKeys } from "../config/CommonConstant"; +import { getHeaderConfigs } from "../config/GetHeaderConfigs"; interface DataPayload { name: string @@ -17,18 +19,10 @@ export const createEcosystems = async (dataPayload: DataPayload) => { const url = `${apiRoutes.Ecosystem.root}/${orgId}` const payload = dataPayload - - const token = await getFromLocalStorage(storageKeys.TOKEN) - const config = { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - } - } const axiosPayload = { url, payload, - config + config: await getHeaderConfigs() } try { @@ -44,17 +38,10 @@ export const updateEcosystem = async (data: object) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); const url = `${apiRoutes.Ecosystem.root}/${orgId}` const payload = data - const token = await getFromLocalStorage(storageKeys.TOKEN) - const config = { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - } - } const axiosPayload = { url, payload, - config + config: await getHeaderConfigs() } try { @@ -69,16 +56,28 @@ export const updateEcosystem = async (data: object) => { export const getEcosystem = async () => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); const url = `${apiRoutes.Ecosystem.root}/${orgId}` - const token = await getFromLocalStorage(storageKeys.TOKEN) - const config = { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - } + + const axiosPayload = { + url, + config: await getHeaderConfigs() } + + try { + return await axiosGet(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} + +export const getEndorsementList = async () => { + + const url = `${apiRoutes.Ecosystem.endorsements.list}` + const axiosPayload = { url, - config + config: await getHeaderConfigs() } try { @@ -88,4 +87,68 @@ export const getEcosystem = async () => { const err = error as Error return err?.message } +} + +export const createSchemaRequest = async (data: object, orgId: number) => { + + const url = `${apiRoutes.Ecosystem.root}/${orgId}${apiRoutes.Ecosystem.endorsements.createSchemaRequest}` + const payload = data + const axiosPayload = { + url, + payload, + config: await getHeaderConfigs() + } + + try { + return await axiosPost(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} + +export const createCredDefRequest = async (data: object, orgId: number) => { + + const url = `${apiRoutes.Ecosystem.root}/${orgId}${apiRoutes.Ecosystem.endorsements.createCredDefRequest}` + const payload = data + const axiosPayload = { + url, + payload, + config: await getHeaderConfigs() + } + + try { + return await axiosPost(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } +} + +export const editOrganizationUserRole = async (userId: number, roles: number[]) => { + + const orgId = await getFromLocalStorage(storageKeys.ORG_ID) + + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.organizations.editUserROle}/${userId}` + const payload = { + orgId, + userId, + orgRoleId: roles + } + + const axiosPayload = { + url, + payload, + config: await getHeaderConfigs() + } + + try { + return axiosPut(axiosPayload); + } + catch (error) { + const err = error as Error + return err?.message + } } \ No newline at end of file diff --git a/src/commonComponents/ConfirmPopup.tsx b/src/commonComponents/ConfirmPopup.tsx new file mode 100644 index 000000000..b4e3f83a3 --- /dev/null +++ b/src/commonComponents/ConfirmPopup.tsx @@ -0,0 +1,88 @@ +import { Button, Modal } from 'flowbite-react'; + +interface IProps { + openModal: boolean; + closeModal: (flag: boolean) => void; + onSuccess: (flag: boolean) => void; + message: string + isProcessing: boolean +} + +const ConfirmModal = (props: IProps) => { + return ( + +
    +
    + +
    + +

    + {props.message} +

    + + +
    +
    +
    +
    + ); +}; + +export default ConfirmModal; \ No newline at end of file diff --git a/src/commonComponents/SchemaCard.tsx b/src/commonComponents/SchemaCard.tsx index 977b82e19..b99e63985 100644 --- a/src/commonComponents/SchemaCard.tsx +++ b/src/commonComponents/SchemaCard.tsx @@ -71,7 +71,7 @@ const SchemaCard = (props: IProps) => { if (enableAction) { props.onClickCallback(props.schemaId, props.attributes, props.issuerDid, props.created) } - }} className={`transform transition duration-500 hover:scale-105 hover:bg-gray-50 min-h-[260px] overflow-auto w-full h-full ${enableAction ? "cursor-pointer" : "cursor-not-allowed"}`}> + }} className={`transform transition duration-500 hover:scale-103 hover:bg-gray-50 min-h-[260px] overflow-auto w-full h-full ${enableAction ? "cursor-pointer" : "cursor-not-allowed"}`}>
    diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index 277667cb4..064f685a7 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -53,7 +53,7 @@ const Dashboard = () => { } setLoading(false) } - + useEffect(() => { fetchEcosystemDetails() }, []) @@ -133,7 +133,7 @@ const Dashboard = () => { className="grid w-full grid-cols-1 gap-4 mt-0 md:grid-cols-2 xl:grid-cols-2 2xl:grid-cols-2" >

    @@ -147,7 +147,7 @@ const Dashboard = () => {

    diff --git a/src/components/Ecosystem/Endorsement/index.tsx b/src/components/Ecosystem/Endorsement/index.tsx index 2c2ffe3ac..5bc02dfa6 100644 --- a/src/components/Ecosystem/Endorsement/index.tsx +++ b/src/components/Ecosystem/Endorsement/index.tsx @@ -27,7 +27,7 @@ const EndorsementList = () => { const [loading, setLoading] = useState(true) const [allSchemaFlag, setAllSchemaFlag] = useState(false) const [orgId, setOrgId] = useState('') - const [schemaListAPIParameter, setSchemaListAPIParameter] = useState({ + const [endorsementListAPIParameter, setEndorsementListAPIParameter] = useState({ itemPerPage: 9, page: 1, search: "", @@ -37,16 +37,16 @@ const EndorsementList = () => { }) const [walletStatus, setWalletStatus] = useState(false) const [totalItem, setTotalItem] = useState(0) - const getSchemaList = async (schemaListAPIParameter: GetAllSchemaListParameter, flag: boolean) => { + const getEndorsementList = async (endorsementListAPIParameter: GetAllSchemaListParameter, flag: boolean) => { try { const organizationId = await getFromLocalStorage(storageKeys.ORG_ID); setOrgId(organizationId); setLoading(true); let schemaList if (allSchemaFlag) { - schemaList = await getAllSchemas(schemaListAPIParameter); + schemaList = await getAllSchemas(endorsementListAPIParameter); } else { - schemaList = await getAllSchemasByOrgId(schemaListAPIParameter, organizationId); + schemaList = await getAllSchemasByOrgId(endorsementListAPIParameter, organizationId); } const { data } = schemaList as AxiosResponse; if (schemaList === 'Schema records not found') { @@ -84,20 +84,20 @@ const EndorsementList = () => { }; useEffect(() => { - getSchemaList(schemaListAPIParameter, false) + getEndorsementList(endorsementListAPIParameter, false) - }, [schemaListAPIParameter, allSchemaFlag]) + }, [endorsementListAPIParameter, allSchemaFlag]) const onSearch = async (event: ChangeEvent): Promise => { event.preventDefault() - getSchemaList({ - ...schemaListAPIParameter, + getEndorsementList({ + ...endorsementListAPIParameter, search: event.target.value }, false) if (allSchemaFlag) { - getSchemaList({ - ...schemaListAPIParameter, + getEndorsementList({ + ...endorsementListAPIParameter, allSearch: event.target.value }, false) } @@ -123,7 +123,7 @@ const EndorsementList = () => { } else { setAllSchemaFlag(false) - getSchemaList(schemaListAPIParameter, false) + getEndorsementList(endorsementListAPIParameter, false) } }; @@ -210,47 +210,48 @@ const EndorsementList = () => { ))}

    - {schemaList.length > 0 && ( { - setSchemaListAPIParameter(prevState => ({ + setEndorsementListAPIParameter(prevState => ({ ...prevState, page: page })); }} - totalPages={Math.ceil(totalItem / schemaListAPIParameter?.itemPerPage)} + totalPages={Math.ceil(totalItem / endorsementListAPIParameter?.itemPerPage)} />)}
    -
    ) : ( -
    - {walletStatus ? - - - } - onClick={() => { - window.location.href = `${pathRoutes.organizations.createSchema}?OrgId=${orgId}` - }} - /> - : - - - } - onClick={() => { - window.location.href = `${pathRoutes.organizations.dashboard}?OrgId=${orgId}` - }} - />} -
    - ) + ) : + ( +
    + {walletStatus ? + + + } + onClick={() => { + window.location.href = `${pathRoutes.organizations.createSchema}?OrgId=${orgId}` + }} + /> + : + + + } + onClick={() => { + window.location.href = `${pathRoutes.organizations.dashboard}?OrgId=${orgId}` + }} + />} + +
    + ) }
    diff --git a/src/components/Resources/Schema/Create.tsx b/src/components/Resources/Schema/Create.tsx index ea363c6f2..8c60e3c92 100644 --- a/src/components/Resources/Schema/Create.tsx +++ b/src/components/Resources/Schema/Create.tsx @@ -13,6 +13,8 @@ import { addSchema } from '../../../api/Schema'; import { getFromLocalStorage } from '../../../api/Auth'; import { pathRoutes } from '../../../config/pathRoutes'; import checkEcosystem from '../../../config/ecosystem'; +import { createSchemaRequest } from '../../../api/ecosystem'; +import ConfirmModal from '../../../commonComponents/ConfirmPopup'; const options = [ { value: 'string', label: 'String' }, @@ -20,12 +22,36 @@ const options = [ { value: 'date', label: 'Date' }, ]; +interface IAttributes { + attributeName: string + schemaDataType: string + displayName: string +} +interface IFormData { + schemaName: string + schemaVersion: string + attribute: IAttributes[] +} + const CreateSchema = () => { const [failure, setFailure] = useState(null); const [orgId, setOrgId] = useState(0); const [orgDid, setOrgDid] = useState(''); const [createloader, setCreateLoader] = useState(false); + const [showPopup, setShowPopup] = useState(false) + const initFormData: IFormData = { + schemaName: '', + schemaVersion: '', + attribute: [ + { + attributeName: '', + schemaDataType: 'string', + displayName: '', + } + ] + } + const [formData, setFormData] = useState(initFormData) useEffect(() => { const fetchData = async () => { const organizationId = await getFromLocalStorage( @@ -66,10 +92,58 @@ const CreateSchema = () => { } }; + const submitSchemaCreationRequest = async (values: Values) => { + setCreateLoader(true); + const schemaFieldName: FieldName = { + schemaName: values.schemaName, + schemaVersion: values.schemaVersion, + attributes: values.attribute, + orgId: orgId, + }; + + const createSchema = await createSchemaRequest(schemaFieldName, orgId); + const { data } = createSchema as AxiosResponse; + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + if (data?.data) { + setCreateLoader(false); + window.location.href = pathRoutes.organizations.schemas; + } else { + setFailure(createSchema as string); + setCreateLoader(false); + } + } else { + setCreateLoader(false); + setFailure(createSchema as string); + setTimeout(() => { + setFailure(null); + }, 4000); + } + setShowPopup(false) + }; + + const { isEnabledEcosystem, isEcosystemMember } = checkEcosystem() const formTitle = isEcosystemMember ? "Create Endorsement Request" : "Create Schema" const submitButtonTitle = isEcosystemMember ? "Request Endorsement" : "Create" + const confirmCreateSchema = () => { + if (isEnabledEcosystem && isEcosystemMember) { + console.log("Submitted for endorsement by ecosystem member") + submitSchemaCreationRequest(formData) + } else { + formData.attribute.forEach((element: any) => { + if (!element.schemaDataType) { + element.schemaDataType = 'string'; + } + }); + const updatedAttribute: Array = []; + formData.attribute.forEach((element) => { + updatedAttribute.push(Number(element)); + }); + submit(formData); + } + } + return (
    @@ -82,20 +156,9 @@ const CreateSchema = () => {
    { validateOnChange enableReinitialize onSubmit={async (values): Promise => { - if (isEnabledEcosystem && isEcosystemMember) { - console.log("Submitted for endorsement by ecosystem member") - } else { - values.attribute.forEach((element: any) => { - if (!element.schemaDataType) { - element.schemaDataType = 'string'; - } - }); - const updatedAttribute: Array = []; - values.attribute.forEach((element) => { - updatedAttribute.push(Number(element)); - - }); - submit(values); - } + setFormData(values) + setShowPopup(true) }} > {(formikHandlers): JSX.Element => ( @@ -153,10 +203,8 @@ const CreateSchema = () => { {formikHandlers.errors && formikHandlers.touched.schemaName && formikHandlers.errors.schemaName ? ( - ) : ( @@ -269,6 +317,7 @@ const CreateSchema = () => { {options.map((opt) => { return (
    {failure && ( -
    +
    setFailure(null)}>

    {failure}

    @@ -457,12 +506,10 @@ const CreateSchema = () => { )}
    -
    - -
    + setShowPopup(false)} onSuccess={confirmCreateSchema} message={"Would you like to proceed? Keep in mind that this action cannot be undone."} isProcessing={createloader} />