Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions client/src/pages/agreementDetails/agreementCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ const AgreementCard: React.FC<AgreementCardProps> = ({ 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)
}
Expand Down
13 changes: 9 additions & 4 deletions client/src/pages/agreements/agreementsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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())
);
}

Expand All @@ -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(
Expand All @@ -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) => {
Expand Down
28 changes: 14 additions & 14 deletions client/src/pages/agreements/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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"
)
: "-",
Expand All @@ -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 "";
Expand Down
36 changes: 18 additions & 18 deletions client/src/types/agreement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>;
source_name: string;
source_id: string;
metadata: {
created_at: string;
modified_at: string;
modified_by: string;
relatedAgreementDocuments?: Record<string, unknown>;
sourceName?: string;
sourceId?: string;
metadata?: {
createdAt: string;
modifiedAt: string;
modifiedBy: string;
};
additional_custom_esign_data?: {
additionalCustomEsignData?: {
[key: string]: {
label: string;
value: string;
Expand Down
2 changes: 1 addition & 1 deletion server/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
3 changes: 0 additions & 3 deletions server/config/example.private.key

This file was deleted.

19 changes: 19 additions & 0 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
}
30 changes: 9 additions & 21 deletions server/services/docusignService.js
Original file line number Diff line number Diff line change
@@ -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];
Expand All @@ -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");
}
Expand All @@ -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`);
}
Expand Down