Skip to content

Commit 92a871d

Browse files
authored
fix/connection list refresh issue , no org view conistency (#1049)
Signed-off-by: Sujit <sujit.sutar@ayanworks.com>
1 parent e076999 commit 92a871d

File tree

3 files changed

+71
-83
lines changed

3 files changed

+71
-83
lines changed

nextjs/src/features/organization/connectionIssuance/components/ConnectionList.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ const ConnectionList = (props: {
111111

112112
const refreshPage = (): void => {
113113
setLocalOrgs([])
114-
getConnections(listAPIParameterIssuance)
115114
}
116115

117116
useEffect(() => {
@@ -185,21 +184,29 @@ const ConnectionList = (props: {
185184
pageSize={listAPIParameterIssuance.itemPerPage}
186185
pageCount={Math.ceil(totalItem / listAPIParameterIssuance.itemPerPage)}
187186
onPageChange={(index) =>
188-
setListAPIParameterIssuance((prev) => ({ ...prev, page: index + 1 }))
187+
setListAPIParameterIssuance((prev) => {
188+
const newPage = index + 1
189+
if (prev.page === newPage) {
190+
return prev
191+
}
192+
return { ...prev, page: newPage }
193+
})
189194
}
190195
onPageSizeChange={(size) =>
191-
setListAPIParameterIssuance((prev) => ({
192-
...prev,
193-
itemPerPage: size,
194-
page: 1,
195-
}))
196+
setListAPIParameterIssuance((prev) => {
197+
if (prev.itemPerPage === size && prev.page === 1) {
198+
return prev
199+
}
200+
return { ...prev, itemPerPage: size, page: 1 }
201+
})
196202
}
197203
onSearchTerm={(term) =>
198-
setListAPIParameterIssuance((prev) => ({
199-
...prev,
200-
search: term,
201-
page: 1,
202-
}))
204+
setListAPIParameterIssuance((prev) => {
205+
if (prev.search === term && prev.page === 1) {
206+
return prev
207+
}
208+
return { ...prev, search: term, page: 1 }
209+
})
203210
}
204211
/>
205212
</div>

nextjs/src/features/organization/connectionIssuance/components/Credentials.tsx

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { AxiosResponse } from 'axios'
2020
import { ConnectionApiSortFields } from '@/features/connections/types/connections-interface'
2121
import { DataTable } from '../../../../components/ui/generic-table-component/data-table'
2222
import { DidMethod } from '@/features/common/enum'
23-
import { EmptyListMessage } from '@/components/EmptyListComponent'
2423
import { Features } from '@/common/enums'
2524
import { IssuedCredential } from '../type/Issuance'
2625
import PageContainer from '@/components/layout/page-container'
@@ -313,41 +312,31 @@ const Credentials = (): JSX.Element => {
313312
/>
314313
)}
315314

316-
{!walletCreated && !loading ? (
317-
<div className="flex items-center justify-center">
318-
<EmptyListMessage
319-
message={'No Wallet Details Found'}
320-
description={'The owner is required to create a wallet'}
321-
buttonContent={''}
322-
/>
323-
</div>
324-
) : (
325-
<div className="-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-y-0 lg:space-x-12">
326-
<DataTable
327-
isLoading={loading}
328-
placeHolder="Filter by Connection Id and Schema Name"
329-
data={issuedCredList}
330-
columns={column}
331-
index={'credentialExchangeId'}
332-
pageIndex={pagination.pageIndex}
333-
pageSize={pagination.pageSize}
334-
pageCount={pagination.pageCount}
335-
onPageChange={(index) =>
336-
setPagination((prev) => ({ ...prev, pageIndex: index }))
337-
}
338-
onPageSizeChange={(size) => {
339-
setPagination((prev) => ({
340-
...prev,
341-
pageSize: size,
342-
pageIndex: 0,
343-
}))
344-
}}
345-
onSearchTerm={(term) =>
346-
setPagination((prev) => ({ ...prev, searchTerm: term }))
347-
}
348-
/>
349-
</div>
350-
)}
315+
<div className="-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-y-0 lg:space-x-12">
316+
<DataTable
317+
isLoading={loading}
318+
placeHolder="Filter by Connection Id and Schema Name"
319+
data={issuedCredList}
320+
columns={column}
321+
index={'credentialExchangeId'}
322+
pageIndex={pagination.pageIndex}
323+
pageSize={pagination.pageSize}
324+
pageCount={pagination.pageCount}
325+
onPageChange={(index) =>
326+
setPagination((prev) => ({ ...prev, pageIndex: index }))
327+
}
328+
onPageSizeChange={(size) => {
329+
setPagination((prev) => ({
330+
...prev,
331+
pageSize: size,
332+
pageIndex: 0,
333+
}))
334+
}}
335+
onSearchTerm={(term) =>
336+
setPagination((prev) => ({ ...prev, searchTerm: term }))
337+
}
338+
/>
339+
</div>
351340
</PageContainer>
352341
)
353342
}

nextjs/src/features/verification/components/VerificationCredentialList.tsx

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { AxiosResponse } from 'axios'
2727
import { Button } from '@/components/ui/button'
2828
import { ConnectionApiSortFields } from '@/features/connections/types/connections-interface'
2929
import { DataTable } from '../../../components/ui/generic-table-component/data-table'
30-
import { EmptyListMessage } from '@/components/EmptyListComponent'
3130
import { Features } from '@/common/enums'
3231
import PageContainer from '@/components/layout/page-container'
3332
import ProofRequest from './ProofRequestPopup'
@@ -81,6 +80,7 @@ const VerificationCredentialList = (): JSX.Element => {
8180

8281
const fetchOrganizationDetails = async (): Promise<void> => {
8382
if (!orgId) {
83+
setLoading(false)
8484
return
8585
}
8686
setLoading(true)
@@ -130,6 +130,7 @@ const VerificationCredentialList = (): JSX.Element => {
130130

131131
try {
132132
if (!orgId) {
133+
setLoading(false)
133134
return
134135
}
135136
const response = await getVerificationList(orgId, {
@@ -459,40 +460,31 @@ const VerificationCredentialList = (): JSX.Element => {
459460
</div>
460461
)}
461462

462-
{!isWalletCreated && !loading ? (
463-
<div className="flex items-center justify-center">
464-
<EmptyListMessage
465-
message={'No Wallet Details Found'}
466-
description={'The owner is required to create a wallet'}
467-
/>
468-
</div>
469-
) : (
470-
<div className="-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-y-0 lg:space-x-12">
471-
<DataTable
472-
isLoading={loading}
473-
placeHolder="Filter by Connection Id and Schema Name"
474-
data={verificationList}
475-
columns={column}
476-
index={'presentationId'}
477-
pageIndex={proofPagination.pageIndex}
478-
pageSize={proofPagination.pageSize}
479-
pageCount={proofPagination.pageCount}
480-
onPageChange={(index) =>
481-
setProofPagination((prev) => ({ ...prev, pageIndex: index }))
482-
}
483-
onPageSizeChange={(size) => {
484-
setProofPagination((prev) => ({
485-
...prev,
486-
pageSize: size,
487-
pageIndex: 0,
488-
}))
489-
}}
490-
onSearchTerm={(term) =>
491-
setProofPagination((prev) => ({ ...prev, searchTerm: term }))
492-
}
493-
/>
494-
</div>
495-
)}
463+
<div className="-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-y-0 lg:space-x-12">
464+
<DataTable
465+
isLoading={loading}
466+
placeHolder="Filter by Connection Id and Schema Name"
467+
data={verificationList}
468+
columns={column}
469+
index={'presentationId'}
470+
pageIndex={proofPagination.pageIndex}
471+
pageSize={proofPagination.pageSize}
472+
pageCount={proofPagination.pageCount}
473+
onPageChange={(index) =>
474+
setProofPagination((prev) => ({ ...prev, pageIndex: index }))
475+
}
476+
onPageSizeChange={(size) => {
477+
setProofPagination((prev) => ({
478+
...prev,
479+
pageSize: size,
480+
pageIndex: 0,
481+
}))
482+
}}
483+
onSearchTerm={(term) =>
484+
setProofPagination((prev) => ({ ...prev, searchTerm: term }))
485+
}
486+
/>
487+
</div>
496488

497489
{userData && (
498490
<ProofRequest

0 commit comments

Comments
 (0)