Skip to content

Commit

Permalink
🐛 Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jun 4, 2024
1 parent 9016a31 commit f1bee72
Show file tree
Hide file tree
Showing 24 changed files with 69 additions and 555 deletions.

This file was deleted.

13 changes: 6 additions & 7 deletions apps/client-ts/src/components/Events/EventsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { DataTableLoading } from "../shared/data-table-loading";
import { events as Event } from "api";
import { useEventsCount } from '@/hooks/get/useEventsCount';
import { useQueryPagination } from '@/hooks/get/useQueryPagination';
import useProjectStore from "@/state/projectStore";

export default function EventsTable() {
const { data: eventsCount } = useEventsCount();
Expand All @@ -22,14 +21,14 @@ export default function EventsTable() {
pageSize: pagination.pageSize,
});

//TODO
const transformedEvents = events?.map((event: Event) => ({
method: event.method, // replace with actual value
url: event.url, // replace with actual value
method: event.method,
url: event.url,
status: event.status,
direction: event.type, // replace with actual value
integration: event.provider, // replace with actual value + logo
date: event.timestamp.toLocaleString(), // convert Date to string
direction: event.type,
integration: event.provider,
id_linked_user: event.id_linked_user,
date: event.timestamp.toLocaleString(),
}));

if(isLoading){
Expand Down
16 changes: 16 additions & 0 deletions apps/client-ts/src/components/Events/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ export const columns: ColumnDef<Event>[] = [
return value.includes(row.getValue(id))
},
},
{
accessorKey: "id_linked_user",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Id Linked User" />
),
cell: ({ row }) => {
return (
<div className="flex items-center">
<Badge variant="outline" className="rounded-sm py-1 font-normal">{row.getValue("id_linked_user")}</Badge>
</div>
)
},
filterFn: (row, id, value) => {
return value.includes(row.getValue(id))
},
},
{
accessorKey: "date",
header: ({ column }) => (
Expand Down
1 change: 1 addition & 0 deletions apps/client-ts/src/components/Events/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const eventSchema = z.object({
status: z.string(),
direction: z.string(),
integration: z.string(),
id_linked_user: z.string(),
date: z.string()
})

Expand Down
1 change: 0 additions & 1 deletion packages/api/src/@core/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { handleServiceError } from '@@core/utils/errors';
import { LoginDto } from './dto/login.dto';
import { VerifyUserDto } from './dto/verify-user.dto';

//TODO: Ensure the JWT is used for user session authentication and that it's short-lived.
@Injectable()
export class AuthService {
constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ConnectionsStrategiesService {
private prisma: PrismaService,
private crypto: EncryptionService,
private configService: ConfigService,
) { }
) {}

async isCustomCredentials(projectId: string, type: string) {
const res = await this.prisma.connection_strategies.findFirst({
Expand Down Expand Up @@ -82,7 +82,7 @@ export class ConnectionsStrategiesService {
id_cs_attribute: uuidv4(),
id_cs_entity: entity.id_cs_entity,
attribute_slug: attribute_slug,
data_type: 'string', //TODO
data_type: 'string',
},
});
const value_ = await this.prisma.cs_values.create({

Check warning on line 88 in packages/api/src/@core/connections-strategies/connections-strategies.service.ts

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'value_' is assigned a value but never used
Expand Down Expand Up @@ -230,8 +230,9 @@ export class ConnectionsStrategiesService {
data = {
...data,
SCOPE:
CONNECTORS_METADATA[vertical.toLowerCase()][provider.toLowerCase()]
.scopes,
CONNECTORS_METADATA[vertical.toLowerCase()][
provider.toLowerCase()
].scopes,
};
}
/*const isSubdomain = needsSubdomain(
Expand Down Expand Up @@ -337,7 +338,7 @@ export class ConnectionsStrategiesService {
values: string[],
) {
try {
console.log("In updateAPI xzx")
console.log('In updateAPI xzx');
const cs = await this.prisma.connection_strategies.findFirst({
where: {
id_connection_strategy: id_cs,
Expand Down Expand Up @@ -368,7 +369,7 @@ export class ConnectionsStrategiesService {
where: {
id_cs_entity: id_cs_entity,
attribute_slug: attribute_slug,
data_type: 'string', //TODO
data_type: 'string',
},
});
const value_ = await this.prisma.cs_values.updateMany({

Check warning on line 375 in packages/api/src/@core/connections-strategies/connections-strategies.service.ts

View workflow job for this annotation

GitHub Actions / Build and Test (18.x)

'value_' is assigned a value but never used
Expand All @@ -382,8 +383,8 @@ export class ConnectionsStrategiesService {
}
return cs;
} catch (error) {
console.log("Error xzx")
console.log(error)
console.log('Error xzx');
console.log(error);
throw new Error('Update Failed');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type GithubOAuthResponse = {
access_token: string;
refresh_token: string;
expires_in: string;
refresh_token_expires_in: string; //TODO
refresh_token_expires_in: string;
token_type: string;
scope: string;
};
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/@core/events/events.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class EventsController {
return await this.eventsService.findEvents(dto, id_project);
}

// todo
@ApiOperation({
operationId: 'getEventsCount',
summary: 'Retrieve Events Count',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ export class ProjectConnectorsController {
return await this.projectConnectorsService.createProjectConnectors(data);
}

// It should be public API and don't have to add AuthGuard
// TODO: add admin control
@ApiOperation({
operationId: 'getConnectorsFromProject',
summary: 'Retrieve connectors by Project Id',
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/@core/utils/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CrmObject, UnifiedCrm } from '@crm/@lib/@types';
import { HrisObject } from '@hris/@lib/@types';
import { AtsObject, UnifiedAts } from '@ats/@lib/@types';
import { AtsObject } from '@ats/@lib/@types';
import { AccountingObject } from '@accounting/@lib/@types';
import { TicketingObject, UnifiedTicketing } from '@ticketing/@lib/@types';
import {
Expand All @@ -14,7 +14,7 @@ import { Type, applyDecorators } from '@nestjs/common';
import { FileStorageObject } from '@filestorage/@lib/@types';
import { MarketingAutomationObject } from '@marketingautomation/@lib/@types';

export type Unified = UnifiedCrm | UnifiedAts | UnifiedTicketing;
export type Unified = UnifiedCrm | UnifiedTicketing;
export type UnifyReturnType = Unified | Unified[];
export type TargetObject =
| CrmObject
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/@core/webhook/webhook.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class WebhookService {
id_webhook_endpoint: webhook.id_webhook_endpoint,
status: 'queued', // queued | processed | failed | success
id_webhooks_payload: w_payload.id_webhooks_payload,
attempt_count: 0, //TODO
attempt_count: 0,
},
});
this.logger.log('adding webhook to the queue ');
Expand Down Expand Up @@ -174,7 +174,7 @@ export class WebhookService {
id_webhook_endpoint: webhook.id_webhook_endpoint,
status: 'processed', // queued | processed | failed | success
id_webhooks_payload: w_payload.id_webhooks_payload,
attempt_count: 0, //TODO
attempt_count: 0,
},
});
this.logger.log('sending the webhook to the client ');
Expand Down
2 changes: 0 additions & 2 deletions packages/api/src/ats/@lib/@types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export enum AtsObject {}

export type UnifiedAts = ''; //TODO;
25 changes: 15 additions & 10 deletions packages/api/src/crm/@lib/@utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ export class Utils {
remote_platform: remote_platform,
},
});
if (!res) return;
/*TODO: throw new Error(
if (!res) {
throw new Error(
`crm_user not found for remote_id ${remote_id} and integration ${remote_platform}`,
);*/
);
}
return res.id_crm_user;
} catch (error) {
throw new Error(error);
Expand Down Expand Up @@ -164,7 +165,9 @@ export class Utils {
id_crm_company: uuid,
},
});
if (!res) return; //throw new Error(`crm_companies not found for uuid ${uuid}`);
if (!res) {
throw new Error(`crm_companies not found for uuid ${uuid}`);
}
return res.remote_id;
} catch (error) {
throw new Error(error);
Expand All @@ -179,10 +182,11 @@ export class Utils {
remote_platform: remote_platform,
},
});
if (!res) return;
/*throw new Error(
if (!res) {
throw new Error(
`crm_companies not found for remote_id ${remote_id} and integration ${remote_platform}`,
);*/
);
}
return res.id_crm_company;
} catch (error) {
throw new Error(error);
Expand Down Expand Up @@ -211,10 +215,11 @@ export class Utils {
remote_platform: remote_platform,
},
});
if (!res) return;
/*TODO: throw new Error(
if (!res) {
throw new Error(
`crm_deals_stages not found for remote_id ${remote_id} and integration ${remote_platform}`,
);*/
);
}
return res.id_crm_deals_stage;
} catch (error) {
throw new Error(error);
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/crm/company/services/company.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ export class CompanyService {
// add the company inside our db
const source_company = resp.data;
const target_company = unifiedObject[0];
const originId =
'id' in source_company ? String(source_company.id) : undefined; //TODO

const existingCompany = await this.prisma.crm_companies.findFirst({
where: {
remote_id: originId,
remote_id: target_company.remote_id,
remote_platform: integrationId,
id_linked_user: linkedUserId,
},
Expand Down Expand Up @@ -253,7 +251,7 @@ export class CompanyService {
created_at: new Date(),
modified_at: new Date(),
id_linked_user: linkedUserId,
remote_id: originId,
remote_id: target_company.remote_id,
remote_platform: integrationId,
};

Expand Down
11 changes: 0 additions & 11 deletions packages/api/src/crm/company/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@ export class SyncService implements OnModuleInit {
async syncCompanies(user_id?: string) {
try {
this.logger.log(`Syncing companies....`);
// TODO: insert inside sync_jobs table ?
/*
{
"common_object": "company",
"vertical": "crm",
"last_sync_start": "",
"next_sync_start": "",
"status": "SYNCING",
"is_initial_sync": true,
}
*/
const users = user_id
? [
await this.prisma.users.findUnique({
Expand Down
10 changes: 2 additions & 8 deletions packages/api/src/crm/contact/services/contact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,10 @@ export class ContactService {
// add the contact inside our db
const source_contact = resp.data;
const target_contact = unifiedObject[0];
const originId =
'id' in source_contact
? String(source_contact.id)
: 'contact_id' in source_contact
? String(source_contact.contact_id)
: undefined;

const existingContact = await this.prisma.crm_contacts.findFirst({
where: {
remote_id: originId,
remote_id: target_contact.remote_id,
remote_platform: integrationId,
id_linked_user: linkedUserId,
},
Expand Down Expand Up @@ -253,7 +247,7 @@ export class ContactService {
created_at: new Date(),
modified_at: new Date(),
id_linked_user: linkedUserId,
remote_id: originId,
remote_id: target_contact.remote_id,
remote_platform: integrationId,
};

Expand Down
5 changes: 2 additions & 3 deletions packages/api/src/crm/deal/services/deal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ export class DealService {
// add the deal inside our db
const source_deal = resp.data;
const target_deal = unifiedObject[0];
const originId = 'id' in source_deal ? String(source_deal.id) : undefined; //TODO

const existingDeal = await this.prisma.crm_deals.findFirst({
where: {
remote_id: originId,
remote_id: target_deal.remote_id,
remote_platform: integrationId,
id_linked_user: linkedUserId,
},
Expand Down Expand Up @@ -171,7 +170,7 @@ export class DealService {
created_at: new Date(),
modified_at: new Date(),
id_linked_user: linkedUserId,
remote_id: originId,
remote_id: target_deal.remote_id,
remote_platform: integrationId,
description: '',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ export class EngagementService {
// add the engagement inside our db
const source_engagement = resp.data;
const target_engagement = unifiedObject[0];
const originId =
'id' in source_engagement ? String(source_engagement.id) : undefined; //TODO

const existingEngagement = await this.prisma.crm_engagements.findFirst({
where: {
remote_id: originId,
remote_id: target_engagement.remote_id,
remote_platform: integrationId,
id_linked_user: linkedUserId,
},
Expand Down Expand Up @@ -202,7 +200,7 @@ export class EngagementService {
created_at: new Date(),
modified_at: new Date(),
id_linked_user: linkedUserId,
remote_id: originId,
remote_id: target_engagement.remote_id,
remote_platform: integrationId,
};

Expand Down
5 changes: 2 additions & 3 deletions packages/api/src/crm/note/services/note.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@ export class NoteService {
// add the note inside our db
const source_note = resp.data;
const target_note = unifiedObject[0];
const originId = 'id' in source_note ? String(source_note.id) : undefined; //TODO

const existingNote = await this.prisma.crm_notes.findFirst({
where: {
remote_id: originId,
remote_id: target_note.remote_id,
remote_platform: integrationId,
id_linked_user: linkedUserId,
},
Expand Down Expand Up @@ -189,7 +188,7 @@ export class NoteService {
created_at: new Date(),
modified_at: new Date(),
id_linked_user: linkedUserId,
remote_id: originId,
remote_id: target_note.remote_id,
remote_platform: integrationId,
};
if (target_note.content) {
Expand Down
Loading

0 comments on commit f1bee72

Please sign in to comment.