From c0ec4bf44738bb84a34b8b3b259678db05807996 Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Tue, 26 Dec 2023 12:05:54 +0530 Subject: [PATCH 1/2] feat: delete organization invitation Signed-off-by: sanjay-k1910 --- src/api/organization.ts | 626 +++++++++--------- .../EcosystemInvite/EcoInvitationList.tsx | 4 +- .../EcoSystemReceivedInvitations.tsx | 30 +- .../organization/invitations/Invitations.tsx | 127 ++-- 4 files changed, 422 insertions(+), 365 deletions(-) diff --git a/src/api/organization.ts b/src/api/organization.ts index 818be26e5..8911b1118 100644 --- a/src/api/organization.ts +++ b/src/api/organization.ts @@ -1,354 +1,364 @@ -import { axiosGet, axiosPost, axiosPublicOrganisationGet, axiosPut } from "../services/apiRequests" - -import { apiRoutes } from "../config/apiRoutes"; -import { getFromLocalStorage } from "./Auth"; -import { getHeaderConfigs } from "../config/GetHeaderConfigs"; -import { storageKeys } from "../config/CommonConstant"; +import { + axiosDelete, + axiosGet, + axiosPost, + axiosPublicOrganisationGet, + 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 createOrganization = async (data: object) => { + const url = apiRoutes.organizations.create; + const payload = data; + const token = await getFromLocalStorage(storageKeys.TOKEN); - 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 - } -} - -export const updateOrganization = 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 - } -} - - -export const getOrganizations = async (pageNumber: number, pageSize: number, search = '') => { - - const url = `${apiRoutes.organizations.getAll}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` - - 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 - } -} + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}`, + }, + }; + const axiosPayload = { + url, + payload, + config, + }; -export const getOrganizationById = async (orgId: string) => { + try { + return await axiosPost(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; + } +}; - const url = `${apiRoutes.organizations.getById}/${orgId}` - - 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 updateOrganization = async (data: object, orgId: string) => { + const url = `${apiRoutes.organizations.update}/${orgId}`; + const payload = data; + const token = await getFromLocalStorage(storageKeys.TOKEN); -export const getOrgDashboard = async (orgId: string) => { + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}`, + }, + }; + const axiosPayload = { + url, + payload, + config, + }; - const url = `${apiRoutes.organizations.getOrgDashboard}/${orgId}` - - 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 spinupDedicatedAgent = async (data: object, orgId:string) => { - - const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Agent.agentDedicatedSpinup}` - 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 - } -} - -export const spinupSharedAgent = async (data: object, orgId:string) => { - - const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Agent.agentSharedSpinup}` - 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 - } -} + try { + return await axiosPut(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; + } +}; +export const getOrganizations = async ( + pageNumber: number, + pageSize: number, + search = '', +) => { + const url = `${apiRoutes.organizations.getAll}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}`; -export const getOrganizationRoles = async () => { + const token = await getFromLocalStorage(storageKeys.TOKEN); + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}`, + }, + }; + const axiosPayload = { + url, + config, + }; - const url = `${apiRoutes.organizations.orgRoles}` + try { + return await axiosGet(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; + } +}; - const token = await getFromLocalStorage(storageKeys.TOKEN) +export const getOrganizationById = async (orgId: string) => { + const url = `${apiRoutes.organizations.getById}/${orgId}`; - const config = { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - } - } - const axiosPayload = { - url, - config - } + const token = await getFromLocalStorage(storageKeys.TOKEN); - try { - return await axiosGet(axiosPayload); - } - catch (error) { - const err = error as Error - return err?.message - } -} + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}`, + }, + }; + const axiosPayload = { + url, + config, + }; -//Get users of the organization -export const getOrganizationUsers = async (pageNumber: number, pageSize: number, search = '') => { + try { + return await axiosGet(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; + } +}; + +export const getOrgDashboard = async (orgId: string) => { + const url = `${apiRoutes.organizations.getOrgDashboard}/${orgId}`; - const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - if (!orgId) { - return "Organization is required"; - } + const token = await getFromLocalStorage(storageKeys.TOKEN); - const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.users.fetchUsers}?&pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` + const config = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}`, + }, + }; + const axiosPayload = { + url, + config, + }; - const axiosPayload = { - url, - config: await getHeaderConfigs() - } + try { + return await axiosGet(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; + } +}; - try { - return await axiosGet(axiosPayload); - } - catch (error) { - const err = error as Error - return err?.message - } -} +export const spinupDedicatedAgent = async (data: object, orgId: string) => { + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Agent.agentDedicatedSpinup}`; + const payload = data; -// Edit user roles -export const editOrganizationUserRole = async (userId: string, roles: string[]) => { - - 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 - } -} + const token = await getFromLocalStorage(storageKeys.TOKEN); -//Create Connection + 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 createConnection = async (orgName: string) => { - const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.connection.create}` - - const data = { - label: orgName, - multiUseInvitation: true, - autoAcceptConnection: true, - orgId: orgId - } - 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 spinupSharedAgent = async (data: object, orgId: string) => { + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Agent.agentSharedSpinup}`; + const payload = data; -// public profile + 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 getPublicOrganizations = async (pageNumber: number, pageSize: number, search :string) => { +export const getOrganizationRoles = async () => { + const url = `${apiRoutes.organizations.orgRoles}`; - const url = `${apiRoutes.Public.organizations}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` + const token = await getFromLocalStorage(storageKeys.TOKEN); const config = { - headers: { - 'Content-Type': 'application/json', - } + 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; } +}; + +//Get users of the organization +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}`; + const axiosPayload = { - url, - config + url, + config: await getHeaderConfigs(), + }; + + try { + return await axiosGet(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; } +}; + +// Edit user roles +export const editOrganizationUserRole = async ( + userId: string, + roles: string[], +) => { + 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 await axiosPublicOrganisationGet(axiosPayload); + return axiosPut(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; } - catch (error) { - const err = error as Error - return err?.message +}; + +//Create Connection + +export const createConnection = async (orgName: string) => { + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); + const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.connection.create}`; + + const data = { + label: orgName, + multiUseInvitation: true, + autoAcceptConnection: true, + orgId: orgId, + }; + 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 getPublicOrgDetails = async (orgSlug: string) => { +// public profile - const url = `${apiRoutes.Public.organizationDetails}/${orgSlug}` +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', - } - } + headers: { + 'Content-Type': 'application/json', + }, + }; const axiosPayload = { - url, - config - } + url, + config, + }; try { - return await axiosPublicOrganisationGet(axiosPayload); + return await axiosPublicOrganisationGet(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; } - catch (error) { - const err = error as Error - return err?.message +}; + +export const getPublicOrgDetails = async (orgSlug: string) => { + const url = `${apiRoutes.Public.organizationDetails}/${orgSlug}`; + + const config = { + headers: { + 'Content-Type': 'application/json', + }, + }; + const axiosPayload = { + url, + config, + }; + + try { + return await axiosPublicOrganisationGet(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; } -} +}; +// Edit user roles +export const deleteOrganizationInvitation = async ( + orgId: string, + invitationId: string, +) => { + const url = `${apiRoutes.organizations.root}/${orgId}/invitations/${invitationId}`; + + const axiosPayload = { + url, + config: await getHeaderConfigs(), + }; + try { + return axiosDelete(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; + } +}; diff --git a/src/components/EcosystemInvite/EcoInvitationList.tsx b/src/components/EcosystemInvite/EcoInvitationList.tsx index 48c8ecee0..e60f182af 100644 --- a/src/components/EcosystemInvite/EcoInvitationList.tsx +++ b/src/components/EcosystemInvite/EcoInvitationList.tsx @@ -2,8 +2,8 @@ import type { InvitationProps } from "./EcoSystemReceivedInvitations"; import CustomAvatar from '../Avatar'; const EcoInvitationList = (props: InvitationProps) => { - const { invitationId, ecosytem } = props; - const { name, logoUrl, networkDetails } = ecosytem; + const { invitationId, ecosystem } = props; + const { name, logoUrl, networkDetails } = ecosystem; return (
diff --git a/src/components/EcosystemInvite/EcoSystemReceivedInvitations.tsx b/src/components/EcosystemInvite/EcoSystemReceivedInvitations.tsx index b26ab3c5f..80f964dfd 100644 --- a/src/components/EcosystemInvite/EcoSystemReceivedInvitations.tsx +++ b/src/components/EcosystemInvite/EcoSystemReceivedInvitations.tsx @@ -37,7 +37,7 @@ export interface NetworkDetails { export interface InvitationProps { invitationId: string; - ecosytem: { + ecosystem: { name: string; logoUrl: string; networkDetails: NetworkDetails[] @@ -218,19 +218,19 @@ const ReceivedInvitations = () => { const updateInvitationData = invitationsData && invitationsData.length > 0 ? invitationsData.map((item) => { - if (id === item.id) { - return { - ...item, - orgId: value, - selected: true, - orgData: orgData ?? undefined, - }; - } + if (id === item.id) { return { ...item, - selected: false, + orgId: value, + selected: true, + orgData: orgData ?? undefined, }; - }) + } + return { + ...item, + selected: false, + }; + }) : null; setInvitationsData(updateInvitationData); setSelectedId(value); @@ -285,13 +285,13 @@ const ReceivedInvitations = () => { return (
+
- +

+ Received Ecosystem Invitations +

-

- Received Ecosystem Invitations -

diff --git a/src/components/organization/invitations/Invitations.tsx b/src/components/organization/invitations/Invitations.tsx index 864978cd2..e16e83b09 100644 --- a/src/components/organization/invitations/Invitations.tsx +++ b/src/components/organization/invitations/Invitations.tsx @@ -1,7 +1,7 @@ 'use client'; import { ChangeEvent, useEffect, useState } from 'react'; -import { apiStatusCodes } from '../../../config/CommonConstant'; +import { apiStatusCodes, storageKeys } from '../../../config/CommonConstant'; import { AlertComponent } from '../../AlertComponent'; import type { AxiosResponse } from 'axios'; @@ -9,7 +9,7 @@ import { EmptyListMessage } from '../../EmptyListComponent'; import { Features } from '../../../utils/enums/features'; import type { Invitation } from '../interfaces/invitations'; import type { OrgRole } from '../interfaces' -import { Pagination } from 'flowbite-react'; +import { Button, Pagination } from 'flowbite-react'; import RoleViewButton from '../../RoleViewButton'; import SearchInput from '../../SearchInput'; import SendInvitationModal from './SendInvitationModal'; @@ -19,6 +19,8 @@ import CustomSpinner from '../../CustomSpinner'; import { dateConversion } from '../../../utils/DateConversion'; import DateTooltip from '../../Tooltip'; import React from 'react'; +import { deleteOrganizationInvitation } from '../../../api/organization'; +import { getFromLocalStorage } from '../../../api/Auth'; const initialPageState = { pageNumber: 1, @@ -84,7 +86,7 @@ const Invitations = () => { getData = setTimeout(() => { getAllInvitations() }, 1000) - return () => clearTimeout(getData); + return () => clearTimeout(getData); } else { getAllInvitations() } @@ -92,7 +94,7 @@ const Invitations = () => { return () => clearTimeout(getData) }, [searchText, openModal, currentPage.pageNumber]) - + //onCHnage of Search input text const searchInputChange = (e: ChangeEvent) => { setSearchText(e.target.value); @@ -101,6 +103,22 @@ const Invitations = () => { const createInvitationsModel = () => { props.setOpenModal(true) } + + const deleteInvitations = async (invitationId: string) => { + const orgId = await getFromLocalStorage(storageKeys.ORG_ID) + const response = await deleteOrganizationInvitation(orgId, invitationId); + const { data } = response as AxiosResponse; + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + setLoading(true); + await getAllInvitations(); + setMessage(data?.message || 'Invitation deleted successfully'); + } else { + setError(response as string); + } + setLoading(false); + }; + return (
{ buttonTitle='Invite' feature={Features.SEND_INVITATION} svgComponent={ - - - } + + + } onClickEvent={createInvitationsModel} - /> + />
{ {loading ?
- - +
: invitationsList && invitationsList?.length > 0 ? (
{ { invitationsList.map((invitation) => ( -
  • +
  • - +

    {

  • - {invitation.orgRoles.length>1 ? 'Roles:' : 'Role:'} + {invitation.orgRoles.length > 1 ? 'Roles:' : 'Role:'} {invitation.orgRoles && invitation.orgRoles.length > 0 && invitation.orgRoles.map((role: OrgRole, index: number) => { @@ -216,39 +233,69 @@ const Invitations = () => { -
    - Invited On:  {dateConversion(invitation.createDateTime)} -
    +
    +
    + Invited On:  {dateConversion(invitation.createDateTime)} +
    + {invitation.status === 'pending' && ( +
    + +
    + )} +
  • )) }
    -
    ) - : invitationsList && ( - - } - />) +
    ) + : invitationsList && ( + + } + />) + } + { + currentPage.total > 1 && +
    + +
    } - { - currentPage.total > 1 && -
    - -
    - }
    From 4e55f12ae52206464fb970ca4b9e539a494d4438 Mon Sep 17 00:00:00 2001 From: sanjay-k1910 Date: Tue, 26 Dec 2023 12:49:40 +0530 Subject: [PATCH 2/2] refactor: confirmation popup Signed-off-by: sanjay-k1910 --- src/api/organization.ts | 2 +- .../organization/invitations/Invitations.tsx | 66 +++++++++++-------- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/api/organization.ts b/src/api/organization.ts index 8911b1118..73cf3ad8b 100644 --- a/src/api/organization.ts +++ b/src/api/organization.ts @@ -356,7 +356,7 @@ export const deleteOrganizationInvitation = async ( }; try { - return axiosDelete(axiosPayload); + return await axiosDelete(axiosPayload); } catch (error) { const err = error as Error; return err?.message; diff --git a/src/components/organization/invitations/Invitations.tsx b/src/components/organization/invitations/Invitations.tsx index e16e83b09..b3a420bee 100644 --- a/src/components/organization/invitations/Invitations.tsx +++ b/src/components/organization/invitations/Invitations.tsx @@ -1,6 +1,6 @@ 'use client'; -import { ChangeEvent, useEffect, useState } from 'react'; +import React, { ChangeEvent, useEffect, useState } from 'react'; import { apiStatusCodes, storageKeys } from '../../../config/CommonConstant'; import { AlertComponent } from '../../AlertComponent'; @@ -18,9 +18,9 @@ import { getOrganizationInvitations } from '../../../api/invitations'; import CustomSpinner from '../../CustomSpinner'; import { dateConversion } from '../../../utils/DateConversion'; import DateTooltip from '../../Tooltip'; -import React from 'react'; import { deleteOrganizationInvitation } from '../../../api/organization'; import { getFromLocalStorage } from '../../../api/Auth'; +import ConfirmationModal from '../../../commonComponents/ConfirmationModal'; const initialPageState = { pageNumber: 1, @@ -32,11 +32,12 @@ const initialPageState = { const Invitations = () => { const [openModal, setOpenModal] = useState(false); const [loading, setLoading] = useState(false) + const [deleteLoading, setDeleteLoading] = useState(false) + const [selectedInvitation, setSelectedInvitation] = useState('') const [message, setMessage] = useState(null) + const [showPopup, setShowPopup] = useState(false) const [error, setError] = useState(null) const [currentPage, setCurrentPage] = useState(initialPageState); - const [userRoles, setUserRoles] = useState([]) - const timestamp = Date.now(); const onPageChange = (page: number) => { setCurrentPage({ @@ -59,11 +60,8 @@ const Invitations = () => { setLoading(false) if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const totalPages = data?.data?.totalPages; - const invitationList = data?.data?.invitations - setInvitationsList(invitationList) setCurrentPage({ ...currentPage, @@ -78,8 +76,6 @@ const Invitations = () => { //This useEffect is called when the searchText changes useEffect(() => { - - // let getData: string | number | NodeJS.Timeout | undefined; let getData: NodeJS.Timeout if (searchText.length >= 1) { @@ -95,7 +91,7 @@ const Invitations = () => { }, [searchText, openModal, currentPage.pageNumber]) - //onCHnage of Search input text + //onChange of Search input text const searchInputChange = (e: ChangeEvent) => { setSearchText(e.target.value); } @@ -104,20 +100,22 @@ const Invitations = () => { props.setOpenModal(true) } - const deleteInvitations = async (invitationId: string) => { + const deleteInvitations = async () => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - const response = await deleteOrganizationInvitation(orgId, invitationId); - const { data } = response as AxiosResponse; - - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - setLoading(true); - await getAllInvitations(); - setMessage(data?.message || 'Invitation deleted successfully'); - } else { - setError(response as string); - } - setLoading(false); - }; + const invitationId = selectedInvitation + const response = await deleteOrganizationInvitation(orgId, invitationId); + const { data } = response as AxiosResponse; + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + setDeleteLoading(true); + await getAllInvitations(); + setMessage(data?.message || 'Invitation deleted successfully'); + setShowPopup(false) + } else { + setError(response as string); + } + setDeleteLoading(false); + }; return (
    @@ -147,7 +145,7 @@ const Invitations = () => { } /> { setMessage(null) @@ -242,7 +240,12 @@ const Invitations = () => { {invitation.status === 'pending' && (
    } - + setShowPopup(false)} + onSuccess={() => deleteInvitations()} + message={'Would you like to proceed? Keep in mind that this action cannot be undone.'} + buttonTitles={["No, cancel", "Yes, I'm sure"]} + isProcessing={deleteLoading} + setFailure={setError} + setSuccess={setMessage} + />