diff --git a/client/src/pages/agreementDetails/agreementCard/index.tsx b/client/src/pages/agreementDetails/agreementCard/index.tsx index 741ec48..eb5dbeb 100644 --- a/client/src/pages/agreementDetails/agreementCard/index.tsx +++ b/client/src/pages/agreementDetails/agreementCard/index.tsx @@ -19,24 +19,24 @@ const AgreementCard: React.FC = ({ agreement }) => { const agreementType = mapDocumentType(agreement.type); const parties = agreement.parties - ? agreement.parties.map((party) => party.name_in_agreement).join(", ") + ? agreement.parties.map((party) => party.nameInAgreement).join(", ") : "-"; - const effectiveDate = agreement.provisions?.effective_date - ? format(moment(agreement.provisions.effective_date).toDate(), "yyyy/MM/dd") + const effectiveDate = agreement.provisions?.effectiveDate + ? format(moment(agreement.provisions.effectiveDate).toDate(), "yyyy/MM/dd") : "-"; - const expirationDate = agreement.provisions?.expiration_date + const expirationDate = agreement.provisions?.expirationDate ? format( - moment(agreement.provisions.expiration_date).toDate(), + moment(agreement.provisions.expirationDate).toDate(), "yyyy/MM/dd" ) : "-"; - const renewalType = agreement?.provisions?.assignment_type ?? "-"; - const renewalNoticePeriod = agreement?.provisions?.execution_date ?? "-"; - const renewalNoticeDate = agreement?.provisions?.execution_date ?? "-"; - const renewalTerm = agreement?.provisions?.execution_date ?? "1 year"; - const renewalOwner = agreement?.parties?.[0]?.name_in_agreement ?? "-"; - const additionalInfo = agreement?.additional_custom_esign_data?.[0]?.label ?? "-"; + const renewalType = agreement?.provisions?.assignmentType ?? "-"; + const renewalNoticePeriod = agreement?.provisions?.executionDate ?? "-"; + const renewalNoticeDate = agreement?.provisions?.executionDate ?? "-"; + const renewalTerm = agreement?.provisions?.executionDate ?? "1 year"; + const renewalOwner = agreement?.parties?.[0]?.nameInAgreement ?? "-"; + const additionalInfo = agreement?.additionalCustomEsignData?.[0]?.label ?? "-"; const handleRefresh = () => { dispatch(fetchAgreementById(agreement.id) as any) } diff --git a/client/src/pages/agreements/agreementsTable/index.tsx b/client/src/pages/agreements/agreementsTable/index.tsx index 40f8760..217f98d 100644 --- a/client/src/pages/agreements/agreementsTable/index.tsx +++ b/client/src/pages/agreements/agreementsTable/index.tsx @@ -96,7 +96,7 @@ useEffect(() => { let filtered = data; if (filters.searchText) { filtered = filtered.filter((item) => - item.file_name.toLowerCase().includes(filters.searchText.toLowerCase()) + item.fileName?.valueOf().toLowerCase().includes(filters.searchText.toLowerCase()) ); } @@ -108,7 +108,7 @@ useEffect(() => { if (filters.expirationDate.date) { filtered = filtered.filter((item) => { - const itemExpirationDate = item.provisions?.expiration_date; + const itemExpirationDate = item.provisions?.expirationDate; return ( itemExpirationDate && moment(itemExpirationDate).isSame( @@ -134,12 +134,17 @@ useEffect(() => { setSortConfig({ key, direction }); }; const sortedData = [...filteredData].sort((a, b) => { - const sortKey = sortConfig.key || "file_name"; + const sortKey = sortConfig.key || "fileName"; const aValue = getNestedValue(a, sortKey); const bValue = getNestedValue(b, sortKey); - + + if (aValue === undefined || bValue === undefined) { + return 0; + } + if (aValue < bValue) return sortConfig.direction === "ASC" ? -1 : 1; if (aValue > bValue) return sortConfig.direction === "ASC" ? 1 : -1; + return 0; }); const renderSortIcon = (key: string) => { diff --git a/client/src/pages/agreements/helper.tsx b/client/src/pages/agreements/helper.tsx index 315e20b..a10fef1 100644 --- a/client/src/pages/agreements/helper.tsx +++ b/client/src/pages/agreements/helper.tsx @@ -33,16 +33,16 @@ export const getColumns = ( ) => [ { title: t(translationKeys.NAME), - dataIndex: "file_name", - key: "file_name", - render: (_: any, record: AgreementDocument) => record.file_name, + dataIndex: "fileName", + key: "fileName", + render: (_: any, record: AgreementDocument) => record.fileName, }, { title: t(translationKeys.PARTIES), dataIndex: "parties", key: "parties", render: (_: any, record: AgreementDocument) => - record.parties?.map((party) => party.name_in_agreement).join(", ") ?? "-", + record.parties?.map((party) => party.nameInAgreement).join(", ") ?? "-", }, { title: t(translationKeys.DOCUMENT_TYPE), @@ -58,12 +58,12 @@ export const getColumns = ( }, { title: t(translationKeys.EXPIRATION_DATE), - dataIndex: "expiration_date", - key: "expiration_date", + dataIndex: "expirationDate", + key: "expirationDate", render: (_: any, record: AgreementDocument) => - record.provisions?.expiration_date + record.provisions?.expirationDate ? format( - moment(record.provisions.expiration_date).toDate(), + moment(record.provisions.expirationDate).toDate(), "yyyy/MM/dd" ) : "-", @@ -83,17 +83,17 @@ export const getColumns = ( export const getNestedValue = (obj: AgreementDocument, path: string) => { switch (path) { - case "file_name": - return obj.file_name; + case "fileName": + return obj.fileName; case "type": return obj.type; case "parties": return ( - obj?.parties?.map((party) => party.name_in_agreement).join(", ") ?? "-" + obj?.parties?.map((party) => party.nameInAgreement).join(", ") ?? "-" ); - case "expiration_date": - return obj.provisions?.expiration_date - ? moment(obj.provisions.expiration_date).toDate() + case "expirationDate": + return obj.provisions?.expirationDate + ? moment(obj.provisions.expirationDate).toDate() : new Date(); default: return ""; diff --git a/client/src/types/agreement.ts b/client/src/types/agreement.ts index 71e73fd..bf45afc 100644 --- a/client/src/types/agreement.ts +++ b/client/src/types/agreement.ts @@ -49,30 +49,30 @@ export interface Data { export interface AgreementDocument { id: string; - file_name: string; - type: string; - category: string; - status: string; + fileName?: string; + type?: string; + category?: string; + status?: string; parties?: { id: string; - name_in_agreement: string; + nameInAgreement: string; }[]; provisions?: { - effective_date?: string; - expiration_date?: string; - execution_date?: string; - payment_terms_due_date?: string; - assignment_type?: string; + effectiveDate?: string; + expirationDate?: string; + executionDate?: string; + paymentTermsDueDate?: string; + assignmentType?: string; }; - related_agreement_documents?: Record; - source_name: string; - source_id: string; - metadata: { - created_at: string; - modified_at: string; - modified_by: string; + relatedAgreementDocuments?: Record; + sourceName?: string; + sourceId?: string; + metadata?: { + createdAt: string; + modifiedAt: string; + modifiedBy: string; }; - additional_custom_esign_data?: { + additionalCustomEsignData?: { [key: string]: { label: string; value: string; diff --git a/server/config/config.js b/server/config/config.js index c7e2f6f..015503f 100644 --- a/server/config/config.js +++ b/server/config/config.js @@ -23,7 +23,7 @@ module.exports = { client : { port: process.env.CLIENT_URL }, - scopes: ['adm_store_unified_repo_read'], + scopes: ['adm_store_unified_repo_read', 'signature'], responseType:'code', state: 'random_state_string' }; diff --git a/server/config/example.private.key b/server/config/example.private.key deleted file mode 100644 index 2d5d401..0000000 --- a/server/config/example.private.key +++ /dev/null @@ -1,3 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- - ------END RSA PRIVATE KEY----- diff --git a/server/package-lock.json b/server/package-lock.json index 7aa1dfd..f5b9fc7 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@docusign/iam-sdk": "^1.0.0-beta.3", "axios": "^1.7.7", "cors": "^2.8.5", "docusign-esign-node-client": "file:./docusign-esign-node-client", @@ -104,6 +105,14 @@ "integrity": "sha512-ozRQ9CgWF4JXNNae1zUEpb2fbqH61oxtZz2sdR7a0ci5mi9pSP3EvoU7g4idZYi+CXP32gsvH7kTYZJCGW3DKQ==", "license": "MIT" }, + "node_modules/@docusign/iam-sdk": { + "version": "1.0.0-beta.3", + "resolved": "https://registry.npmjs.org/@docusign/iam-sdk/-/iam-sdk-1.0.0-beta.3.tgz", + "integrity": "sha512-kK3lftOtfc+smFcmjURy9XHwhFQ1aXFj+hpRnWjLWl5juXi5/J79xILJVasJyX25T4GEvJP1946BgfpllNn9xg==", + "peerDependencies": { + "zod": ">= 3" + } + }, "node_modules/@hapi/boom": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/@hapi/boom/-/boom-10.0.1.tgz", @@ -5147,6 +5156,16 @@ "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==", "dev": true, "license": "ISC" + }, + "node_modules/zod": { + "version": "3.25.64", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.64.tgz", + "integrity": "sha512-hbP9FpSZf7pkS7hRVUrOjhwKJNyampPgtXKc3AN6DsWtoHsg2Sb4SQaS4Tcay380zSwd2VPo9G9180emBACp5g==", + "license": "MIT", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/server/package.json b/server/package.json index 4425fbc..1051c4c 100644 --- a/server/package.json +++ b/server/package.json @@ -11,6 +11,7 @@ "license": "ISC", "description": "", "dependencies": { + "@docusign/iam-sdk": "^1.0.0-beta.3", "axios": "^1.7.7", "cors": "^2.8.5", "dotenv": "^16.4.5", @@ -23,5 +24,8 @@ "simple-oauth2": "^5.1.0", "url-join": "^4.0.1", "docusign-esign-node-client": "file:./docusign-esign-node-client" + }, + "overrides": { + "zod": "3.25.64" } -} +} \ No newline at end of file diff --git a/server/services/docusignService.js b/server/services/docusignService.js index 480012c..37bc03a 100644 --- a/server/services/docusignService.js +++ b/server/services/docusignService.js @@ -1,7 +1,5 @@ -const axios = require("axios"); -const urlJoin = require("url-join"); -const config = require("../config/config"); const DsClient = require("../config/dsClient"); +const iam = require('@docusign/iam-sdk'); const getAgreements = async (req) => { const accessToken = req.headers['authorization'].split(' ')[1]; @@ -15,15 +13,11 @@ const getAgreements = async (req) => { throw new Error("Access token is missing. Please log in again."); } - const url = urlJoin(config.docusign.agreementsUrl, accountId, 'agreements'); - const response = await axios.get(url, { - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }); + const client = new iam.IamClient({accessToken: accessToken }); + const agreements = await client.navigator.agreements.getAgreementsList({ accountId: accountId }); - if (response.data) { - return response.data.data; + if (agreements.data) { + return agreements.data; } else { throw new Error("No agreements found"); } @@ -45,17 +39,11 @@ const getAgreementById = async (req, agreementId) => { throw new Error("Access token is missing. Please log in again."); } - const url = urlJoin(config.docusign.agreementsUrl, accountId, 'agreements', agreementId); - const response = await axios.get(url, - { - headers: { - Authorization: `Bearer ${accessToken}`, - }, - } - ); + const client = new iam.IamClient({ accessToken: accessToken }); + const agreements = await client.navigator.agreements.getAgreement({ accountId: accountId, agreementId: agreementId }); - if (response.data) { - return response.data; + if (agreements) { + return agreements; } else { throw new Error(`Agreement with ID ${agreementId} not found`); }