From 01ffe2cf326533c77780a4cec05b70be83a27800 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Wed, 13 Sep 2023 17:23:43 +0530 Subject: [PATCH 01/18] 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 02/18] 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 a5eea25dad756c21ad7713af3a44bad75a7e3da3 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 14 Sep 2023 12:04:22 +0530 Subject: [PATCH 03/18] 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 04/18] 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 05/18] 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 06/18] 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 51c63217b9174c3e8a58401dda3c2df997abfa27 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 14 Sep 2023 15:48:05 +0530 Subject: [PATCH 07/18] 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 bc7633acbab0a3546bf60b50f9ef166c71aa3d17 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Fri, 15 Sep 2023 12:05:42 +0530 Subject: [PATCH 08/18] fix: worked on sign up user functionality Signed-off-by: bhavanakarwade --- src/components/Authentication/SignUpUser.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/Authentication/SignUpUser.tsx b/src/components/Authentication/SignUpUser.tsx index cac0bf13c..7b481ea4f 100644 --- a/src/components/Authentication/SignUpUser.tsx +++ b/src/components/Authentication/SignUpUser.tsx @@ -68,12 +68,14 @@ const SignUpUser = () => { const userRsp = await checkUserExist(values?.email) const { data } = userRsp as AxiosResponse setLoading(false) + console.log("data:56576", data) if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - if (data.data === 'New User') { + if (data?.data?.isExist === false) { + console.log('email data::', data.data) setEmail(values?.email) await VerifyMail(values?.email) } - else if (data.data.isEmailVerified === true && data?.data?.isKeycloak !== true) { + else if (data.data.isEmailVerified === true && data?.data?.isSupabase!== true) { setEmail(values?.email) await setToLocalStorage(storageKeys.USER_EMAIL, values?.email) setNextFlag(true) From 159c9c2823782fdf9fb824811e5b85aacab3b687 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Fri, 15 Sep 2023 17:49:02 +0530 Subject: [PATCH 09/18] fix: Fetch user list, if no any organization is created issue Signed-off-by: bhavanakarwade --- src/api/organization.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/organization.ts b/src/api/organization.ts index d41784384..bd0e965e6 100644 --- a/src/api/organization.ts +++ b/src/api/organization.ts @@ -226,6 +226,9 @@ export const getOrganizationRoles = async () => { export const getOrganizationUsers = async (pageNumber: number, pageSize: number, search = '') => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID) + if (!orgId) { + return "Organization is required"; + } const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.users.fetchUsers}?&pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` From 3e3805632974eb4ba4800ef032eb8cab51968461 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Mon, 18 Sep 2023 14:09:25 +0530 Subject: [PATCH 10/18] 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 73770103d09002e7e296162d6d73ab5eb944a70c Mon Sep 17 00:00:00 2001 From: MoulikaKulkarni Date: Mon, 18 Sep 2023 19:56:26 +0530 Subject: [PATCH 11/18] 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 12/18] 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 17/18] 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 18/18] 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