Skip to content

Commit b617d03

Browse files
committed
fix date pading
1 parent 0075be9 commit b617d03

File tree

8 files changed

+35
-45
lines changed

8 files changed

+35
-45
lines changed

packages/api/src/crm/contact/services/leadsquared/index.ts

+13-15
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ export class LeadSquaredService implements IContactService {
3131

3232
formatDateForLeadSquared(date: Date): string {
3333
const year = date.getUTCFullYear();
34-
const month = date.getUTCMonth() + 1;
35-
const currentDate = date.getUTCDate();
36-
const hours = date.getUTCHours();
37-
const minutes = date.getUTCMinutes();
38-
const seconds = date.getUTCSeconds();
34+
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
35+
const currentDate = date.getUTCDate().toString().padStart(2, '0');
36+
const hours = date.getUTCHours().toString().padStart(2, '0');
37+
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
38+
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
3939
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
4040
}
4141

@@ -121,17 +121,15 @@ export class LeadSquaredService implements IContactService {
121121
headers,
122122
},
123123
);
124+
124125
const leads = resp?.data['Leads'].map(
125-
(lead: LeadSquaredContactResponse) => {
126-
const leadSquaredContact: LeadSquaredContactOutput = {};
127-
lead.LeadPropertyList.map(
128-
({ Attribute, Value }: { Attribute: string; Value: string }) => {
129-
leadSquaredContact[Attribute] = Value;
130-
},
131-
);
132-
return leadSquaredContact;
133-
},
134-
);
126+
(lead: LeadSquaredContactResponse) =>
127+
lead.LeadPropertyList.reduce((acc, { Attribute, Value }: { Attribute: string; Value: string }) => {
128+
acc[Attribute] = Value;
129+
return acc;
130+
}, {} as LeadSquaredContactOutput)
131+
);
132+
135133
//this.logger.log('CONTACTS LEADSQUARED ' + JSON.stringify(resp.data.data));
136134
this.logger.log(`Synced leadsquared contacts !`);
137135
return {

packages/api/src/crm/contact/services/leadsquared/types.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
type LeadSquaredContact = {
2-
/*
3-
* user_id
4-
* first_name
5-
* last_name
6-
* email
7-
* phone
8-
* address
9-
*/
102
ProspectID: string;
113
FirstName: string;
124
LastName: string;

packages/api/src/crm/deal/services/leadsquared/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class LeadSquaredService implements IDealService {
8484

8585
async sync(data: SyncParam): Promise<ApiResponse<LeadSquaredDealOutput[]>> {
8686
try {
87-
// TODO: I'm not sure about this
87+
// Have to pass the leadId and opportunityType
8888
const { linkedUserId, leadId, opportunityType } = data;
8989
const connection = await this.prisma.connections.findFirst({
9090
where: {

packages/api/src/crm/deal/services/leadsquared/mappers.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ export class LeadSquaredDealMapper implements IDealMapper {
2020
}
2121
formatDateForLeadSquared(date: Date): string {
2222
const year = date.getUTCFullYear();
23-
const month = date.getUTCMonth() + 1;
24-
const currentDate = date.getUTCDate();
25-
const hours = date.getUTCHours();
26-
const minutes = date.getUTCMinutes();
27-
const seconds = date.getUTCSeconds();
23+
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
24+
const currentDate = date.getUTCDate().toString().padStart(2, '0');
25+
const hours = date.getUTCHours().toString().padStart(2, '0');
26+
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
27+
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
2828
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
2929
}
3030

packages/api/src/crm/deal/services/leadsquared/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ type LeadDetail = {
22
Attribute: string;
33
Value: string;
44
};
5-
// If comments are enabled on opportunity status change, you must pass the mx_Custom_19 (of datatype ‘String’)
5+
66
type Field = {
77
SchemaName: string;
88
Value: string;

packages/api/src/crm/engagement/services/leadsquared/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export class LeadSquaredService implements IEngagementService {
3535

3636
formatDateForLeadSquared(date: Date): string {
3737
const year = date.getUTCFullYear();
38-
const month = date.getUTCMonth() + 1;
39-
const currentDate = date.getUTCDate();
40-
const hours = date.getUTCHours();
41-
const minutes = date.getUTCMinutes();
42-
const seconds = date.getUTCSeconds();
38+
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
39+
const currentDate = date.getUTCDate().toString().padStart(2, '0');
40+
const hours = date.getUTCHours().toString().padStart(2, '0');
41+
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
42+
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
4343
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
4444
}
4545

packages/api/src/crm/engagement/services/leadsquared/mappers.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export class LeadSquaredEngagementMapper implements IEngagementMapper {
3333

3434
formatDateForLeadSquared(date: Date): string {
3535
const year = date.getUTCFullYear();
36-
const month = date.getUTCMonth() + 1;
37-
const currentDate = date.getUTCDate();
38-
const hours = date.getUTCHours();
39-
const minutes = date.getUTCMinutes();
40-
const seconds = date.getUTCSeconds();
36+
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
37+
const currentDate = date.getUTCDate().toString().padStart(2, '0');
38+
const hours = date.getUTCHours().toString().padStart(2, '0');
39+
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
40+
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
4141
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
4242
}
4343

packages/api/src/crm/task/services/leadsquared/mappers.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export class LeadSquaredTaskMapper implements ITaskMapper {
1919

2020
formatDateForLeadSquared(date: Date): string {
2121
const year = date.getUTCFullYear();
22-
const month = date.getUTCMonth() + 1;
23-
const currentDate = date.getUTCDate();
24-
const hours = date.getUTCHours();
25-
const minutes = date.getUTCMinutes();
26-
const seconds = date.getUTCSeconds();
22+
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
23+
const currentDate = date.getUTCDate().toString().padStart(2, '0');
24+
const hours = date.getUTCHours().toString().padStart(2, '0');
25+
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
26+
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
2727
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
2828
}
2929

0 commit comments

Comments
 (0)