Skip to content

Commit

Permalink
fix date pading
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamsidar07 committed Aug 21, 2024
1 parent 0075be9 commit b617d03
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 45 deletions.
28 changes: 13 additions & 15 deletions packages/api/src/crm/contact/services/leadsquared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export class LeadSquaredService implements IContactService {

formatDateForLeadSquared(date: Date): string {
const year = date.getUTCFullYear();
const month = date.getUTCMonth() + 1;
const currentDate = date.getUTCDate();
const hours = date.getUTCHours();
const minutes = date.getUTCMinutes();
const seconds = date.getUTCSeconds();
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
const currentDate = date.getUTCDate().toString().padStart(2, '0');
const hours = date.getUTCHours().toString().padStart(2, '0');
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
}

Expand Down Expand Up @@ -121,17 +121,15 @@ export class LeadSquaredService implements IContactService {
headers,
},
);

const leads = resp?.data['Leads'].map(
(lead: LeadSquaredContactResponse) => {
const leadSquaredContact: LeadSquaredContactOutput = {};
lead.LeadPropertyList.map(
({ Attribute, Value }: { Attribute: string; Value: string }) => {
leadSquaredContact[Attribute] = Value;
},
);
return leadSquaredContact;
},
);
(lead: LeadSquaredContactResponse) =>
lead.LeadPropertyList.reduce((acc, { Attribute, Value }: { Attribute: string; Value: string }) => {
acc[Attribute] = Value;
return acc;
}, {} as LeadSquaredContactOutput)
);

//this.logger.log('CONTACTS LEADSQUARED ' + JSON.stringify(resp.data.data));
this.logger.log(`Synced leadsquared contacts !`);
return {
Expand Down
8 changes: 0 additions & 8 deletions packages/api/src/crm/contact/services/leadsquared/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
type LeadSquaredContact = {
/*
* user_id
* first_name
* last_name
* email
* phone
* address
*/
ProspectID: string;
FirstName: string;
LastName: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/crm/deal/services/leadsquared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class LeadSquaredService implements IDealService {

async sync(data: SyncParam): Promise<ApiResponse<LeadSquaredDealOutput[]>> {
try {
// TODO: I'm not sure about this
// Have to pass the leadId and opportunityType
const { linkedUserId, leadId, opportunityType } = data;
const connection = await this.prisma.connections.findFirst({
where: {
Expand Down
10 changes: 5 additions & 5 deletions packages/api/src/crm/deal/services/leadsquared/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export class LeadSquaredDealMapper implements IDealMapper {
}
formatDateForLeadSquared(date: Date): string {
const year = date.getUTCFullYear();
const month = date.getUTCMonth() + 1;
const currentDate = date.getUTCDate();
const hours = date.getUTCHours();
const minutes = date.getUTCMinutes();
const seconds = date.getUTCSeconds();
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
const currentDate = date.getUTCDate().toString().padStart(2, '0');
const hours = date.getUTCHours().toString().padStart(2, '0');
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/crm/deal/services/leadsquared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ type LeadDetail = {
Attribute: string;
Value: string;
};
// If comments are enabled on opportunity status change, you must pass the mx_Custom_19 (of datatype ‘String’)

type Field = {
SchemaName: string;
Value: string;
Expand Down
10 changes: 5 additions & 5 deletions packages/api/src/crm/engagement/services/leadsquared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export class LeadSquaredService implements IEngagementService {

formatDateForLeadSquared(date: Date): string {
const year = date.getUTCFullYear();
const month = date.getUTCMonth() + 1;
const currentDate = date.getUTCDate();
const hours = date.getUTCHours();
const minutes = date.getUTCMinutes();
const seconds = date.getUTCSeconds();
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
const currentDate = date.getUTCDate().toString().padStart(2, '0');
const hours = date.getUTCHours().toString().padStart(2, '0');
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
}

Expand Down
10 changes: 5 additions & 5 deletions packages/api/src/crm/engagement/services/leadsquared/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export class LeadSquaredEngagementMapper implements IEngagementMapper {

formatDateForLeadSquared(date: Date): string {
const year = date.getUTCFullYear();
const month = date.getUTCMonth() + 1;
const currentDate = date.getUTCDate();
const hours = date.getUTCHours();
const minutes = date.getUTCMinutes();
const seconds = date.getUTCSeconds();
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
const currentDate = date.getUTCDate().toString().padStart(2, '0');
const hours = date.getUTCHours().toString().padStart(2, '0');
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
}

Expand Down
10 changes: 5 additions & 5 deletions packages/api/src/crm/task/services/leadsquared/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export class LeadSquaredTaskMapper implements ITaskMapper {

formatDateForLeadSquared(date: Date): string {
const year = date.getUTCFullYear();
const month = date.getUTCMonth() + 1;
const currentDate = date.getUTCDate();
const hours = date.getUTCHours();
const minutes = date.getUTCMinutes();
const seconds = date.getUTCSeconds();
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
const currentDate = date.getUTCDate().toString().padStart(2, '0');
const hours = date.getUTCHours().toString().padStart(2, '0');
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
return `${year}-${month}-${currentDate} ${hours}:${minutes}:${seconds}`;
}

Expand Down

0 comments on commit b617d03

Please sign in to comment.