diff --git a/src/components/Verification/ConnectionList.tsx b/src/components/Verification/ConnectionList.tsx
index 4f6db0c3..43b24eec 100644
--- a/src/components/Verification/ConnectionList.tsx
+++ b/src/components/Verification/ConnectionList.tsx
@@ -106,77 +106,68 @@ const ConnectionList = (props: {
);
};
-
- const selectOrganization = async (
- item: IConnectionList,
- checked: boolean,
- ) => {
- try {
- const index =
- localOrgs?.length > 0
- ? localOrgs.findIndex((ele) => ele.connectionId === item.connectionId)
- : -1;
-
- const { connectionId, theirLabel, createDateTime } = item || {};
- if (index === -1) {
- setLocalOrgs((prev: LocalOrgs[]) => [
- ...prev,
- {
- connectionId,
- theirLabel,
- createDateTime,
- },
- ]);
- } else {
- const updateLocalOrgs = [...localOrgs];
- if (!checked) {
- updateLocalOrgs.splice(index, 1);
- }
- setLocalOrgs(updateLocalOrgs);
- }
- } catch (error) {
- console.error('SELECTED ORGANIZATION:::', error);
- }
- };
-
-
- const generateTable = async (connections: IConnectionList[]) => {
- try {
- const connectionsData =
- connections?.length > 0 &&
- connections?.map((ele: IConnectionList) => {
- const createdOn = ele?.createDateTime
- ? ele?.createDateTime
- : 'Not available';
- const connectionId = ele.connectionId
- ? ele.connectionId
- : 'Not available';
- const userName = ele?.theirLabel ? ele.theirLabel : 'Not available';
-
- const isChecked = localOrgs
- .map((item) => item.connectionId)
- .includes(ele.connectionId);
-
- return {
- data: [
- { data: renderCheckbox(ele, isChecked, connections) },
- { data: userName },
- { data: connectionId },
- {
- data: (
-
- {' '}
- {dateConversion(createdOn)}{' '}
-
- ),
- },
- ],
- };
- });
+const extractConnectionFields = (item: IConnectionList) => {
+ const connectionId = item?.connectionId || 'Not available';
+ const theirLabel = item?.theirLabel || 'Not available';
+ const createDateTime = item?.createDateTime || 'Not available';
+ return { connectionId, theirLabel, createDateTime };
+ };
+
+ const isConnectionChecked = (connectionId: string) =>
+ localOrgs.map((item) => item.connectionId).includes(connectionId);
+
+
+ const selectOrganization = async (item: IConnectionList, checked: boolean) => {
+ try {
+ const { connectionId, theirLabel, createDateTime } = extractConnectionFields(item);
+ const index = localOrgs?.findIndex((ele) => ele.connectionId === connectionId) ?? -1;
+
+ if (index === -1) {
+ setLocalOrgs((prev: LocalOrgs[]) => [
+ ...prev,
+ { connectionId, theirLabel, createDateTime },
+ ]);
+ } else if (!checked) {
+ const updateLocalOrgs = [...localOrgs];
+ updateLocalOrgs.splice(index, 1);
+ setLocalOrgs(updateLocalOrgs);
+ }
+ } catch (error) {
+ console.error('SELECTED ORGANIZATION:::', error);
+ }
+ };
+
+
+ const generateTable = async (connections: IConnectionList[]) => {
+ try {
+ const connectionsData =
+ connections?.length > 0 &&
+ connections.map((ele: IConnectionList) => {
+ const { connectionId, theirLabel, createDateTime } = extractConnectionFields(ele);
+ const isChecked = isConnectionChecked(connectionId);
+
+ return {
+ data: [
+ { data: renderCheckbox(ele, isChecked, connections) },
+ { data: theirLabel },
+ { data: connectionId },
+ {
+ data: (
+
+ {dateConversion(createDateTime)}
+
+ ),
+ },
+ ],
+ };
+ });
+
+ setTableData(connectionsData);
+ } catch (err) {
+ console.error('Error generating table:', err);
+ }
+ };
- setTableData(connectionsData);
- } catch (err) {}
- };
useEffect(() => {
props.selectConnection(localOrgs);
}, [localOrgs]);